From 1b47f0c372655657957684e5448cb3ce403e9f05 Mon Sep 17 00:00:00 2001 From: Go-Go-Farther Date: Tue, 19 Jul 2022 23:56:42 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=201.=20=E7=94=A8=E6=88=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E7=94=A8=E6=88=B7=E8=A7=92=E8=89=B2=E6=A0=8F?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8=EF=BC=9B?= =?UTF-8?q?2.=20=E4=BF=AE=E5=A4=8D=E9=9D=9Ebook=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E4=B8=94=E9=9D=9E=E8=AF=84=E8=AE=BA=E4=BD=9C=E8=80=85=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E8=83=BD=E5=88=A0=E9=99=A4=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E7=9A=84bug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/enumerate.go | 2 ++ controllers/DocumentController.go | 4 ---- controllers/ManagerController.go | 8 +++++--- models/Member.go | 11 ++++++----- models/Relationship.go | 3 +-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/conf/enumerate.go b/conf/enumerate.go index 2fe406a21..507f564ad 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -47,6 +47,8 @@ const ( BookEditor //观察者 BookObserver + //未指定关系 + BookRoleNoSpecific ) //项目角色 diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index 7a99a833a..6339b5a94 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -99,8 +99,6 @@ func (c *DocumentController) Index() { // CheckPassword : Handles password verification for private documents, // and front-end requests are made through Ajax. func (c *DocumentController) CheckPassword() { - c.Prepare() - identify := c.Ctx.Input.Param(":key") password := c.GetString("bPassword") @@ -133,8 +131,6 @@ func (c *DocumentController) CheckPassword() { // 阅读文档 func (c *DocumentController) Read() { - c.Prepare() - identify := c.Ctx.Input.Param(":key") token := c.GetString("token") id := c.GetString(":id") diff --git a/controllers/ManagerController.go b/controllers/ManagerController.go index 8984031be..dea3e5073 100644 --- a/controllers/ManagerController.go +++ b/controllers/ManagerController.go @@ -46,12 +46,13 @@ func (c *ManagerController) Index() { // 用户列表. func (c *ManagerController) Users() { - c.Prepare() c.TplName = "manager/users.tpl" c.Data["Action"] = "users" pageIndex, _ := c.GetInt("page", 0) - members, totalCount, err := models.NewMember().FindToPager(pageIndex, conf.PageSize) + tempMember := models.NewMember() + tempMember.Lang = c.Lang + members, totalCount, err := tempMember.FindToPager(pageIndex, conf.PageSize) if err != nil { c.Data["ErrorMessage"] = err.Error() return @@ -78,7 +79,6 @@ func (c *ManagerController) Users() { // 添加用户. func (c *ManagerController) CreateMember() { - c.Prepare() account := strings.TrimSpace(c.GetString("account")) password1 := strings.TrimSpace(c.GetString("password1")) @@ -120,6 +120,8 @@ func (c *ManagerController) CreateMember() { member.CreateAt = c.Member.MemberId member.Email = email member.RealName = strings.TrimSpace(c.GetString("real_name", "")) + member.Lang = c.Lang + if phone != "" { member.Phone = phone } diff --git a/models/Member.go b/models/Member.go index 7cd8e7c89..49916e242 100644 --- a/models/Member.go +++ b/models/Member.go @@ -330,11 +330,11 @@ func (m *Member) Find(id int, cols ...string) (*Member, error) { func (m *Member) ResolveRoleName() { if m.Role == conf.MemberSuperRole { - m.RoleName = i18n.Tr(m.Lang, "common.administrator") + m.RoleName = i18n.Tr(m.Lang, "uc.super_admin") } else if m.Role == conf.MemberAdminRole { - m.RoleName = i18n.Tr(m.Lang, "common.editor") + m.RoleName = i18n.Tr(m.Lang, "uc.admin") } else if m.Role == conf.MemberGeneralRole { - m.RoleName = i18n.Tr(m.Lang, "common.obverser") + m.RoleName = i18n.Tr(m.Lang, "uc.user") } } @@ -385,8 +385,9 @@ func (m *Member) FindToPager(pageIndex, pageSize int) ([]*Member, int, error) { return members, 0, err } - for _, m := range members { - m.ResolveRoleName() + for _, tm := range members { + tm.Lang = m.Lang + tm.ResolveRoleName() } return members, int(totalCount), nil } diff --git a/models/Relationship.go b/models/Relationship.go index e78b8a8c8..7f9fe801f 100644 --- a/models/Relationship.go +++ b/models/Relationship.go @@ -100,8 +100,7 @@ func (m *Relationship) FindForRoleId(bookId, memberId int) (conf.BookRole, error err := o.QueryTable(m.TableNameWithPrefix()).Filter("book_id", bookId).Filter("member_id", memberId).One(relationship) if err != nil { - - return 0, err + return conf.BookRoleNoSpecific, err } return relationship.RoleId, nil }