mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-06-28 15:45:35 +08:00
User
refactor and update i18n, to be continue
This commit is contained in:
parent
a5682f1308
commit
6eb26fcb23
@ -37,6 +37,10 @@ js_lang = en
|
|||||||
remove = Remove
|
remove = Remove
|
||||||
operate = Operate
|
operate = Operate
|
||||||
confirm = Confirm
|
confirm = Confirm
|
||||||
|
creator = Creator
|
||||||
|
administrator = Administrator
|
||||||
|
editor = Editor
|
||||||
|
observer = Observer
|
||||||
|
|
||||||
[message]
|
[message]
|
||||||
tips = Tips
|
tips = Tips
|
||||||
@ -128,6 +132,8 @@ project_name_empty = Project name cannot be empty
|
|||||||
success = Success
|
success = Success
|
||||||
failed = Failed
|
failed = Failed
|
||||||
receive_account_empty = The recipient account cannot be empty
|
receive_account_empty = The recipient account cannot be empty
|
||||||
|
receive_account_not_exist = The recipient account not exist
|
||||||
|
receive_account_disabled = The recipient account disable
|
||||||
cannot_preview = Cannot preview
|
cannot_preview = Cannot preview
|
||||||
upload_failed = Upload failed
|
upload_failed = Upload failed
|
||||||
upload_file_size_limit = The file must be less than 2MB
|
upload_file_size_limit = The file must be less than 2MB
|
||||||
@ -157,6 +163,10 @@ get_doc_his_failed = Fail to get document history
|
|||||||
project_space_not_exist = Project space does not exist
|
project_space_not_exist = Project space does not exist
|
||||||
search_placeholder = input keyword please
|
search_placeholder = input keyword please
|
||||||
no_search_result = No search results!
|
no_search_result = No search results!
|
||||||
|
user_exist_in_proj = The user already exists in the project
|
||||||
|
cannot_change_own_priv = Cannot change own permissions
|
||||||
|
cannot_delete_self = Cannot delete myself
|
||||||
|
cannot_handover_myself = Cannot handover to myself
|
||||||
|
|
||||||
[blog]
|
[blog]
|
||||||
author = author
|
author = author
|
||||||
@ -242,7 +252,8 @@ search = Search
|
|||||||
expand = Unfold
|
expand = Unfold
|
||||||
fold = Fold
|
fold = Fold
|
||||||
close = Close
|
close = Close
|
||||||
doc_tool_copyright = Document is Published by <a href="https://www.iminho.me" target="_blank">MinDoc</a>
|
doc_publish_by = Document is Published by
|
||||||
|
doc_publish =
|
||||||
edit_doc = Edit Document
|
edit_doc = Edit Document
|
||||||
backward = backward
|
backward = backward
|
||||||
save = save
|
save = save
|
||||||
@ -336,6 +347,10 @@ bg_color = background color
|
|||||||
input_pwd = input password please
|
input_pwd = input password please
|
||||||
read_pwd = read password
|
read_pwd = read password
|
||||||
commit = commit
|
commit = commit
|
||||||
|
ft_author = Author:
|
||||||
|
ft_last_editor = Last editor:
|
||||||
|
ft_create_time = Create time:
|
||||||
|
ft_update_time = Update time:
|
||||||
|
|
||||||
[page]
|
[page]
|
||||||
first = first
|
first = first
|
||||||
|
@ -37,6 +37,10 @@ js_lang = zh-CN
|
|||||||
remove = 移除
|
remove = 移除
|
||||||
operate = 操作
|
operate = 操作
|
||||||
confirm = 确定
|
confirm = 确定
|
||||||
|
creator = 创始人
|
||||||
|
administrator = 管理员
|
||||||
|
editor = 编辑者
|
||||||
|
observer = 观察者
|
||||||
|
|
||||||
[message]
|
[message]
|
||||||
tips = 友情提示
|
tips = 友情提示
|
||||||
@ -128,6 +132,8 @@ project_name_empty = 项目名称不能为空
|
|||||||
success = 成功
|
success = 成功
|
||||||
failed = 失败
|
failed = 失败
|
||||||
receive_account_empty = 接受者账号不能为空
|
receive_account_empty = 接受者账号不能为空
|
||||||
|
receive_account_not_exist = 接受用户不存在
|
||||||
|
receive_account_disabled = 接受用户已被禁用
|
||||||
cannot_preview = 不能预览
|
cannot_preview = 不能预览
|
||||||
upload_failed = 上传失败
|
upload_failed = 上传失败
|
||||||
upload_file_size_limit = 文件必须小于2MB
|
upload_file_size_limit = 文件必须小于2MB
|
||||||
@ -157,6 +163,10 @@ get_doc_his_failed = 获取历史失败
|
|||||||
project_space_not_exist = 项目空间不存在
|
project_space_not_exist = 项目空间不存在
|
||||||
search_placeholder = 请输入搜索关键字
|
search_placeholder = 请输入搜索关键字
|
||||||
no_search_result = 暂无相关搜索结果!
|
no_search_result = 暂无相关搜索结果!
|
||||||
|
user_exist_in_proj = 用户已存在该项目中
|
||||||
|
cannot_change_own_priv = 不能变更自己的权限
|
||||||
|
cannot_delete_self = 不能删除自己
|
||||||
|
cannot_handover_myself = 不能转让给自己
|
||||||
|
|
||||||
[blog]
|
[blog]
|
||||||
author = 作者
|
author = 作者
|
||||||
@ -242,7 +252,8 @@ search = 搜索
|
|||||||
expand = 展开
|
expand = 展开
|
||||||
fold = 收起
|
fold = 收起
|
||||||
close = 关闭
|
close = 关闭
|
||||||
doc_tool_copyright = 本文档使用 <a href="https://www.iminho.me" target="_blank">MinDoc</a> 发布
|
doc_publish_by = 本文档使用
|
||||||
|
doc_publish = 发布
|
||||||
edit_doc = 编辑文档
|
edit_doc = 编辑文档
|
||||||
backward = 返回
|
backward = 返回
|
||||||
save = 保存
|
save = 保存
|
||||||
@ -336,6 +347,10 @@ bg_color = 背景颜色
|
|||||||
input_pwd = 请输入密码
|
input_pwd = 请输入密码
|
||||||
read_pwd = 浏览密码
|
read_pwd = 浏览密码
|
||||||
commit = 提交
|
commit = 提交
|
||||||
|
ft_author = 作者:
|
||||||
|
ft_last_editor = 最后编辑:
|
||||||
|
ft_create_time = 创建时间:
|
||||||
|
ft_update_time = 更新时间:
|
||||||
|
|
||||||
[page]
|
[page]
|
||||||
first = 首页
|
first = 首页
|
||||||
|
@ -37,7 +37,7 @@ func (c *BookController) Index() {
|
|||||||
|
|
||||||
pageIndex, _ := c.GetInt("page", 1)
|
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 {
|
if err != nil {
|
||||||
logs.Error("BookController.Index => ", err)
|
logs.Error("BookController.Index => ", err)
|
||||||
@ -79,7 +79,7 @@ func (c *BookController) Dashboard() {
|
|||||||
c.Abort("404")
|
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 != nil {
|
||||||
if err == models.ErrPermissionDenied {
|
if err == models.ErrPermissionDenied {
|
||||||
c.Abort("403")
|
c.Abort("403")
|
||||||
@ -204,7 +204,7 @@ func (c *BookController) SaveBook() {
|
|||||||
book.AutoSave = 0
|
book.AutoSave = 0
|
||||||
}
|
}
|
||||||
if err := book.Update(); err != nil {
|
if err := book.Update(); err != nil {
|
||||||
c.JsonResult(6006, "保存失败")
|
c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed"))
|
||||||
}
|
}
|
||||||
bookResult.BookName = bookName
|
bookResult.BookName = bookName
|
||||||
bookResult.Description = description
|
bookResult.Description = description
|
||||||
@ -221,7 +221,7 @@ func (c *BookController) PrivatelyOwned() {
|
|||||||
status := c.GetString("status")
|
status := c.GetString("status")
|
||||||
|
|
||||||
if status != "open" && status != "close" {
|
if status != "open" && status != "close" {
|
||||||
c.JsonResult(6003, "参数错误")
|
c.JsonResult(6003, i18n.Tr(c.Lang, "message.param_error"))
|
||||||
}
|
}
|
||||||
state := 0
|
state := 0
|
||||||
if status == "open" {
|
if status == "open" {
|
||||||
@ -238,13 +238,13 @@ func (c *BookController) PrivatelyOwned() {
|
|||||||
}
|
}
|
||||||
//只有创始人才能变更私有状态
|
//只有创始人才能变更私有状态
|
||||||
if bookResult.RoleId != conf.BookFounder {
|
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)
|
book, err := models.NewBook().Find(bookResult.BookId)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JsonResult(6005, "项目不存在")
|
c.JsonResult(6005, i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
book.PrivatelyOwned = state
|
book.PrivatelyOwned = state
|
||||||
@ -253,7 +253,7 @@ func (c *BookController) PrivatelyOwned() {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("PrivatelyOwned => ", err)
|
logs.Error("PrivatelyOwned => ", err)
|
||||||
c.JsonResult(6004, "保存失败")
|
c.JsonResult(6004, i18n.Tr(c.Lang, "message.failed"))
|
||||||
}
|
}
|
||||||
logs.Info("用户 【", c.Member.Account, "]修改了项目权限 ->", state)
|
logs.Info("用户 【", c.Member.Account, "]修改了项目权限 ->", state)
|
||||||
c.JsonResult(0, "ok")
|
c.JsonResult(0, "ok")
|
||||||
@ -265,19 +265,19 @@ func (c *BookController) Transfer() {
|
|||||||
account := c.GetString("account")
|
account := c.GetString("account")
|
||||||
|
|
||||||
if account == "" {
|
if account == "" {
|
||||||
c.JsonResult(6004, "接受者账号不能为空")
|
c.JsonResult(6004, i18n.Tr(c.Lang, "message.receive_account_empty"))
|
||||||
}
|
}
|
||||||
member, err := models.NewMember().FindByAccount(account)
|
member, err := models.NewMember().FindByAccount(account)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("FindByAccount => ", err)
|
logs.Error("FindByAccount => ", err)
|
||||||
c.JsonResult(6005, "接受用户不存在")
|
c.JsonResult(6005, i18n.Tr(c.Lang, "message.receive_account_not_exist"))
|
||||||
}
|
}
|
||||||
if member.Status != 0 {
|
if member.Status != 0 {
|
||||||
c.JsonResult(6006, "接受用户已被禁用")
|
c.JsonResult(6006, i18n.Tr(c.Lang, "message.receive_account_disabled"))
|
||||||
}
|
}
|
||||||
if member.MemberId == c.Member.MemberId {
|
if member.MemberId == c.Member.MemberId {
|
||||||
c.JsonResult(6007, "不能转让给自己")
|
c.JsonResult(6007, i18n.Tr(c.Lang, "message.cannot_handover_myself"))
|
||||||
}
|
}
|
||||||
bookResult, err := c.IsPermission()
|
bookResult, err := c.IsPermission()
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ func (c *BookController) Users() {
|
|||||||
pageIndex, _ := c.GetInt("page", 1)
|
pageIndex, _ := c.GetInt("page", 1)
|
||||||
|
|
||||||
if key == "" {
|
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)
|
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
|
||||||
@ -421,7 +421,7 @@ func (c *BookController) Users() {
|
|||||||
}
|
}
|
||||||
c.Data["Model"] = *book
|
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 {
|
if totalCount > 0 {
|
||||||
pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl())
|
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", ""))
|
identify := strings.TrimSpace(c.GetString("identify", ""))
|
||||||
if identify == "" {
|
if identify == "" {
|
||||||
c.JsonResult(6001, "参数错误")
|
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
|
||||||
}
|
}
|
||||||
book := models.NewBook()
|
book := models.NewBook()
|
||||||
err := book.Copy(identify)
|
err := book.Copy(identify)
|
||||||
@ -641,7 +641,7 @@ func (c *BookController) Import() {
|
|||||||
book.Editor = "markdown"
|
book.Editor = "markdown"
|
||||||
book.Theme = "default"
|
book.Theme = "default"
|
||||||
|
|
||||||
go book.ImportBook(tempPath)
|
go book.ImportBook(tempPath, c.Lang)
|
||||||
|
|
||||||
logs.Info("用户[", c.Member.Account, "]导入了项目 ->", book)
|
logs.Info("用户[", c.Member.Account, "]导入了项目 ->", book)
|
||||||
|
|
||||||
@ -657,10 +657,10 @@ func (c *BookController) Import() {
|
|||||||
//
|
//
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// if err == models.ErrPermissionDenied {
|
// if err == models.ErrPermissionDenied {
|
||||||
// c.JsonResult(403, "权限不足")
|
// c.JsonResult(403, i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
// }
|
// }
|
||||||
// if err == orm.ErrNoRows {
|
// if err == orm.ErrNoRows {
|
||||||
// c.JsonResult(404, "项目不存在")
|
// c.JsonResult(404, i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
// }
|
// }
|
||||||
// logs.Error("生成阅读令牌失败 =>", err)
|
// logs.Error("生成阅读令牌失败 =>", err)
|
||||||
// c.JsonResult(6002, err.Error())
|
// c.JsonResult(6002, err.Error())
|
||||||
@ -668,7 +668,7 @@ func (c *BookController) Import() {
|
|||||||
// book := models.NewBook()
|
// book := models.NewBook()
|
||||||
//
|
//
|
||||||
// if _, err := book.Find(bookResult.BookId); err != nil {
|
// 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 action == "create" {
|
||||||
// if bookResult.PrivatelyOwned == 0 {
|
// if bookResult.PrivatelyOwned == 0 {
|
||||||
@ -710,7 +710,7 @@ func (c *BookController) Delete() {
|
|||||||
err = models.NewBook().ThoroughDeleteBook(bookResult.BookId)
|
err = models.NewBook().ThoroughDeleteBook(bookResult.BookId)
|
||||||
|
|
||||||
if err == orm.ErrNoRows {
|
if err == orm.ErrNoRows {
|
||||||
c.JsonResult(6002, "项目不存在")
|
c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Error("删除项目 => ", err)
|
logs.Error("删除项目 => ", err)
|
||||||
@ -741,22 +741,22 @@ func (c *BookController) Release() {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrPermissionDenied {
|
if err == models.ErrPermissionDenied {
|
||||||
c.JsonResult(6001, "权限不足")
|
c.JsonResult(6001, i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
}
|
}
|
||||||
if err == orm.ErrNoRows {
|
if err == orm.ErrNoRows {
|
||||||
c.JsonResult(6002, "项目不存在")
|
c.JsonResult(6002, i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
}
|
}
|
||||||
logs.Error(err)
|
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 {
|
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
|
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() {
|
if c.Member.IsAdministrator() {
|
||||||
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
book, err := models.NewBook().FindByFieldFirst("identify", identify)
|
||||||
if err != nil || book == nil {
|
if err != nil || book == nil {
|
||||||
c.JsonResult(6001, "项目不存在")
|
c.JsonResult(6001, i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
bookId = book.BookId
|
bookId = book.BookId
|
||||||
@ -784,7 +784,7 @@ func (c *BookController) SaveSort() {
|
|||||||
c.Abort("403")
|
c.Abort("403")
|
||||||
}
|
}
|
||||||
if bookResult.RoleId == conf.BookObserver {
|
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
|
bookId = bookResult.BookId
|
||||||
}
|
}
|
||||||
@ -808,7 +808,7 @@ func (c *BookController) SaveSort() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if doc.BookId != bookId {
|
if doc.BookId != bookId {
|
||||||
logs.Info("%s", "权限错误")
|
logs.Info("%s", i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sort, ok := item["sort"].(float64)
|
sort, ok := item["sort"].(float64)
|
||||||
@ -848,15 +848,15 @@ func (c *BookController) Team() {
|
|||||||
pageIndex, _ := c.GetInt("page", 1)
|
pageIndex, _ := c.GetInt("page", 1)
|
||||||
|
|
||||||
if key == "" {
|
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)
|
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
|
||||||
if err != nil || book == nil {
|
if err != nil || book == nil {
|
||||||
if err == models.ErrPermissionDenied {
|
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
|
return
|
||||||
}
|
}
|
||||||
//如果不是创始人也不是管理员则不能操作
|
//如果不是创始人也不是管理员则不能操作
|
||||||
@ -927,7 +927,7 @@ func (c *BookController) TeamDelete() {
|
|||||||
teamId, _ := c.GetInt("teamId")
|
teamId, _ := c.GetInt("teamId")
|
||||||
|
|
||||||
if teamId <= 0 {
|
if teamId <= 0 {
|
||||||
c.JsonResult(5001, "参数错误")
|
c.JsonResult(5001, i18n.Tr(c.Lang, "message.param_error"))
|
||||||
}
|
}
|
||||||
book, err := c.IsPermission()
|
book, err := c.IsPermission()
|
||||||
|
|
||||||
@ -992,22 +992,22 @@ func (c *BookController) IsPermission() (*models.BookResult, error) {
|
|||||||
identify := c.GetString("identify")
|
identify := c.GetString("identify")
|
||||||
|
|
||||||
if 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)
|
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrPermissionDenied {
|
if err == models.ErrPermissionDenied {
|
||||||
return book, errors.New("权限不足")
|
return book, errors.New(i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
}
|
}
|
||||||
if err == orm.ErrNoRows {
|
if err == orm.ErrNoRows {
|
||||||
return book, errors.New("项目不存在")
|
return book, errors.New(i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
}
|
}
|
||||||
return book, err
|
return book, err
|
||||||
}
|
}
|
||||||
if book.RoleId != conf.BookAdmin && book.RoleId != conf.BookFounder {
|
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
|
return book, nil
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
"github.com/beego/i18n"
|
||||||
"github.com/mindoc-org/mindoc/conf"
|
"github.com/mindoc-org/mindoc/conf"
|
||||||
"github.com/mindoc-org/mindoc/models"
|
"github.com/mindoc-org/mindoc/models"
|
||||||
)
|
)
|
||||||
@ -20,7 +21,7 @@ func (c *BookMemberController) AddMember() {
|
|||||||
roleId, _ := c.GetInt("role_id", 3)
|
roleId, _ := c.GetInt("role_id", 3)
|
||||||
logs.Info(account)
|
logs.Info(account)
|
||||||
if identify == "" || account <= 0 {
|
if identify == "" || account <= 0 {
|
||||||
c.JsonResult(6001, "参数错误")
|
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
|
||||||
}
|
}
|
||||||
book, err := c.IsPermission()
|
book, err := c.IsPermission()
|
||||||
|
|
||||||
@ -31,14 +32,14 @@ func (c *BookMemberController) AddMember() {
|
|||||||
member := models.NewMember()
|
member := models.NewMember()
|
||||||
|
|
||||||
if _, err := member.Find(account); err != nil {
|
if _, err := member.Find(account); err != nil {
|
||||||
c.JsonResult(404, "用户不存在")
|
c.JsonResult(404, i18n.Tr(c.Lang, "message.user_not_existed"))
|
||||||
}
|
}
|
||||||
if member.Status == 1 {
|
if member.Status == 1 {
|
||||||
c.JsonResult(6003, "用户已被禁用")
|
c.JsonResult(6003, i18n.Tr(c.Lang, "message.user_disable"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := models.NewRelationship().FindForRoleId(book.BookId, member.MemberId); err == nil {
|
if _, err := models.NewRelationship().FindForRoleId(book.BookId, member.MemberId); err == nil {
|
||||||
c.JsonResult(6003, "用户已存在该项目中")
|
c.JsonResult(6003, i18n.Tr(c.Lang, "message.user_exist_in_proj"))
|
||||||
}
|
}
|
||||||
|
|
||||||
relationship := models.NewRelationship()
|
relationship := models.NewRelationship()
|
||||||
@ -51,7 +52,7 @@ func (c *BookMemberController) AddMember() {
|
|||||||
memberRelationshipResult.RoleId = conf.BookRole(roleId)
|
memberRelationshipResult.RoleId = conf.BookRole(roleId)
|
||||||
memberRelationshipResult.RelationshipId = relationship.RelationshipId
|
memberRelationshipResult.RelationshipId = relationship.RelationshipId
|
||||||
memberRelationshipResult.BookId = book.BookId
|
memberRelationshipResult.BookId = book.BookId
|
||||||
memberRelationshipResult.ResolveRoleName()
|
memberRelationshipResult.ResolveRoleName(c.Lang)
|
||||||
|
|
||||||
c.JsonResult(0, "ok", memberRelationshipResult)
|
c.JsonResult(0, "ok", memberRelationshipResult)
|
||||||
}
|
}
|
||||||
@ -65,33 +66,33 @@ func (c *BookMemberController) ChangeRole() {
|
|||||||
role, _ := c.GetInt("role_id", 0)
|
role, _ := c.GetInt("role_id", 0)
|
||||||
|
|
||||||
if identify == "" || memberId <= 0 {
|
if identify == "" || memberId <= 0 {
|
||||||
c.JsonResult(6001, "参数错误")
|
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
|
||||||
}
|
}
|
||||||
if memberId == c.Member.MemberId {
|
if memberId == c.Member.MemberId {
|
||||||
c.JsonResult(6006, "不能变更自己的权限")
|
c.JsonResult(6006, i18n.Tr(c.Lang, "message.cannot_change_own_priv"))
|
||||||
}
|
}
|
||||||
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrPermissionDenied {
|
if err == models.ErrPermissionDenied {
|
||||||
c.JsonResult(403, "权限不足")
|
c.JsonResult(403, i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
}
|
}
|
||||||
if err == orm.ErrNoRows {
|
if err == orm.ErrNoRows {
|
||||||
c.JsonResult(404, "项目不存在")
|
c.JsonResult(404, i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
}
|
}
|
||||||
c.JsonResult(6002, err.Error())
|
c.JsonResult(6002, err.Error())
|
||||||
}
|
}
|
||||||
if book.RoleId != 0 && book.RoleId != 1 {
|
if book.RoleId != 0 && book.RoleId != 1 {
|
||||||
c.JsonResult(403, "权限不足")
|
c.JsonResult(403, i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
}
|
}
|
||||||
|
|
||||||
member := models.NewMember()
|
member := models.NewMember()
|
||||||
|
|
||||||
if _, err := member.Find(memberId); err != nil {
|
if _, err := member.Find(memberId); err != nil {
|
||||||
c.JsonResult(6003, "用户不存在")
|
c.JsonResult(6003, i18n.Tr(c.Lang, "message.user_not_existed"))
|
||||||
}
|
}
|
||||||
if member.Status == 1 {
|
if member.Status == 1 {
|
||||||
c.JsonResult(6004, "用户已被禁用")
|
c.JsonResult(6004, i18n.Tr(c.Lang, "message.user_disable"))
|
||||||
}
|
}
|
||||||
|
|
||||||
relationship, err := models.NewRelationship().UpdateRoleId(book.BookId, memberId, conf.BookRole(role))
|
relationship, err := models.NewRelationship().UpdateRoleId(book.BookId, memberId, conf.BookRole(role))
|
||||||
@ -105,7 +106,7 @@ func (c *BookMemberController) ChangeRole() {
|
|||||||
memberRelationshipResult.RoleId = relationship.RoleId
|
memberRelationshipResult.RoleId = relationship.RoleId
|
||||||
memberRelationshipResult.RelationshipId = relationship.RelationshipId
|
memberRelationshipResult.RelationshipId = relationship.RelationshipId
|
||||||
memberRelationshipResult.BookId = book.BookId
|
memberRelationshipResult.BookId = book.BookId
|
||||||
memberRelationshipResult.ResolveRoleName()
|
memberRelationshipResult.ResolveRoleName(c.Lang)
|
||||||
|
|
||||||
c.JsonResult(0, "ok", memberRelationshipResult)
|
c.JsonResult(0, "ok", memberRelationshipResult)
|
||||||
}
|
}
|
||||||
@ -116,25 +117,25 @@ func (c *BookMemberController) RemoveMember() {
|
|||||||
member_id, _ := c.GetInt("member_id", 0)
|
member_id, _ := c.GetInt("member_id", 0)
|
||||||
|
|
||||||
if identify == "" || member_id <= 0 {
|
if identify == "" || member_id <= 0 {
|
||||||
c.JsonResult(6001, "参数错误")
|
c.JsonResult(6001, i18n.Tr(c.Lang, "message.param_error"))
|
||||||
}
|
}
|
||||||
if member_id == c.Member.MemberId {
|
if member_id == c.Member.MemberId {
|
||||||
c.JsonResult(6006, "不能删除自己")
|
c.JsonResult(6006, i18n.Tr(c.Lang, "message.cannot_delete_self"))
|
||||||
}
|
}
|
||||||
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
book, err := models.NewBookResult().FindByIdentify(identify, c.Member.MemberId)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrPermissionDenied {
|
if err == models.ErrPermissionDenied {
|
||||||
c.JsonResult(403, "权限不足")
|
c.JsonResult(403, i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
}
|
}
|
||||||
if err == orm.ErrNoRows {
|
if err == orm.ErrNoRows {
|
||||||
c.JsonResult(404, "项目不存在")
|
c.JsonResult(404, i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
}
|
}
|
||||||
c.JsonResult(6002, err.Error())
|
c.JsonResult(6002, err.Error())
|
||||||
}
|
}
|
||||||
//如果不是创始人也不是管理员则不能操作
|
//如果不是创始人也不是管理员则不能操作
|
||||||
if book.RoleId != conf.BookFounder && book.RoleId != conf.BookAdmin {
|
if book.RoleId != conf.BookFounder && book.RoleId != conf.BookAdmin {
|
||||||
c.JsonResult(403, "权限不足")
|
c.JsonResult(403, i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
}
|
}
|
||||||
err = models.NewRelationship().DeleteByBookIdAndMemberId(book.BookId, member_id)
|
err = models.NewRelationship().DeleteByBookIdAndMemberId(book.BookId, member_id)
|
||||||
|
|
||||||
@ -150,15 +151,15 @@ func (c *BookMemberController) IsPermission() (*models.BookResult, error) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == models.ErrPermissionDenied {
|
if err == models.ErrPermissionDenied {
|
||||||
return book, errors.New("权限不足")
|
return book, errors.New(i18n.Tr(c.Lang, "message.no_permission"))
|
||||||
}
|
}
|
||||||
if err == orm.ErrNoRows {
|
if err == orm.ErrNoRows {
|
||||||
return book, errors.New("项目不存在")
|
return book, errors.New(i18n.Tr(c.Lang, "message.item_not_exist"))
|
||||||
}
|
}
|
||||||
return book, err
|
return book, err
|
||||||
}
|
}
|
||||||
if book.RoleId != conf.BookAdmin && book.RoleId != conf.BookFounder {
|
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
|
return book, nil
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,6 @@ func (c *DocumentController) Read() {
|
|||||||
c.TplName = fmt.Sprintf("document/%s_read.tpl", bookResult.Theme)
|
c.TplName = fmt.Sprintf("document/%s_read.tpl", bookResult.Theme)
|
||||||
|
|
||||||
doc := models.NewDocument()
|
doc := models.NewDocument()
|
||||||
|
|
||||||
if docId, err := strconv.Atoi(id); err == nil {
|
if docId, err := strconv.Atoi(id); err == nil {
|
||||||
doc, err = doc.FromCacheById(docId)
|
doc, err = doc.FromCacheById(docId)
|
||||||
if err != nil || doc == nil {
|
if err != nil || doc == nil {
|
||||||
@ -136,7 +135,7 @@ func (c *DocumentController) Read() {
|
|||||||
if doc.BookId != bookResult.BookId {
|
if doc.BookId != bookResult.BookId {
|
||||||
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.doc_not_exist"))
|
c.ShowErrorPage(404, i18n.Tr(c.Lang, "message.doc_not_exist"))
|
||||||
}
|
}
|
||||||
|
doc.Lang = c.Lang
|
||||||
doc.Processor()
|
doc.Processor()
|
||||||
|
|
||||||
attach, err := models.NewAttachment().FindListByDocumentId(doc.DocumentId)
|
attach, err := models.NewAttachment().FindListByDocumentId(doc.DocumentId)
|
||||||
@ -712,7 +711,6 @@ func (c *DocumentController) Content() {
|
|||||||
isCover := c.GetString("cover")
|
isCover := c.GetString("cover")
|
||||||
|
|
||||||
doc, err := models.NewDocument().Find(docId)
|
doc, err := models.NewDocument().Find(docId)
|
||||||
|
|
||||||
if err != nil || doc == nil {
|
if err != nil || doc == nil {
|
||||||
c.JsonResult(6003, i18n.Tr(c.Lang, "message.read_file_error"))
|
c.JsonResult(6003, i18n.Tr(c.Lang, "message.read_file_error"))
|
||||||
return
|
return
|
||||||
@ -768,6 +766,7 @@ func (c *DocumentController) Content() {
|
|||||||
//如果启用了自动发布
|
//如果启用了自动发布
|
||||||
if autoRelease {
|
if autoRelease {
|
||||||
go func() {
|
go func() {
|
||||||
|
doc.Lang = c.Lang
|
||||||
err := doc.ReleaseContent()
|
err := doc.ReleaseContent()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
logs.Informational(i18n.Tr(c.Lang, "message.doc_auto_published")+"-> document_id=%d;document_name=%s", doc.DocumentId, doc.DocumentName)
|
logs.Informational(i18n.Tr(c.Lang, "message.doc_auto_published")+"-> document_id=%d;document_name=%s", doc.DocumentId, doc.DocumentName)
|
||||||
|
@ -192,6 +192,7 @@ func (c *ManagerController) ChangeMemberRole() {
|
|||||||
if err := member.Update(); err != nil {
|
if err := member.Update(); err != nil {
|
||||||
c.JsonResult(6003, "用户权限设置失败")
|
c.JsonResult(6003, "用户权限设置失败")
|
||||||
}
|
}
|
||||||
|
member.Lang = c.Lang
|
||||||
member.ResolveRoleName()
|
member.ResolveRoleName()
|
||||||
c.JsonResult(0, "ok", member)
|
c.JsonResult(0, "ok", member)
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
"github.com/beego/i18n"
|
||||||
"github.com/mindoc-org/mindoc/conf"
|
"github.com/mindoc-org/mindoc/conf"
|
||||||
"github.com/mindoc-org/mindoc/utils"
|
"github.com/mindoc-org/mindoc/utils"
|
||||||
"github.com/mindoc-org/mindoc/utils/cryptil"
|
"github.com/mindoc-org/mindoc/utils/cryptil"
|
||||||
@ -323,7 +324,7 @@ func (book *Book) FindByIdentify(identify string, cols ...string) (*Book, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//分页查询指定用户的项目
|
//分页查询指定用户的项目
|
||||||
func (book *Book) FindToPager(pageIndex, pageSize, memberId int) (books []*BookResult, totalCount int, err error) {
|
func (book *Book) FindToPager(pageIndex, pageSize, memberId int, lang string) (books []*BookResult, totalCount int, err error) {
|
||||||
|
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
|
|
||||||
@ -391,13 +392,13 @@ ORDER BY book.order_index, book.book_id DESC limit ?,?`
|
|||||||
books[index].LastModifyText = text.Account + " 于 " + text.ModifyTime.Format("2006-01-02 15:04:05")
|
books[index].LastModifyText = text.Account + " 于 " + text.ModifyTime.Format("2006-01-02 15:04:05")
|
||||||
}
|
}
|
||||||
if book.RoleId == 0 {
|
if book.RoleId == 0 {
|
||||||
book.RoleName = "创始人"
|
book.RoleName = i18n.Tr(lang, "common.creator")
|
||||||
} else if book.RoleId == 1 {
|
} else if book.RoleId == 1 {
|
||||||
book.RoleName = "管理员"
|
book.RoleName = i18n.Tr(lang, "common.administrator")
|
||||||
} else if book.RoleId == 2 {
|
} else if book.RoleId == 2 {
|
||||||
book.RoleName = "编辑者"
|
book.RoleName = i18n.Tr(lang, "common.editor")
|
||||||
} else if book.RoleId == 3 {
|
} else if book.RoleId == 3 {
|
||||||
book.RoleName = "观察者"
|
book.RoleName = i18n.Tr(lang, "common.observer")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -585,7 +586,7 @@ WHERE (relationship_id > 0 OR book.privately_owned = 0 or team.team_member_id >
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReleaseContent 批量发布文档
|
// ReleaseContent 批量发布文档
|
||||||
func (book *Book) ReleaseContent(bookId int) {
|
func (book *Book) ReleaseContent(bookId int, lang string) {
|
||||||
releaseQueue <- bookId
|
releaseQueue <- bookId
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
go func() {
|
go func() {
|
||||||
@ -606,6 +607,7 @@ func (book *Book) ReleaseContent(bookId int) {
|
|||||||
}
|
}
|
||||||
for _, item := range docs {
|
for _, item := range docs {
|
||||||
item.BookId = bookId
|
item.BookId = bookId
|
||||||
|
item.Lang = lang
|
||||||
_ = item.ReleaseContent()
|
_ = item.ReleaseContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,7 +635,7 @@ func (book *Book) ResetDocumentNumber(bookId int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//导入项目
|
//导入项目
|
||||||
func (book *Book) ImportBook(zipPath string) error {
|
func (book *Book) ImportBook(zipPath string, lang string) error {
|
||||||
if !filetil.FileExists(zipPath) {
|
if !filetil.FileExists(zipPath) {
|
||||||
return errors.New("文件不存在 => " + zipPath)
|
return errors.New("文件不存在 => " + zipPath)
|
||||||
}
|
}
|
||||||
@ -926,7 +928,7 @@ func (book *Book) ImportBook(zipPath string) error {
|
|||||||
book.Description = "【项目导入存在错误:" + err.Error() + "】"
|
book.Description = "【项目导入存在错误:" + err.Error() + "】"
|
||||||
}
|
}
|
||||||
logs.Info("项目导入完毕 => ", book.BookName)
|
logs.Info("项目导入完毕 => ", book.BookName)
|
||||||
book.ReleaseContent(book.BookId)
|
book.ReleaseContent(book.BookId, lang)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
"github.com/beego/i18n"
|
||||||
"github.com/mindoc-org/mindoc/conf"
|
"github.com/mindoc-org/mindoc/conf"
|
||||||
"github.com/mindoc-org/mindoc/converter"
|
"github.com/mindoc-org/mindoc/converter"
|
||||||
"github.com/mindoc-org/mindoc/utils/cryptil"
|
"github.com/mindoc-org/mindoc/utils/cryptil"
|
||||||
@ -70,6 +71,7 @@ type BookResult struct {
|
|||||||
IsDisplayComment bool `json:"is_display_comment"`
|
IsDisplayComment bool `json:"is_display_comment"`
|
||||||
IsDownload bool `json:"is_download"`
|
IsDownload bool `json:"is_download"`
|
||||||
AutoSave bool `json:"auto_save"`
|
AutoSave bool `json:"auto_save"`
|
||||||
|
Lang string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBookResult() *BookResult {
|
func NewBookResult() *BookResult {
|
||||||
@ -85,6 +87,11 @@ func (m *BookResult) String() string {
|
|||||||
return string(ret)
|
return string(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *BookResult) SetLang(lang string) *BookResult {
|
||||||
|
m.Lang = lang
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
// 根据项目标识查询项目以及指定用户权限的信息.
|
// 根据项目标识查询项目以及指定用户权限的信息.
|
||||||
func (m *BookResult) FindByIdentify(identify string, memberId int) (*BookResult, error) {
|
func (m *BookResult) FindByIdentify(identify string, memberId int) (*BookResult, error) {
|
||||||
if identify == "" || memberId <= 0 {
|
if identify == "" || memberId <= 0 {
|
||||||
@ -131,13 +138,13 @@ func (m *BookResult) FindByIdentify(identify string, memberId int) (*BookResult,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m.RoleId == conf.BookFounder {
|
if m.RoleId == conf.BookFounder {
|
||||||
m.RoleName = "创始人"
|
m.RoleName = i18n.Tr(m.Lang, "common.creator")
|
||||||
} else if m.RoleId == conf.BookAdmin {
|
} else if m.RoleId == conf.BookAdmin {
|
||||||
m.RoleName = "管理员"
|
m.RoleName = i18n.Tr(m.Lang, "common.administrator")
|
||||||
} else if m.RoleId == conf.BookEditor {
|
} else if m.RoleId == conf.BookEditor {
|
||||||
m.RoleName = "编辑者"
|
m.RoleName = i18n.Tr(m.Lang, "common.editor")
|
||||||
} else if m.RoleId == conf.BookObserver {
|
} else if m.RoleId == conf.BookObserver {
|
||||||
m.RoleName = "观察者"
|
m.RoleName = i18n.Tr(m.Lang, "common.observer")
|
||||||
}
|
}
|
||||||
|
|
||||||
doc := NewDocument()
|
doc := NewDocument()
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego/logs"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/astaxie/beego/logs"
|
||||||
|
"github.com/beego/i18n"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -43,6 +45,8 @@ type Document struct {
|
|||||||
//是否展开子目录:0 否/1 是 /2 空间节点,单击时展开下一级
|
//是否展开子目录:0 否/1 是 /2 空间节点,单击时展开下一级
|
||||||
IsOpen int `orm:"column(is_open);type(int);default(0)" json:"is_open"`
|
IsOpen int `orm:"column(is_open);type(int);default(0)" json:"is_open"`
|
||||||
AttachList []*Attachment `orm:"-" json:"attach"`
|
AttachList []*Attachment `orm:"-" json:"attach"`
|
||||||
|
//i18n
|
||||||
|
Lang string `orm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 多字段唯一键
|
// 多字段唯一键
|
||||||
@ -275,7 +279,7 @@ func (item *Document) Processor() *Document {
|
|||||||
//处理附件
|
//处理附件
|
||||||
attachList, err := NewAttachment().FindListByDocumentId(item.DocumentId)
|
attachList, err := NewAttachment().FindListByDocumentId(item.DocumentId)
|
||||||
if err == nil && len(attachList) > 0 {
|
if err == nil && len(attachList) > 0 {
|
||||||
content := bytes.NewBufferString("<div class=\"attach-list\"><strong>附件</strong><ul>")
|
content := bytes.NewBufferString("<div class=\"attach-list\"><strong>" + i18n.Tr(item.Lang, "doc.attachment") + "</strong><ul>")
|
||||||
for _, attach := range attachList {
|
for _, attach := range attachList {
|
||||||
if strings.HasPrefix(attach.HttpPath, "/") {
|
if strings.HasPrefix(attach.HttpPath, "/") {
|
||||||
attach.HttpPath = strings.TrimSuffix(conf.BaseUrl, "/") + attach.HttpPath
|
attach.HttpPath = strings.TrimSuffix(conf.BaseUrl, "/") + attach.HttpPath
|
||||||
@ -305,7 +309,7 @@ func (item *Document) Processor() *Document {
|
|||||||
docCreator, err := NewMember().Find(item.MemberId, "real_name", "account")
|
docCreator, err := NewMember().Find(item.MemberId, "real_name", "account")
|
||||||
release := "<div class=\"wiki-bottom\">"
|
release := "<div class=\"wiki-bottom\">"
|
||||||
|
|
||||||
release += "作者:"
|
release += i18n.Tr(item.Lang, "doc.ft_author")
|
||||||
if err == nil && docCreator != nil {
|
if err == nil && docCreator != nil {
|
||||||
if docCreator.RealName != "" {
|
if docCreator.RealName != "" {
|
||||||
release += docCreator.RealName
|
release += docCreator.RealName
|
||||||
@ -313,19 +317,19 @@ func (item *Document) Processor() *Document {
|
|||||||
release += docCreator.Account
|
release += docCreator.Account
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
release += " 创建时间:" + item.CreateTime.Local().Format("2006-01-02 15:04") + "<br>"
|
release += " " + i18n.Tr(item.Lang, "doc.ft_create_time") + item.CreateTime.Local().Format("2006-01-02 15:04") + "<br>"
|
||||||
|
|
||||||
if item.ModifyAt > 0 {
|
if item.ModifyAt > 0 {
|
||||||
docModify, err := NewMember().Find(item.ModifyAt, "real_name", "account")
|
docModify, err := NewMember().Find(item.ModifyAt, "real_name", "account")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if docModify.RealName != "" {
|
if docModify.RealName != "" {
|
||||||
release += "最后编辑:" + docModify.RealName
|
release += i18n.Tr(item.Lang, "doc.ft_last_editor") + docModify.RealName
|
||||||
} else {
|
} else {
|
||||||
release += "最后编辑:" + docModify.Account
|
release += i18n.Tr(item.Lang, "doc.ft_last_editor") + docModify.Account
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
release += " 更新时间:" + item.ModifyTime.Local().Format("2006-01-02 15:04") + "<br>"
|
release += " " + i18n.Tr(item.Lang, "doc.ft_update_time") + item.ModifyTime.Local().Format("2006-01-02 15:04") + "<br>"
|
||||||
release += "</div>"
|
release += "</div>"
|
||||||
|
|
||||||
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() > 0 {
|
if selector := docQuery.Find("div.markdown-article").First(); selector.Size() > 0 {
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
"github.com/beego/i18n"
|
||||||
"github.com/mindoc-org/mindoc/conf"
|
"github.com/mindoc-org/mindoc/conf"
|
||||||
"github.com/mindoc-org/mindoc/utils"
|
"github.com/mindoc-org/mindoc/utils"
|
||||||
)
|
)
|
||||||
@ -44,6 +45,8 @@ type Member struct {
|
|||||||
CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"`
|
CreateTime time.Time `orm:"type(datetime);column(create_time);auto_now_add" json:"create_time"`
|
||||||
CreateAt int `orm:"type(int);column(create_at)" json:"create_at"`
|
CreateAt int `orm:"type(int);column(create_at)" json:"create_at"`
|
||||||
LastLoginTime time.Time `orm:"type(datetime);column(last_login_time);null" json:"last_login_time"`
|
LastLoginTime time.Time `orm:"type(datetime);column(last_login_time);null" json:"last_login_time"`
|
||||||
|
//i18n
|
||||||
|
Lang string `orm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName 获取对应数据库表名.
|
// TableName 获取对应数据库表名.
|
||||||
@ -321,11 +324,11 @@ func (m *Member) Find(id int, cols ...string) (*Member, error) {
|
|||||||
|
|
||||||
func (m *Member) ResolveRoleName() {
|
func (m *Member) ResolveRoleName() {
|
||||||
if m.Role == conf.MemberSuperRole {
|
if m.Role == conf.MemberSuperRole {
|
||||||
m.RoleName = "超级管理员"
|
m.RoleName = i18n.Tr(m.Lang, "common.administrator")
|
||||||
} else if m.Role == conf.MemberAdminRole {
|
} else if m.Role == conf.MemberAdminRole {
|
||||||
m.RoleName = "管理员"
|
m.RoleName = i18n.Tr(m.Lang, "common.editor")
|
||||||
} else if m.Role == conf.MemberGeneralRole {
|
} else if m.Role == conf.MemberGeneralRole {
|
||||||
m.RoleName = "普通用户"
|
m.RoleName = i18n.Tr(m.Lang, "common.obverser")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
"github.com/beego/i18n"
|
||||||
"github.com/mindoc-org/mindoc/conf"
|
"github.com/mindoc-org/mindoc/conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,19 +55,19 @@ func (m *MemberRelationshipResult) FromMember(member *Member) *MemberRelationshi
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MemberRelationshipResult) ResolveRoleName() *MemberRelationshipResult {
|
func (m *MemberRelationshipResult) ResolveRoleName(lang string) *MemberRelationshipResult {
|
||||||
if m.RoleId == conf.BookAdmin {
|
if m.RoleId == conf.BookAdmin {
|
||||||
m.RoleName = "管理者"
|
m.RoleName = i18n.Tr(lang, "common.administrator")
|
||||||
} else if m.RoleId == conf.BookEditor {
|
} else if m.RoleId == conf.BookEditor {
|
||||||
m.RoleName = "编辑者"
|
m.RoleName = i18n.Tr(lang, "common.editor")
|
||||||
} else if m.RoleId == conf.BookObserver {
|
} else if m.RoleId == conf.BookObserver {
|
||||||
m.RoleName = "观察者"
|
m.RoleName = i18n.Tr(lang, "common.obverser")
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据项目ID查询用户
|
// 根据项目ID查询用户
|
||||||
func (m *MemberRelationshipResult) FindForUsersByBookId(bookId, pageIndex, pageSize int) ([]*MemberRelationshipResult, int, error) {
|
func (m *MemberRelationshipResult) FindForUsersByBookId(lang string, bookId, pageIndex, pageSize int) ([]*MemberRelationshipResult, int, error) {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
|
|
||||||
var members []*MemberRelationshipResult
|
var members []*MemberRelationshipResult
|
||||||
@ -92,7 +93,7 @@ func (m *MemberRelationshipResult) FindForUsersByBookId(bookId, pageIndex, pageS
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range members {
|
for _, item := range members {
|
||||||
item.ResolveRoleName()
|
item.ResolveRoleName(lang)
|
||||||
}
|
}
|
||||||
return members, total_count, nil
|
return members, total_count, nil
|
||||||
}
|
}
|
||||||
@ -118,8 +119,7 @@ func (m *MemberRelationshipResult) FindNotJoinUsersByAccountOrRealName(bookId, l
|
|||||||
|
|
||||||
var members []*Member
|
var members []*Member
|
||||||
|
|
||||||
_, err := o.Raw(sql, bookId, keyWord,keyWord, limit).QueryRows(&members)
|
_, err := o.Raw(sql, bookId, keyWord, keyWord, limit).QueryRows(&members)
|
||||||
|
|
||||||
return members, err
|
return members, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
{{if gt .Member.MemberId 0}}
|
{{if gt .Member.MemberId 0}}
|
||||||
{{if eq .Model.RoleId 0 1 2}}
|
{{if eq .Model.RoleId 0 1 2}}
|
||||||
<div class="dropdown pull-left" style="margin-right: 10px;">
|
<div class="dropdown pull-left" style="margin-right: 10px;">
|
||||||
<a href="{{urlfor "DocumentController.Edit" ":key" .Model.Identify ":id" ""}}" class="btn btn-default"><i class="fa fa-edit" aria-hidden="true"></i> {{i18n .Lang "blog.edit"}}</a>
|
<a href="{{urlfor "DocumentController.Edit" ":key" .Model.Identify ":id" ""}}" class="btn btn-danger"><i class="fa fa-edit" aria-hidden="true"></i> {{i18n .Lang "blog.edit"}}</a>
|
||||||
{{if eq .Model.RoleId 0 1}}
|
{{if eq .Model.RoleId 0 1}}
|
||||||
<a href="{{urlfor "BookController.Users" ":key" .Model.Identify}}" class="btn btn-success"><i class="fa fa-user" aria-hidden="true"></i> {{i18n .Lang "blog.member"}}</a>
|
<a href="{{urlfor "BookController.Users" ":key" .Model.Identify}}" class="btn btn-success"><i class="fa fa-user" aria-hidden="true"></i> {{i18n .Lang "blog.member"}}</a>
|
||||||
<a href="{{urlfor "BookController.Setting" ":key" .Model.Identify}}" class="btn btn-primary"><i class="fa fa-gear" aria-hidden="true"></i> {{i18n .Lang "common.setting"}}</a>
|
<a href="{{urlfor "BookController.Setting" ":key" .Model.Identify}}" class="btn btn-primary"><i class="fa fa-gear" aria-hidden="true"></i> {{i18n .Lang "common.setting"}}</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user