作者 yangfu

部门用户

@@ -14,14 +14,19 @@ info( @@ -14,14 +14,19 @@ info(
14 jwt: SystemAuth 14 jwt: SystemAuth
15 ) 15 )
16 service Core { 16 service Core {
  17 + @doc "角色详情"
17 @handler systemGetRole 18 @handler systemGetRole
18 get /system/role/:id (RoleGetRequest) returns (RoleGetResponse) 19 get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
  20 + @doc "角色新增"
19 @handler systemSaveRole 21 @handler systemSaveRole
20 post /system/role (RoleSaveRequest) returns (RoleSaveResponse) 22 post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
  23 + @doc "角色删除"
21 @handler systemDeleteRole 24 @handler systemDeleteRole
22 delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse) 25 delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
  26 + @doc "角色更新"
23 @handler systemUpdateRole 27 @handler systemUpdateRole
24 put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse) 28 put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
  29 + @doc "角色列表搜索"
25 @handler systemSearchRole 30 @handler systemSearchRole
26 post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse) 31 post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
27 } 32 }
@@ -33,9 +33,10 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -33,9 +33,10 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
33 userToken = contextdata.GetUserTokenFromCtx(l.ctx) 33 userToken = contextdata.GetUserTokenFromCtx(l.ctx)
34 users []*domain.User 34 users []*domain.User
35 departments []*domain.Department 35 departments []*domain.Department
  36 + groups = make([]DepartmentUser, 0)
36 ) 37 )
37 resp = map[string]interface{}{ 38 resp = map[string]interface{}{
38 - "list": make([]DepartmentUser, 0), 39 + "list": groups,
39 } 40 }
40 _, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly()) 41 _, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly())
41 if err != nil { 42 if err != nil {
@@ -60,11 +61,15 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -60,11 +61,15 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
60 group.Users = append(group.Users, &domain.User{ 61 group.Users = append(group.Users, &domain.User{
61 Id: user.Id, 62 Id: user.Id,
62 Name: user.Name, 63 Name: user.Name,
  64 + PinYinName: user.PinYinName,
63 }) 65 })
64 } 66 }
65 } 67 }
  68 + groups = append(groups, group)
66 }) 69 })
67 - 70 + resp = map[string]interface{}{
  71 + "list": groups,
  72 + }
68 return 73 return
69 } 74 }
70 75
@@ -2,6 +2,7 @@ package user @@ -2,6 +2,7 @@ package user
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "github.com/samber/lo"
5 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
@@ -33,6 +34,9 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System @@ -33,6 +34,9 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System
33 users []*domain.User 34 users []*domain.User
34 userToken = contextdata.GetUserTokenFromCtx(l.ctx) 35 userToken = contextdata.GetUserTokenFromCtx(l.ctx)
35 ) 36 )
  37 + if !lo.Contains([]int{domain.UserEnable, domain.UserDisable}, req.Status) {
  38 + return nil, xerr.NewErrMsg("启用状态有误")
  39 + }
36 if _, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", req.UserIds).WithFindOnly()); err != nil { 40 if _, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", req.UserIds).WithFindOnly()); err != nil {
37 return nil, xerr.NewErrMsgErr("公司不存在", err) 41 return nil, xerr.NewErrMsgErr("公司不存在", err)
38 } 42 }
@@ -50,5 +54,6 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System @@ -50,5 +54,6 @@ func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.System
50 }, true); err != nil { 54 }, true); err != nil {
51 return nil, xerr.NewErrMsgErr("更新启用状态失败", err) 55 return nil, xerr.NewErrMsgErr("更新启用状态失败", err)
52 } 56 }
  57 + resp = &types.SystemUserAccountEnableResponse{}
53 return 58 return
54 } 59 }
@@ -211,8 +211,8 @@ func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn @@ -211,8 +211,8 @@ func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn
211 total int64 211 total int64
212 ) 212 )
213 queryFunc := func() (interface{}, error) { 213 queryFunc := func() (interface{}, error) {
214 - tx = tx.Model(&ms).Order("id desc")  
215 - tx.Select("id", "name", "departments") 214 + tx = tx.Model(&ms).Order("pin_yin_name asc")
  215 + tx.Select("id", "name", "departments", "pin_yin_name")
216 tx.Where("company_id = ?", companyId) 216 tx.Where("company_id = ?", companyId)
217 tx.Where("audit_status in (?)", domain.UserAuditStatusPassed) 217 tx.Where("audit_status in (?)", domain.UserAuditStatusPassed)
218 tx.Where("enable = ?", domain.UserEnable) 218 tx.Where("enable = ?", domain.UserEnable)