mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-21 03:44:17 +08:00
feat:实现自定义模板功能
This commit is contained in:
@@ -197,6 +197,9 @@ func (c *BookController) SaveBook() {
|
||||
bookResult.Description = description
|
||||
bookResult.CommentStatus = commentStatus
|
||||
bookResult.Label = tag
|
||||
|
||||
beego.Info("用户 [",c.Member.Account ,"] 修改了项目 ->",book)
|
||||
|
||||
c.JsonResult(0, "ok", bookResult)
|
||||
}
|
||||
|
||||
@@ -238,6 +241,7 @@ func (c *BookController) PrivatelyOwned() {
|
||||
logs.Error("PrivatelyOwned => ", err)
|
||||
c.JsonResult(6004, "保存失败")
|
||||
}
|
||||
beego.Info("用户 【",c.Member.Account,"]修改了项目权限 ->", state)
|
||||
c.JsonResult(0, "ok")
|
||||
}
|
||||
|
||||
@@ -344,7 +348,7 @@ func (c *BookController) UploadCover() {
|
||||
filePath = filepath.Join(conf.WorkingDirectory, "uploads", time.Now().Format("200601"), fileName+"_small"+ext)
|
||||
|
||||
//生成缩略图并保存到磁盘
|
||||
err = graphics.ImageResizeSaveFile(subImg, 175, 230, filePath)
|
||||
err = graphics.ImageResizeSaveFile(subImg, 350, 460, filePath)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("ImageResizeSaveFile => ", err.Error())
|
||||
@@ -368,6 +372,7 @@ func (c *BookController) UploadCover() {
|
||||
if oldCover != conf.GetDefaultCover() {
|
||||
os.Remove("." + oldCover)
|
||||
}
|
||||
beego.Info("用户[",c.Member.Account,"]上传了项目封面 ->",book.BookName,book.BookId,book.Cover)
|
||||
|
||||
c.JsonResult(0, "ok", url)
|
||||
}
|
||||
@@ -473,7 +478,7 @@ func (c *BookController) Create() {
|
||||
}
|
||||
}
|
||||
|
||||
if books, _ := book.FindByField("identify", identify,"book_id"); len(books) > 0 {
|
||||
if books, _ := book.FindByField("identify", identify, "book_id"); len(books) > 0 {
|
||||
c.JsonResult(6006, "项目标识已存在")
|
||||
}
|
||||
|
||||
@@ -505,32 +510,34 @@ func (c *BookController) Create() {
|
||||
beego.Error(err)
|
||||
}
|
||||
|
||||
beego.Info("用户[",c.Member.Account,"]创建了项目 ->",book)
|
||||
c.JsonResult(0, "ok", bookResult)
|
||||
}
|
||||
c.JsonResult(6001, "error")
|
||||
}
|
||||
|
||||
//复制项目
|
||||
func (c *BookController) Copy(){
|
||||
func (c *BookController) Copy() {
|
||||
if c.Ctx.Input.IsPost() {
|
||||
//检查是否有复制项目的权限
|
||||
if _,err := c.IsPermission(); err != nil{
|
||||
c.JsonResult(500,err.Error())
|
||||
if _, err := c.IsPermission(); err != nil {
|
||||
c.JsonResult(500, err.Error())
|
||||
}
|
||||
|
||||
identify := strings.TrimSpace(c.GetString("identify", ""))
|
||||
if identify == "" {
|
||||
c.JsonResult(6001,"参数错误")
|
||||
c.JsonResult(6001, "参数错误")
|
||||
}
|
||||
book := models.NewBook()
|
||||
err := book.Copy(identify)
|
||||
if err != nil {
|
||||
c.JsonResult(6002,"复制项目出错")
|
||||
}else{
|
||||
c.JsonResult(6002, "复制项目出错")
|
||||
} else {
|
||||
bookResult, err := models.NewBookResult().FindByIdentify(book.Identify, c.Member.MemberId)
|
||||
if err != nil {
|
||||
beego.Error("查询失败")
|
||||
}
|
||||
c.JsonResult(0,"ok",bookResult)
|
||||
c.JsonResult(0, "ok", bookResult)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -572,7 +579,7 @@ func (c *BookController) Import() {
|
||||
c.JsonResult(6004, "不支持的文件类型")
|
||||
}
|
||||
|
||||
if books, _ := models.NewBook().FindByField("identify", identify,"book_id"); len(books) > 0 {
|
||||
if books, _ := models.NewBook().FindByField("identify", identify, "book_id"); len(books) > 0 {
|
||||
c.JsonResult(6006, "项目标识已存在")
|
||||
}
|
||||
|
||||
@@ -602,9 +609,10 @@ func (c *BookController) Import() {
|
||||
book.Editor = "markdown"
|
||||
book.Theme = "default"
|
||||
|
||||
|
||||
go book.ImportBook(tempPath)
|
||||
|
||||
beego.Info("用户[",c.Member.Account,"]导入了项目 ->",book)
|
||||
|
||||
c.JsonResult(0, "项目正在后台转换中,请稍后查看")
|
||||
}
|
||||
|
||||
@@ -640,6 +648,7 @@ func (c *BookController) CreateToken() {
|
||||
logs.Error("生成阅读令牌失败 => ", err)
|
||||
c.JsonResult(6003, "生成阅读令牌失败")
|
||||
}
|
||||
beego.Info("用户[",c.Member.Account,"]创建项目令牌 ->",book.PrivateToken)
|
||||
c.JsonResult(0, "ok", conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken))
|
||||
} else {
|
||||
book.PrivateToken = ""
|
||||
@@ -647,6 +656,7 @@ func (c *BookController) CreateToken() {
|
||||
logs.Error("CreateToken => ", err)
|
||||
c.JsonResult(6004, "删除令牌失败")
|
||||
}
|
||||
beego.Info("用户[",c.Member.Account,"]创建项目令牌 ->",book.PrivateToken)
|
||||
c.JsonResult(0, "ok", "")
|
||||
}
|
||||
}
|
||||
@@ -673,6 +683,7 @@ func (c *BookController) Delete() {
|
||||
logs.Error("删除项目 => ", err)
|
||||
c.JsonResult(6003, "删除失败")
|
||||
}
|
||||
beego.Info("用户[",c.Member.Account,"]删除了项目 ->",bookResult)
|
||||
c.JsonResult(0, "ok")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user