diff --git a/cache/cache.go b/cache/cache.go index 951dd66a..dadc485b 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -7,7 +7,7 @@ import ( "errors" "time" - "github.com/astaxie/beego/logs" + "github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/client/cache" ) @@ -20,7 +20,7 @@ func Get(key string, e interface{}) error { val, err := bm.Get(nilctx, key) if err != nil { - return errors.New("get cache error:"+ err.Error()) + return errors.New("get cache error:" + err.Error()) } if val == nil { diff --git a/commands/daemon/daemon.go b/commands/daemon/daemon.go index 41d47d3e..80fa604c 100644 --- a/commands/daemon/daemon.go +++ b/commands/daemon/daemon.go @@ -6,8 +6,8 @@ import ( "path/filepath" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter" + "github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/server/web" "github.com/kardianos/service" "github.com/mindoc-org/mindoc/commands" diff --git a/commands/install.go b/commands/install.go index 4637d5ce..8d962e68 100644 --- a/commands/install.go +++ b/commands/install.go @@ -7,8 +7,8 @@ import ( "flag" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/models" "github.com/mindoc-org/mindoc/utils" diff --git a/commands/update.go b/commands/update.go index 3c5be9ca..5fc18ebe 100644 --- a/commands/update.go +++ b/commands/update.go @@ -7,7 +7,7 @@ import ( "net/http" "os" - "github.com/astaxie/beego/logs" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" ) diff --git a/controllers/BlogController.go b/controllers/BlogController.go index f886f544..b26c2e20 100644 --- a/controllers/BlogController.go +++ b/controllers/BlogController.go @@ -13,8 +13,9 @@ import ( "strings" "time" - "github.com/astaxie/beego" - "github.com/astaxie/beego/orm" + "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" + "github.com/beego/beego/v2/server/web" "github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/models" "github.com/mindoc-org/mindoc/utils" @@ -50,12 +51,12 @@ func (c *BlogController) Index() { } if c.Ctx.Input.IsPost() { - password := c.GetString("password"); + password := c.GetString("password") if blog.BlogStatus == "password" && password != blog.Password { c.JsonResult(6001, "文章密码不正确") } else if blog.BlogStatus == "password" && password == blog.Password { //如果密码输入正确,则存入session中 - _ = c.CruSession.Set( context.TODO(),blogReadSession, blogId) + _ = c.CruSession.Set(context.TODO(), blogReadSession, blogId) c.JsonResult(0, "OK") } c.JsonResult(0, "OK") @@ -251,7 +252,7 @@ func (c *BlogController) ManageSetting() { blog.Password = blogPassword if err := blog.Save(); err != nil { - beego.Error("保存文章失败 -> ", err) + logs.Error("保存文章失败 -> ", err) c.JsonResult(6011, "保存文章失败") } else { c.JsonResult(0, "ok", blog) @@ -264,7 +265,7 @@ func (c *BlogController) ManageSetting() { } blogId, err := strconv.Atoi(c.Ctx.Input.Param(":id")) - c.Data["DocumentIdentify"] = ""; + c.Data["DocumentIdentify"] = "" if err == nil { blog, err := models.NewBlog().FindByIdAndMemberId(blogId, c.Member.MemberId) if err != nil { @@ -302,7 +303,7 @@ func (c *BlogController) ManageEdit() { blog, err = models.NewBlog().FindByIdAndMemberId(blogId, c.Member.MemberId) } if err != nil { - beego.Error("查询文章失败 ->", err) + logs.Error("查询文章失败 ->", err) c.JsonResult(6002, "查询文章失败") } if version > 0 && blog.Version != version && cover != "yes" { @@ -312,7 +313,7 @@ func (c *BlogController) ManageEdit() { if blog.BlogType == 1 { doc, err := models.NewDocument().Find(blog.DocumentId) if err != nil { - beego.Error("查询关联项目文档时出错 ->", err) + logs.Error("查询关联项目文档时出错 ->", err) c.JsonResult(6003, "查询关联项目文档时出错") } book, err := models.NewBook().Find(doc.BookId) @@ -325,7 +326,7 @@ func (c *BlogController) ManageEdit() { bookResult, err := models.NewBookResult().FindByIdentify(book.Identify, c.Member.MemberId) if err != nil || bookResult.RoleId == conf.BookObserver { - beego.Error("FindByIdentify => ", err) + logs.Error("FindByIdentify => ", err) c.JsonResult(6002, "关联文档不存在或权限不足") } } @@ -336,7 +337,7 @@ func (c *BlogController) ManageEdit() { doc.ModifyTime = time.Now() doc.ModifyAt = c.Member.MemberId if err := doc.InsertOrUpdate("markdown", "release", "content", "modify_time", "modify_at"); err != nil { - beego.Error("保存关联文档时出错 ->", err) + logs.Error("保存关联文档时出错 ->", err) c.JsonResult(6004, "保存关联文档时出错") } } @@ -347,7 +348,7 @@ func (c *BlogController) ManageEdit() { blog.Modified = time.Now() if err := blog.Save("blog_content", "blog_release", "modify_at", "modify_time", "version"); err != nil { - beego.Error("保存文章失败 -> ", err) + logs.Error("保存文章失败 -> ", err) c.JsonResult(6011, "保存文章失败") } else { c.JsonResult(0, "ok", blog) @@ -375,7 +376,7 @@ func (c *BlogController) ManageEdit() { if len(blog.AttachList) > 0 { returnJSON, err := json.Marshal(blog.AttachList) if err != nil { - beego.Error("序列化文章附件时出错 ->", err) + logs.Error("序列化文章附件时出错 ->", err) } else { c.Data["AttachList"] = template.JS(string(returnJSON)) } @@ -385,7 +386,7 @@ func (c *BlogController) ManageEdit() { if conf.GetUploadFileSize() > 0 { c.Data["UploadFileSize"] = conf.GetUploadFileSize() } else { - c.Data["UploadFileSize"] = "undefined"; + c.Data["UploadFileSize"] = "undefined" } c.Data["Model"] = blog } @@ -467,7 +468,7 @@ func (c *BlogController) Upload() { c.JsonResult(6003, "无法解析文件的格式") } //如果文件类型设置为 * 标识不限制文件类型 - if beego.AppConfig.DefaultString("upload_file_ext", "") != "*" { + if web.AppConfig.DefaultString("upload_file_ext", "") != "*" { if !conf.IsAllowUploadFileExt(ext) { c.JsonResult(6004, "不允许的文件类型") } @@ -485,7 +486,7 @@ func (c *BlogController) Upload() { _, err := models.NewBlog().FindByIdAndMemberId(blogId, c.Member.MemberId) if err != nil { - beego.Error("查询文章时出错 -> ", err) + logs.Error("查询文章时出错 -> ", err) if err == orm.ErrNoRows { c.JsonResult(6006, "权限不足") } @@ -505,7 +506,7 @@ func (c *BlogController) Upload() { err = c.SaveToFile(name, filePath) if err != nil { - beego.Error("SaveToFile => ", err) + logs.Error("SaveToFile => ", err) c.JsonResult(6005, "保存文件失败") } @@ -538,14 +539,14 @@ func (c *BlogController) Upload() { if err := attachment.Insert(); err != nil { os.Remove(filePath) - beego.Error("保存文件附件失败 -> ", err) + logs.Error("保存文件附件失败 -> ", err) c.JsonResult(6006, "文件保存失败") } if attachment.HttpPath == "" { attachment.HttpPath = conf.URLForNotHost("BlogController.Download", ":id", blogId, ":attach_id", attachment.AttachmentId) if err := attachment.Update(); err != nil { - beego.Error("保存文件失败 -> ",attachment.FilePath, err) + logs.Error("保存文件失败 -> ", attachment.FilePath, err) c.JsonResult(6005, "保存文件失败") } } @@ -582,7 +583,7 @@ func (c *BlogController) RemoveAttachment() { attach, err := models.NewAttachment().Find(attachId) if err != nil { - beego.Error(err) + logs.Error(err) c.JsonResult(6002, "附件不存在") } @@ -590,7 +591,7 @@ func (c *BlogController) RemoveAttachment() { _, err := models.NewBlog().FindByIdAndMemberId(attach.DocumentId, c.Member.MemberId) if err != nil { - beego.Error(err) + logs.Error(err) c.JsonResult(6003, "文档不存在") } } @@ -602,7 +603,7 @@ func (c *BlogController) RemoveAttachment() { } if err := attach.Delete(); err != nil { - beego.Error(err) + logs.Error(err) c.JsonResult(6005, "删除失败") } @@ -640,7 +641,7 @@ func (c *BlogController) Download() { if err == orm.ErrNoRows { c.ShowErrorPage(404, "附件不存在") } else { - beego.Error("查询附件时出现异常 -> ", err) + logs.Error("查询附件时出现异常 -> ", err) c.ShowErrorPage(500, "查询附件时出现异常") } } @@ -648,7 +649,7 @@ func (c *BlogController) Download() { //如果是链接的文章,需要校验文档ID是否一致,如果不是,需要保证附件的项目ID为0且文档的ID等于博文ID if blog.BlogType == 1 && attachment.DocumentId != blog.DocumentId { c.ShowErrorPage(404, "附件不存在") - } else if blog.BlogType != 1 && (attachment.BookId != 0 || attachment.DocumentId != blogId ) { + } else if blog.BlogType != 1 && (attachment.BookId != 0 || attachment.DocumentId != blogId) { c.ShowErrorPage(404, "附件不存在") } diff --git a/controllers/BookController.go b/controllers/BookController.go index cb0bc30f..7408da1a 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -24,7 +24,7 @@ import ( "github.com/mindoc-org/mindoc/models" "github.com/mindoc-org/mindoc/utils" "github.com/mindoc-org/mindoc/utils/pagination" - "gopkg.in/russross/blackfriday.v2" + "github.com/russross/blackfriday/v2" ) type BookController struct { diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index 4f3ea5e5..4c176741 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -15,9 +15,9 @@ import ( "strings" "time" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/boombuler/barcode" "github.com/boombuler/barcode/qr" "github.com/mindoc-org/mindoc/conf" @@ -27,7 +27,7 @@ import ( "github.com/mindoc-org/mindoc/utils/filetil" "github.com/mindoc-org/mindoc/utils/gopool" "github.com/mindoc-org/mindoc/utils/pagination" - "gopkg.in/russross/blackfriday.v2" + "github.com/russross/blackfriday/v2" ) // DocumentController struct diff --git a/controllers/ManagerController.go b/controllers/ManagerController.go index 1c982c7b..ef70bc3e 100644 --- a/controllers/ManagerController.go +++ b/controllers/ManagerController.go @@ -21,7 +21,7 @@ import ( "github.com/mindoc-org/mindoc/utils" "github.com/mindoc-org/mindoc/utils/filetil" "github.com/mindoc-org/mindoc/utils/pagination" - "gopkg.in/russross/blackfriday.v2" + "github.com/russross/blackfriday/v2" ) type ManagerController struct { diff --git a/go.mod b/go.mod index 7edd45a1..8e1efba3 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.12 require ( github.com/PuerkitoBio/goquery v1.4.1 github.com/andybalholm/cascadia v1.2.0 // indirect - github.com/astaxie/beego v1.12.3 github.com/beego/beego/v2 v2.0.1 github.com/boombuler/barcode v1.0.0 github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect @@ -15,10 +14,9 @@ require ( github.com/lifei6671/gocaptcha v0.1.1 github.com/mattn/go-sqlite3 v2.0.3+incompatible github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 - github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 gopkg.in/asn1-ber.v1 v1.0.0-00010101000000-000000000000 // indirect gopkg.in/ldap.v2 v2.5.1 - gopkg.in/russross/blackfriday.v2 v2.0.0 gopkg.in/yaml.v2 v2.3.0 // indirect ) diff --git a/go.sum b/go.sum index fc962e0c..cb1aa121 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,6 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGn github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk= github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE= github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxBp0T0eFw1RUQY= -github.com/astaxie/beego v1.12.3 h1:SAQkdD2ePye+v8Gn1r4X6IKZM1wd28EyUOVQ3PDSOOQ= -github.com/astaxie/beego v1.12.3/go.mod h1:p3qIm0Ryx7zeBHLljmd7omloyca1s4yu1a8kM1FkpIA= github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE= github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI= github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ= @@ -144,7 +142,6 @@ github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -170,10 +167,10 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo= github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= -github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s= github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= @@ -298,8 +295,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/ldap.v2 v2.5.1 h1:wiu0okdNfjlBzg6UWvd1Hn8Y+Ux17/u/4nlk4CQr6tU= gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/russross/blackfriday.v2 v2.0.0 h1:+FlnIV8DSQnT7NZ43hcVKcdJdzZoeCmJj4Ql8gq5keA= -gopkg.in/russross/blackfriday.v2 v2.0.0/go.mod h1:6sSBNz/GtOm/pJTuh5UmBK2ZHfmnxGbl2NZg1UliSOI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/models/AttachmentModel.go b/models/AttachmentModel.go index 3e871f0d..d13b75c4 100644 --- a/models/AttachmentModel.go +++ b/models/AttachmentModel.go @@ -8,7 +8,7 @@ import ( "strings" - "github.com/astaxie/beego/logs" + "github.com/beego/beego/v2/adapter/logs" "github.com/beego/beego/v2/adapter/orm" "github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/utils/filetil" diff --git a/models/BookModel.go b/models/BookModel.go index e2dd3777..ce93d0eb 100644 --- a/models/BookModel.go +++ b/models/BookModel.go @@ -24,7 +24,7 @@ import ( "github.com/mindoc-org/mindoc/utils/filetil" "github.com/mindoc-org/mindoc/utils/requests" "github.com/mindoc-org/mindoc/utils/ziptil" - "gopkg.in/russross/blackfriday.v2" + "github.com/russross/blackfriday/v2" ) var releaseQueue = make(chan int, 500) diff --git a/models/BookResult.go b/models/BookResult.go index 7309ef6a..2b1a3c02 100644 --- a/models/BookResult.go +++ b/models/BookResult.go @@ -25,7 +25,7 @@ import ( "github.com/mindoc-org/mindoc/utils/gopool" "github.com/mindoc-org/mindoc/utils/requests" "github.com/mindoc-org/mindoc/utils/ziptil" - "gopkg.in/russross/blackfriday.v2" + "github.com/russross/blackfriday/v2" ) var ( diff --git a/models/DocumentHistory.go b/models/DocumentHistory.go index 6fc3f66f..655c8292 100644 --- a/models/DocumentHistory.go +++ b/models/DocumentHistory.go @@ -3,8 +3,8 @@ package models import ( "time" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" ) diff --git a/models/DocumentModel.go b/models/DocumentModel.go index 85992d5b..c081cbd2 100644 --- a/models/DocumentModel.go +++ b/models/DocumentModel.go @@ -12,9 +12,9 @@ import ( "strings" "github.com/PuerkitoBio/goquery" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter" "github.com/beego/beego/v2/client/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/cache" "github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/utils" diff --git a/models/DocumentSearchResult.go b/models/DocumentSearchResult.go index 2c45d9c1..05c92f77 100644 --- a/models/DocumentSearchResult.go +++ b/models/DocumentSearchResult.go @@ -5,8 +5,8 @@ import ( "strings" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" ) type DocumentSearchResult struct { diff --git a/models/Itemsets.go b/models/Itemsets.go index 948b82d1..abe290a6 100644 --- a/models/Itemsets.go +++ b/models/Itemsets.go @@ -5,8 +5,8 @@ import ( "strings" "time" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/utils" "github.com/mindoc-org/mindoc/utils/cryptil" diff --git a/models/LabelModel.go b/models/LabelModel.go index 128a521b..363ba4d1 100644 --- a/models/LabelModel.go +++ b/models/LabelModel.go @@ -3,8 +3,8 @@ package models import ( "strings" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" ) diff --git a/models/Member.go b/models/Member.go index 6a82c01d..0fc3c2d0 100644 --- a/models/Member.go +++ b/models/Member.go @@ -19,9 +19,9 @@ import ( "math" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/utils" ) diff --git a/models/Team.go b/models/Team.go index 360c87dc..17a5fd9d 100644 --- a/models/Team.go +++ b/models/Team.go @@ -4,8 +4,8 @@ import ( "errors" "time" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" ) diff --git a/models/TeamMember.go b/models/TeamMember.go index bf1095ba..7977dffd 100644 --- a/models/TeamMember.go +++ b/models/TeamMember.go @@ -3,8 +3,8 @@ package models import ( "errors" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" ) diff --git a/models/TeamRelationship.go b/models/TeamRelationship.go index 46134800..0efb61cc 100644 --- a/models/TeamRelationship.go +++ b/models/TeamRelationship.go @@ -4,8 +4,8 @@ import ( "errors" "time" - "github.com/astaxie/beego/logs" "github.com/beego/beego/v2/adapter/orm" + "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" ) diff --git a/routers/filter.go b/routers/filter.go index 17f91516..67cc5f2f 100644 --- a/routers/filter.go +++ b/routers/filter.go @@ -5,9 +5,9 @@ import ( "net/url" "regexp" - "github.com/beego/beego/v2" "github.com/beego/beego/v2/adapter" - "github.com/beego/beego/v2/server/web/context" + "github.com/beego/beego/v2/server/web" + "github.com/beego/beego/v2/adapter/context" "github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/models" ) @@ -31,14 +31,14 @@ func init() { } } } - beego.InsertFilter("/manager", beego.BeforeRouter, FilterUser) - beego.InsertFilter("/manager/*", beego.BeforeRouter, FilterUser) - beego.InsertFilter("/setting", beego.BeforeRouter, FilterUser) - beego.InsertFilter("/setting/*", beego.BeforeRouter, FilterUser) - beego.InsertFilter("/book", beego.BeforeRouter, FilterUser) - beego.InsertFilter("/book/*", beego.BeforeRouter, FilterUser) - beego.InsertFilter("/api/*", beego.BeforeRouter, FilterUser) - beego.InsertFilter("/manage/*", beego.BeforeRouter, FilterUser) + adapter.InsertFilter("/manager", web.BeforeRouter, FilterUser) + adapter.InsertFilter("/manager/*", web.BeforeRouter, FilterUser) + adapter.InsertFilter("/setting", web.BeforeRouter, FilterUser) + adapter.InsertFilter("/setting/*", web.BeforeRouter, FilterUser) + adapter.InsertFilter("/book", web.BeforeRouter, FilterUser) + adapter.InsertFilter("/book/*", web.BeforeRouter, FilterUser) + adapter.InsertFilter("/api/*", web.BeforeRouter, FilterUser) + adapter.InsertFilter("/manage/*", web.BeforeRouter, FilterUser) var FinishRouter = func(ctx *context.Context) { ctx.ResponseWriter.Header().Add("MinDoc-Version", conf.VERSION) @@ -55,6 +55,6 @@ func init() { } } } - beego.InsertFilter("/*", beego.BeforeStatic, StartRouter, false) - beego.InsertFilter("/*", beego.BeforeRouter, FinishRouter, false) + adapter.InsertFilter("/*", web.BeforeStatic, StartRouter, false) + adapter.InsertFilter("/*", web.BeforeRouter, FinishRouter, false) } diff --git a/routers/router.go b/routers/router.go index f24e460e..25a4890a 100644 --- a/routers/router.go +++ b/routers/router.go @@ -1,146 +1,146 @@ package routers import ( - "github.com/beego/beego/v2" + "github.com/beego/beego/v2/adapter" "github.com/mindoc-org/mindoc/controllers" ) func init() { - beego.Router("/", &controllers.HomeController{}, "*:Index") + adapter.Router("/", &controllers.HomeController{}, "*:Index") - beego.Router("/login", &controllers.AccountController{}, "*:Login") - beego.Router("/logout", &controllers.AccountController{}, "*:Logout") - beego.Router("/register", &controllers.AccountController{}, "*:Register") - beego.Router("/find_password", &controllers.AccountController{}, "*:FindPassword") - beego.Router("/valid_email", &controllers.AccountController{}, "post:ValidEmail") - beego.Router("/captcha", &controllers.AccountController{}, "*:Captcha") + adapter.Router("/login", &controllers.AccountController{}, "*:Login") + adapter.Router("/logout", &controllers.AccountController{}, "*:Logout") + adapter.Router("/register", &controllers.AccountController{}, "*:Register") + adapter.Router("/find_password", &controllers.AccountController{}, "*:FindPassword") + adapter.Router("/valid_email", &controllers.AccountController{}, "post:ValidEmail") + adapter.Router("/captcha", &controllers.AccountController{}, "*:Captcha") - beego.Router("/manager", &controllers.ManagerController{}, "*:Index") - beego.Router("/manager/users", &controllers.ManagerController{}, "*:Users") - beego.Router("/manager/users/edit/:id", &controllers.ManagerController{}, "*:EditMember") - beego.Router("/manager/member/create", &controllers.ManagerController{}, "post:CreateMember") - beego.Router("/manager/member/delete", &controllers.ManagerController{}, "post:DeleteMember") - beego.Router("/manager/member/update-member-status", &controllers.ManagerController{}, "post:UpdateMemberStatus") - beego.Router("/manager/member/change-member-role", &controllers.ManagerController{}, "post:ChangeMemberRole") - beego.Router("/manager/books", &controllers.ManagerController{}, "*:Books") - beego.Router("/manager/books/edit/:key", &controllers.ManagerController{}, "*:EditBook") - beego.Router("/manager/books/delete", &controllers.ManagerController{}, "*:DeleteBook") + adapter.Router("/manager", &controllers.ManagerController{}, "*:Index") + adapter.Router("/manager/users", &controllers.ManagerController{}, "*:Users") + adapter.Router("/manager/users/edit/:id", &controllers.ManagerController{}, "*:EditMember") + adapter.Router("/manager/member/create", &controllers.ManagerController{}, "post:CreateMember") + adapter.Router("/manager/member/delete", &controllers.ManagerController{}, "post:DeleteMember") + adapter.Router("/manager/member/update-member-status", &controllers.ManagerController{}, "post:UpdateMemberStatus") + adapter.Router("/manager/member/change-member-role", &controllers.ManagerController{}, "post:ChangeMemberRole") + adapter.Router("/manager/books", &controllers.ManagerController{}, "*:Books") + adapter.Router("/manager/books/edit/:key", &controllers.ManagerController{}, "*:EditBook") + adapter.Router("/manager/books/delete", &controllers.ManagerController{}, "*:DeleteBook") - beego.Router("/manager/comments", &controllers.ManagerController{}, "*:Comments") - beego.Router("/manager/setting", &controllers.ManagerController{}, "*:Setting") - beego.Router("/manager/books/token", &controllers.ManagerController{}, "post:CreateToken") - beego.Router("/manager/books/transfer", &controllers.ManagerController{}, "post:Transfer") - beego.Router("/manager/books/open", &controllers.ManagerController{}, "post:PrivatelyOwned") + adapter.Router("/manager/comments", &controllers.ManagerController{}, "*:Comments") + adapter.Router("/manager/setting", &controllers.ManagerController{}, "*:Setting") + adapter.Router("/manager/books/token", &controllers.ManagerController{}, "post:CreateToken") + adapter.Router("/manager/books/transfer", &controllers.ManagerController{}, "post:Transfer") + adapter.Router("/manager/books/open", &controllers.ManagerController{}, "post:PrivatelyOwned") - beego.Router("/manager/attach/list", &controllers.ManagerController{}, "*:AttachList") - beego.Router("/manager/attach/detailed/:id", &controllers.ManagerController{}, "*:AttachDetailed") - beego.Router("/manager/attach/delete", &controllers.ManagerController{}, "post:AttachDelete") - beego.Router("/manager/label/list", &controllers.ManagerController{}, "get:LabelList") - beego.Router("/manager/label/delete/:id", &controllers.ManagerController{}, "post:LabelDelete") + adapter.Router("/manager/attach/list", &controllers.ManagerController{}, "*:AttachList") + adapter.Router("/manager/attach/detailed/:id", &controllers.ManagerController{}, "*:AttachDetailed") + adapter.Router("/manager/attach/delete", &controllers.ManagerController{}, "post:AttachDelete") + adapter.Router("/manager/label/list", &controllers.ManagerController{}, "get:LabelList") + adapter.Router("/manager/label/delete/:id", &controllers.ManagerController{}, "post:LabelDelete") - //beego.Router("/manager/config", &controllers.ManagerController{}, "*:Config") + //adapter.Router("/manager/config", &controllers.ManagerController{}, "*:Config") - beego.Router("/manager/team", &controllers.ManagerController{}, "*:Team") - beego.Router("/manager/team/create", &controllers.ManagerController{}, "POST:TeamCreate") - beego.Router("/manager/team/edit", &controllers.ManagerController{}, "POST:TeamEdit") - beego.Router("/manager/team/delete", &controllers.ManagerController{}, "POST:TeamDelete") + adapter.Router("/manager/team", &controllers.ManagerController{}, "*:Team") + adapter.Router("/manager/team/create", &controllers.ManagerController{}, "POST:TeamCreate") + adapter.Router("/manager/team/edit", &controllers.ManagerController{}, "POST:TeamEdit") + adapter.Router("/manager/team/delete", &controllers.ManagerController{}, "POST:TeamDelete") - beego.Router("/manager/team/member/list/:id", &controllers.ManagerController{}, "*:TeamMemberList") - beego.Router("/manager/team/member/add", &controllers.ManagerController{}, "POST:TeamMemberAdd") - beego.Router("/manager/team/member/delete", &controllers.ManagerController{}, "POST:TeamMemberDelete") - beego.Router("/manager/team/member/change_role", &controllers.ManagerController{}, "POST:TeamChangeMemberRole") - beego.Router("/manager/team/member/search", &controllers.ManagerController{}, "*:TeamSearchMember") + adapter.Router("/manager/team/member/list/:id", &controllers.ManagerController{}, "*:TeamMemberList") + adapter.Router("/manager/team/member/add", &controllers.ManagerController{}, "POST:TeamMemberAdd") + adapter.Router("/manager/team/member/delete", &controllers.ManagerController{}, "POST:TeamMemberDelete") + adapter.Router("/manager/team/member/change_role", &controllers.ManagerController{}, "POST:TeamChangeMemberRole") + adapter.Router("/manager/team/member/search", &controllers.ManagerController{}, "*:TeamSearchMember") - beego.Router("/manager/team/book/list/:id", &controllers.ManagerController{}, "*:TeamBookList") - beego.Router("/manager/team/book/add", &controllers.ManagerController{}, "POST:TeamBookAdd") - beego.Router("/manager/team/book/delete", &controllers.ManagerController{}, "POST:TeamBookDelete") - beego.Router("/manager/team/book/search", &controllers.ManagerController{}, "*:TeamSearchBook") + adapter.Router("/manager/team/book/list/:id", &controllers.ManagerController{}, "*:TeamBookList") + adapter.Router("/manager/team/book/add", &controllers.ManagerController{}, "POST:TeamBookAdd") + adapter.Router("/manager/team/book/delete", &controllers.ManagerController{}, "POST:TeamBookDelete") + adapter.Router("/manager/team/book/search", &controllers.ManagerController{}, "*:TeamSearchBook") - beego.Router("/manager/itemsets", &controllers.ManagerController{}, "*:Itemsets") - beego.Router("/manager/itemsets/edit", &controllers.ManagerController{}, "post:ItemsetsEdit") - beego.Router("/manager/itemsets/delete", &controllers.ManagerController{}, "post:ItemsetsDelete") + adapter.Router("/manager/itemsets", &controllers.ManagerController{}, "*:Itemsets") + adapter.Router("/manager/itemsets/edit", &controllers.ManagerController{}, "post:ItemsetsEdit") + adapter.Router("/manager/itemsets/delete", &controllers.ManagerController{}, "post:ItemsetsDelete") - beego.Router("/setting", &controllers.SettingController{}, "*:Index") - beego.Router("/setting/password", &controllers.SettingController{}, "*:Password") - beego.Router("/setting/upload", &controllers.SettingController{}, "*:Upload") + adapter.Router("/setting", &controllers.SettingController{}, "*:Index") + adapter.Router("/setting/password", &controllers.SettingController{}, "*:Password") + adapter.Router("/setting/upload", &controllers.SettingController{}, "*:Upload") - beego.Router("/book", &controllers.BookController{}, "*:Index") - beego.Router("/book/:key/dashboard", &controllers.BookController{}, "*:Dashboard") - beego.Router("/book/:key/setting", &controllers.BookController{}, "*:Setting") - beego.Router("/book/:key/users", &controllers.BookController{}, "*:Users") - beego.Router("/book/:key/release", &controllers.BookController{}, "post:Release") - beego.Router("/book/:key/sort", &controllers.BookController{}, "post:SaveSort") - beego.Router("/book/:key/teams", &controllers.BookController{}, "*:Team") + adapter.Router("/book", &controllers.BookController{}, "*:Index") + adapter.Router("/book/:key/dashboard", &controllers.BookController{}, "*:Dashboard") + adapter.Router("/book/:key/setting", &controllers.BookController{}, "*:Setting") + adapter.Router("/book/:key/users", &controllers.BookController{}, "*:Users") + adapter.Router("/book/:key/release", &controllers.BookController{}, "post:Release") + adapter.Router("/book/:key/sort", &controllers.BookController{}, "post:SaveSort") + adapter.Router("/book/:key/teams", &controllers.BookController{}, "*:Team") - beego.Router("/book/create", &controllers.BookController{}, "*:Create") - beego.Router("/book/itemsets/search", &controllers.BookController{}, "*:ItemsetsSearch") + adapter.Router("/book/create", &controllers.BookController{}, "*:Create") + adapter.Router("/book/itemsets/search", &controllers.BookController{}, "*:ItemsetsSearch") - beego.Router("/book/users/create", &controllers.BookMemberController{}, "post:AddMember") - beego.Router("/book/users/change", &controllers.BookMemberController{}, "post:ChangeRole") - beego.Router("/book/users/delete", &controllers.BookMemberController{}, "post:RemoveMember") - beego.Router("/book/users/import", &controllers.BookController{}, "post:Import") - beego.Router("/book/users/copy", &controllers.BookController{}, "post:Copy") + adapter.Router("/book/users/create", &controllers.BookMemberController{}, "post:AddMember") + adapter.Router("/book/users/change", &controllers.BookMemberController{}, "post:ChangeRole") + adapter.Router("/book/users/delete", &controllers.BookMemberController{}, "post:RemoveMember") + adapter.Router("/book/users/import", &controllers.BookController{}, "post:Import") + adapter.Router("/book/users/copy", &controllers.BookController{}, "post:Copy") - beego.Router("/book/setting/save", &controllers.BookController{}, "post:SaveBook") - beego.Router("/book/setting/open", &controllers.BookController{}, "post:PrivatelyOwned") - beego.Router("/book/setting/transfer", &controllers.BookController{}, "post:Transfer") - beego.Router("/book/setting/upload", &controllers.BookController{}, "post:UploadCover") - beego.Router("/book/setting/delete", &controllers.BookController{}, "post:Delete") + adapter.Router("/book/setting/save", &controllers.BookController{}, "post:SaveBook") + adapter.Router("/book/setting/open", &controllers.BookController{}, "post:PrivatelyOwned") + adapter.Router("/book/setting/transfer", &controllers.BookController{}, "post:Transfer") + adapter.Router("/book/setting/upload", &controllers.BookController{}, "post:UploadCover") + adapter.Router("/book/setting/delete", &controllers.BookController{}, "post:Delete") - beego.Router("/book/team/add", &controllers.BookController{}, "POST:TeamAdd") - beego.Router("/book/team/delete", &controllers.BookController{}, "POST:TeamDelete") - beego.Router("/book/team/search", &controllers.BookController{}, "*:TeamSearch") + adapter.Router("/book/team/add", &controllers.BookController{}, "POST:TeamAdd") + adapter.Router("/book/team/delete", &controllers.BookController{}, "POST:TeamDelete") + adapter.Router("/book/team/search", &controllers.BookController{}, "*:TeamSearch") //管理文章的路由 - beego.Router("/manage/blogs", &controllers.BlogController{}, "*:ManageList") - beego.Router("/manage/blogs/setting/?:id", &controllers.BlogController{}, "*:ManageSetting") - beego.Router("/manage/blogs/edit/?:id", &controllers.BlogController{}, "*:ManageEdit") - beego.Router("/manage/blogs/delete", &controllers.BlogController{}, "post:ManageDelete") - beego.Router("/manage/blogs/upload", &controllers.BlogController{}, "post:Upload") - beego.Router("/manage/blogs/attach/:id", &controllers.BlogController{}, "post:RemoveAttachment") + adapter.Router("/manage/blogs", &controllers.BlogController{}, "*:ManageList") + adapter.Router("/manage/blogs/setting/?:id", &controllers.BlogController{}, "*:ManageSetting") + adapter.Router("/manage/blogs/edit/?:id", &controllers.BlogController{}, "*:ManageEdit") + adapter.Router("/manage/blogs/delete", &controllers.BlogController{}, "post:ManageDelete") + adapter.Router("/manage/blogs/upload", &controllers.BlogController{}, "post:Upload") + adapter.Router("/manage/blogs/attach/:id", &controllers.BlogController{}, "post:RemoveAttachment") //读文章的路由 - beego.Router("/blogs", &controllers.BlogController{}, "*:List") - beego.Router("/blog-attach/:id:int/:attach_id:int", &controllers.BlogController{}, "get:Download") - beego.Router("/blog-:id([0-9]+).html", &controllers.BlogController{}, "*:Index") + adapter.Router("/blogs", &controllers.BlogController{}, "*:List") + adapter.Router("/blog-attach/:id:int/:attach_id:int", &controllers.BlogController{}, "get:Download") + adapter.Router("/blog-:id([0-9]+).html", &controllers.BlogController{}, "*:Index") //模板相关接口 - beego.Router("/api/template/get", &controllers.TemplateController{}, "get:Get") - beego.Router("/api/template/list", &controllers.TemplateController{}, "post:List") - beego.Router("/api/template/add", &controllers.TemplateController{}, "post:Add") - beego.Router("/api/template/remove", &controllers.TemplateController{}, "post:Delete") + adapter.Router("/api/template/get", &controllers.TemplateController{}, "get:Get") + adapter.Router("/api/template/list", &controllers.TemplateController{}, "post:List") + adapter.Router("/api/template/add", &controllers.TemplateController{}, "post:Add") + adapter.Router("/api/template/remove", &controllers.TemplateController{}, "post:Delete") - beego.Router("/api/attach/remove/", &controllers.DocumentController{}, "post:RemoveAttachment") - beego.Router("/api/:key/edit/?:id", &controllers.DocumentController{}, "*:Edit") - beego.Router("/api/upload", &controllers.DocumentController{}, "post:Upload") - beego.Router("/api/:key/create", &controllers.DocumentController{}, "post:Create") - beego.Router("/api/:key/delete", &controllers.DocumentController{}, "post:Delete") - beego.Router("/api/:key/content/?:id", &controllers.DocumentController{}, "*:Content") - beego.Router("/api/:key/compare/:id", &controllers.DocumentController{}, "*:Compare") - beego.Router("/api/search/user/:key", &controllers.SearchController{}, "*:User") + adapter.Router("/api/attach/remove/", &controllers.DocumentController{}, "post:RemoveAttachment") + adapter.Router("/api/:key/edit/?:id", &controllers.DocumentController{}, "*:Edit") + adapter.Router("/api/upload", &controllers.DocumentController{}, "post:Upload") + adapter.Router("/api/:key/create", &controllers.DocumentController{}, "post:Create") + adapter.Router("/api/:key/delete", &controllers.DocumentController{}, "post:Delete") + adapter.Router("/api/:key/content/?:id", &controllers.DocumentController{}, "*:Content") + adapter.Router("/api/:key/compare/:id", &controllers.DocumentController{}, "*:Compare") + adapter.Router("/api/search/user/:key", &controllers.SearchController{}, "*:User") - beego.Router("/history/get", &controllers.DocumentController{}, "get:History") - beego.Router("/history/delete", &controllers.DocumentController{}, "*:DeleteHistory") - beego.Router("/history/restore", &controllers.DocumentController{}, "*:RestoreHistory") + adapter.Router("/history/get", &controllers.DocumentController{}, "get:History") + adapter.Router("/history/delete", &controllers.DocumentController{}, "*:DeleteHistory") + adapter.Router("/history/restore", &controllers.DocumentController{}, "*:RestoreHistory") - beego.Router("/docs/:key", &controllers.DocumentController{}, "*:Index") - beego.Router("/docs/:key/:id", &controllers.DocumentController{}, "*:Read") - beego.Router("/docs/:key/search", &controllers.DocumentController{}, "post:Search") - beego.Router("/export/:key", &controllers.DocumentController{}, "*:Export") - beego.Router("/qrcode/:key.png", &controllers.DocumentController{}, "get:QrCode") + adapter.Router("/docs/:key", &controllers.DocumentController{}, "*:Index") + adapter.Router("/docs/:key/:id", &controllers.DocumentController{}, "*:Read") + adapter.Router("/docs/:key/search", &controllers.DocumentController{}, "post:Search") + adapter.Router("/export/:key", &controllers.DocumentController{}, "*:Export") + adapter.Router("/qrcode/:key.png", &controllers.DocumentController{}, "get:QrCode") - beego.Router("/attach_files/:key/:attach_id", &controllers.DocumentController{}, "get:DownloadAttachment") + adapter.Router("/attach_files/:key/:attach_id", &controllers.DocumentController{}, "get:DownloadAttachment") - beego.Router("/comment/create", &controllers.CommentController{}, "post:Create") - beego.Router("/comment/lists", &controllers.CommentController{}, "get:Lists") - beego.Router("/comment/index", &controllers.CommentController{}, "*:Index") + adapter.Router("/comment/create", &controllers.CommentController{}, "post:Create") + adapter.Router("/comment/lists", &controllers.CommentController{}, "get:Lists") + adapter.Router("/comment/index", &controllers.CommentController{}, "*:Index") - beego.Router("/search", &controllers.SearchController{}, "get:Index") + adapter.Router("/search", &controllers.SearchController{}, "get:Index") - beego.Router("/tag/:key", &controllers.LabelController{}, "get:Index") - beego.Router("/tags", &controllers.LabelController{}, "get:List") + adapter.Router("/tag/:key", &controllers.LabelController{}, "get:Index") + adapter.Router("/tags", &controllers.LabelController{}, "get:List") - beego.Router("/items", &controllers.ItemsetsController{}, "get:Index") - beego.Router("/items/:key", &controllers.ItemsetsController{}, "get:List") + adapter.Router("/items", &controllers.ItemsetsController{}, "get:Index") + adapter.Router("/items/:key", &controllers.ItemsetsController{}, "get:List") } diff --git a/utils/ldap.go b/utils/ldap.go index bf58542c..14aa02ef 100644 --- a/utils/ldap.go +++ b/utils/ldap.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/astaxie/beego/logs" + "github.com/beego/beego/v2/core/logs" "gopkg.in/ldap.v2" )