refactor, fix bug and update i18n(search), to be continue

This commit is contained in:
shiqstone
2021-04-18 14:45:04 +08:00
parent 7294ba5489
commit 25e06a767b
5 changed files with 43 additions and 17 deletions

View File

@@ -1,10 +1,12 @@
package controllers
import (
"github.com/astaxie/beego/logs"
"strconv"
"strings"
"github.com/astaxie/beego/logs"
"github.com/beego/i18n"
"github.com/mindoc-org/mindoc/conf"
"github.com/mindoc-org/mindoc/models"
"github.com/mindoc-org/mindoc/utils"
@@ -87,16 +89,16 @@ func (c *SearchController) User() {
key := c.Ctx.Input.Param(":key")
keyword := strings.TrimSpace(c.GetString("q"))
if key == "" || keyword == "" {
c.JsonResult(404, "参数错误")
c.JsonResult(404, i18n.Tr(c.Lang, "message.param_error"))
}
keyword = sqltil.EscapeLike(keyword)
book, err := models.NewBookResult().FindByIdentify(key, c.Member.MemberId)
if err != nil {
if err == models.ErrPermissionDenied {
c.JsonResult(403, "没有权限")
c.JsonResult(403, i18n.Tr(c.Lang, "message.no_permission"))
}
c.JsonResult(500, "项目不存在")
c.JsonResult(500, i18n.Tr(c.Lang, "message.item_not_exist"))
}
//members, err := models.NewMemberRelationshipResult().FindNotJoinUsersByAccount(book.BookId, 10, "%"+keyword+"%")