|
@@ -37,7 +37,7 @@ func (c *BookController) Index() {
|
|
|
|
|
|
pageIndex, _ := c.GetInt("page", 1)
|
|
|
|
|
|
- books, totalCount, err := models.NewBook().FindToPager(pageIndex, conf.PageSize, c.Member.MemberId)
|
|
|
+ books, totalCount, err := models.NewBook().FindToPager(pageIndex, conf.PageSize, c.Member.MemberId, c.Lang)
|
|
|
|
|
|
if err != nil {
|
|
|
logs.Error("BookController.Index => ", err)
|
|
@@ -79,7 +79,7 @@ func (c *BookController) Dashboard() {
|
|
|
c.Abort("404")
|
|
|
}
|
|
|
|
|
|
- book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
|
|
|
+ book, err := models.NewBookResult().SetLang(c.Lang).FindByIdentify(key, c.Member.MemberId)
|
|
|
if err != nil {
|
|
|
if err == models.ErrPermissionDenied {
|
|
|
c.Abort("403")
|
|
@@ -204,7 +204,7 @@ func (c *BookController) SaveBook() {
|
|
|
book.AutoSave = 0
|
|
|
}
|
|
|
if err := book.Update(); err != nil {
|
|
|
- c.JsonResult(6006, "保存失败")
|
|
|
+ c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed"))
|
|
|
}
|
|
|
bookResult.BookName = bookName
|
|
|
bookResult.Description = description
|
|
@@ -221,7 +221,7 @@ func (c *BookController) PrivatelyOwned() {
|
|
|
status := c.GetString("status")
|
|
|
|
|
|
if status != "open" && status != "close" {
|
|
|
- c.JsonResult(6003, "参数错误")
|
|
|
+ c.JsonResult(6003, i18n.Tr(c.Lang, "message.param_error"))
|
|
|
}
|
|
|
state := 0
|
|
|
if status == "open" {
|
|
@@ -238,13 +238,13 @@ func (c *BookController) PrivatelyOwned() {
|
|
|
}
|
|
|
//只有创始人才能变更私有状态
|
|
|
if bookResult.RoleId != conf.BookFounder {
|
|
|
- c.JsonResult(6002, "权限不足")
|
|
|
+ c.JsonResult(6002, i18n.Tr(c.Lang, "message.no_permission"))
|
|
|
}
|
|
|
|
|
|
book, err := models.NewBook().Find(bookResult.BookId)
|
|
|
|
|
|
if err != nil {
|
|
|
- c.JsonResult(6005, "项目不存在")
|
|
|
+ c.JsonResult(6005, i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
return
|
|
|
}
|
|
|
book.PrivatelyOwned = state
|
|
@@ -253,7 +253,7 @@ func (c *BookController) PrivatelyOwned() {
|
|
|
|
|
|
if err != nil {
|
|
|
logs.Error("PrivatelyOwned => ", err)
|
|
|
- c.JsonResult(6004, "保存失败")
|
|
|
+ c.JsonResult(6004, i18n.Tr(c.Lang, "message.failed"))
|
|
|
}
|
|
|
logs.Info("用户 【", c.Member.Account, "]修改了项目权限 ->", state)
|
|
|
c.JsonResult(0, "ok")
|
|
@@ -265,19 +265,19 @@ func (c *BookController) Transfer() {
|
|
|
account := c.GetString("account")
|
|
|
|
|
|
if account == "" {
|
|
|
- c.JsonResult(6004, "接受者账号不能为空")
|
|
|
+ c.JsonResult(6004, i18n.Tr(c.Lang, "message.receive_account_empty"))
|
|
|
}
|
|
|
member, err := models.NewMember().FindByAccount(account)
|
|
|
|
|
|
if err != nil {
|
|
|
logs.Error("FindByAccount => ", err)
|
|
|
- c.JsonResult(6005, "接受用户不存在")
|
|
|
+ c.JsonResult(6005, i18n.Tr(c.Lang, "message.receive_account_not_exist"))
|
|
|
}
|
|
|
if member.Status != 0 {
|
|
|
- c.JsonResult(6006, "接受用户已被禁用")
|
|
|
+ c.JsonResult(6006, i18n.Tr(c.Lang, "message.receive_account_disabled"))
|
|
|
}
|
|
|
if member.MemberId == c.Member.MemberId {
|
|
|
- c.JsonResult(6007, "不能转让给自己")
|
|
|
+ c.JsonResult(6007, i18n.Tr(c.Lang, "message.cannot_handover_myself"))
|
|
|
}
|
|
|
bookResult, err := c.IsPermission()
|
|
|
|
|
@@ -404,7 +404,7 @@ func (c *BookController) Users() {
|
|
|
pageIndex, _ := c.GetInt("page", 1)
|
|
|
|
|
|
if key == "" {
|
|
|
- c.ShowErrorPage(404, "项目不存在或已删除")
|
|
|
+ c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
}
|
|
|
|
|
|
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
|
|
@@ -421,7 +421,7 @@ func (c *BookController) Users() {
|
|
|
}
|
|
|
c.Data["Model"] = *book
|
|
|
|
|
|
- members, totalCount, err := models.NewMemberRelationshipResult().FindForUsersByBookId(book.BookId, pageIndex, conf.PageSize)
|
|
|
+ members, totalCount, err := models.NewMemberRelationshipResult().FindForUsersByBookId(c.Lang, book.BookId, pageIndex, conf.PageSize)
|
|
|
|
|
|
if totalCount > 0 {
|
|
|
pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl())
|
|
@@ -553,7 +553,7 @@ func (c *BookController) Copy() {
|
|
|
|
|
|
identify := strings.TrimSpace(c.GetString("identify", ""))
|
|
|
if identify == "" {
|
|
|
- c.JsonResult(6001, "参数错误")
|
|
|
+ c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
|
|
|
}
|
|
|
book := models.NewBook()
|
|
|
err := book.Copy(identify)
|
|
@@ -641,7 +641,7 @@ func (c *BookController) Import() {
|
|
|
book.Editor = "markdown"
|
|
|
book.Theme = "default"
|
|
|
|
|
|
- go book.ImportBook(tempPath)
|
|
|
+ go book.ImportBook(tempPath, c.Lang)
|
|
|
|
|
|
logs.Info("用户[", c.Member.Account, "]导入了项目 ->", book)
|
|
|
|
|
@@ -657,10 +657,10 @@ func (c *BookController) Import() {
|
|
|
//
|
|
|
// if err != nil {
|
|
|
// if err == models.ErrPermissionDenied {
|
|
|
-// c.JsonResult(403, "权限不足")
|
|
|
+// c.JsonResult(403, i18n.Tr(c.Lang, "message.no_permission"))
|
|
|
// }
|
|
|
// if err == orm.ErrNoRows {
|
|
|
-// c.JsonResult(404, "项目不存在")
|
|
|
+// c.JsonResult(404, i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
// }
|
|
|
// logs.Error("生成阅读令牌失败 =>", err)
|
|
|
// c.JsonResult(6002, err.Error())
|
|
@@ -668,7 +668,7 @@ func (c *BookController) Import() {
|
|
|
// book := models.NewBook()
|
|
|
//
|
|
|
// if _, err := book.Find(bookResult.BookId); err != nil {
|
|
|
-// c.JsonResult(6001, "项目不存在")
|
|
|
+// c.JsonResult(6001, i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
// }
|
|
|
// if action == "create" {
|
|
|
// if bookResult.PrivatelyOwned == 0 {
|
|
@@ -710,7 +710,7 @@ func (c *BookController) Delete() {
|
|
|
err = models.NewBook().ThoroughDeleteBook(bookResult.BookId)
|
|
|
|
|
|
if err == orm.ErrNoRows {
|
|
|
- c.JsonResult(6002, "项目不存在")
|
|
|
+ c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
}
|
|
|
if err != nil {
|
|
|
logs.Error("删除项目 => ", err)
|
|
@@ -741,22 +741,22 @@ func (c *BookController) Release() {
|
|
|
|
|
|
if err != nil {
|
|
|
if err == models.ErrPermissionDenied {
|
|
|
- c.JsonResult(6001, "权限不足")
|
|
|
+ c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
|
|
}
|
|
|
if err == orm.ErrNoRows {
|
|
|
- c.JsonResult(6002, "项目不存在")
|
|
|
+ c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
}
|
|
|
logs.Error(err)
|
|
|
- c.JsonResult(6003, "未知错误")
|
|
|
+ c.JsonResult(6003, i18n.Tr(c.Lang, "message.unknown_exception"))
|
|
|
}
|
|
|
if book.RoleId != conf.BookAdmin && book.RoleId != conf.BookFounder && book.RoleId != conf.BookEditor {
|
|
|
- c.JsonResult(6003, "权限不足")
|
|
|
+ c.JsonResult(6003, i18n.Tr(c.Lang, "message.no_permission"))
|
|
|
}
|
|
|
bookId = book.BookId
|
|
|
}
|
|
|
- go models.NewBook().ReleaseContent(bookId)
|
|
|
+ go models.NewBook().ReleaseContent(bookId, c.Lang)
|
|
|
|
|
|
- c.JsonResult(0, "发布任务已推送到任务队列,稍后将在后台执行。")
|
|
|
+ c.JsonResult(0, i18n.Tr(c.Lang, "message.publish_to_queue"))
|
|
|
}
|
|
|
|
|
|
//文档排序.
|
|
@@ -772,7 +772,7 @@ func (c *BookController) SaveSort() {
|
|
|
if c.Member.IsAdministrator() {
|
|
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
|
|
if err != nil || book == nil {
|
|
|
- c.JsonResult(6001, "项目不存在")
|
|
|
+ c.JsonResult(6001, i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
return
|
|
|
}
|
|
|
bookId = book.BookId
|
|
@@ -784,7 +784,7 @@ func (c *BookController) SaveSort() {
|
|
|
c.Abort("403")
|
|
|
}
|
|
|
if bookResult.RoleId == conf.BookObserver {
|
|
|
- c.JsonResult(6002, "项目不存在或权限不足")
|
|
|
+ c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist_or_no_permit"))
|
|
|
}
|
|
|
bookId = bookResult.BookId
|
|
|
}
|
|
@@ -808,7 +808,7 @@ func (c *BookController) SaveSort() {
|
|
|
continue
|
|
|
}
|
|
|
if doc.BookId != bookId {
|
|
|
- logs.Info("%s", "权限错误")
|
|
|
+ logs.Info("%s", i18n.Tr(c.Lang, "message.no_permission"))
|
|
|
continue
|
|
|
}
|
|
|
sort, ok := item["sort"].(float64)
|
|
@@ -848,15 +848,15 @@ func (c *BookController) Team() {
|
|
|
pageIndex, _ := c.GetInt("page", 1)
|
|
|
|
|
|
if key == "" {
|
|
|
- c.ShowErrorPage(404, "项目不存在或已删除")
|
|
|
+ c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
}
|
|
|
|
|
|
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
|
|
|
if err != nil || book == nil {
|
|
|
if err == models.ErrPermissionDenied {
|
|
|
- c.ShowErrorPage(403, "权限不足")
|
|
|
+ c.ShowErrorPage(403, i18n.Tr(c.Lang, "message.no_permission"))
|
|
|
}
|
|
|
- c.ShowErrorPage(500, "系统错误")
|
|
|
+ c.ShowErrorPage(500, i18n.Tr(c.Lang, "message.system_error"))
|
|
|
return
|
|
|
}
|
|
|
//如果不是创始人也不是管理员则不能操作
|
|
@@ -927,7 +927,7 @@ func (c *BookController) TeamDelete() {
|
|
|
teamId, _ := c.GetInt("teamId")
|
|
|
|
|
|
if teamId <= 0 {
|
|
|
- c.JsonResult(5001, "参数错误")
|
|
|
+ c.JsonResult(5001, i18n.Tr(c.Lang, "message.param_error"))
|
|
|
}
|
|
|
book, err := c.IsPermission()
|
|
|
|
|
@@ -992,22 +992,22 @@ func (c *BookController) IsPermission() (*models.BookResult, error) {
|
|
|
identify := c.GetString("identify")
|
|
|
|
|
|
if identify == "" {
|
|
|
- return nil, errors.New("参数错误")
|
|
|
+ return nil, errors.New(i18n.Tr(c.Lang, "message.param_error"))
|
|
|
}
|
|
|
|
|
|
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
|
|
|
|
|
if err != nil {
|
|
|
if err == models.ErrPermissionDenied {
|
|
|
- return book, errors.New("权限不足")
|
|
|
+ return book, errors.New(i18n.Tr(c.Lang, "message.no_permission"))
|
|
|
}
|
|
|
if err == orm.ErrNoRows {
|
|
|
- return book, errors.New("项目不存在")
|
|
|
+ return book, errors.New(i18n.Tr(c.Lang, "message.item_not_exist"))
|
|
|
}
|
|
|
return book, err
|
|
|
}
|
|
|
if book.RoleId != conf.BookAdmin && book.RoleId != conf.BookFounder {
|
|
|
- return book, errors.New("权限不足")
|
|
|
+ return book, errors.New(i18n.Tr(c.Lang, "message.no_permission"))
|
|
|
}
|
|
|
return book, nil
|
|
|
}
|