作者 yangfu

fix:分组用户修改

@@ -44,6 +44,8 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty @@ -44,6 +44,8 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty
44 _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions(). 44 _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
45 MustWithKV("companyId", userToken.CompanyId). 45 MustWithKV("companyId", userToken.CompanyId).
46 WithKV("auditStatus", []int{domain.UserAuditStatusPassed})) 46 WithKV("auditStatus", []int{domain.UserAuditStatusPassed}))
  47 +
  48 + // 统计部门用户数量
47 var counterByDepartment = make(map[int64]int) 49 var counterByDepartment = make(map[int64]int)
48 lo.ForEach(users, func(item *domain.User, index int) { 50 lo.ForEach(users, func(item *domain.User, index int) {
49 if len(item.Departments) == 0 { 51 if len(item.Departments) == 0 {
@@ -73,19 +75,20 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty @@ -73,19 +75,20 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty
73 TotalUser: len(users), 75 TotalUser: len(users),
74 }) 76 })
75 } 77 }
  78 + }
  79 +
76 if req.IncludeDefaultDepartment { 80 if req.IncludeDefaultDepartment {
77 to := types.Department{ 81 to := types.Department{
78 Id: domain.DefaultDepartmentId, 82 Id: domain.DefaultDepartmentId,
79 - CompanyId: company.Id, 83 + CompanyId: userToken.CompanyId,
80 ParentId: 0, 84 ParentId: 0,
81 - Name: "默认分组", 85 + Name: "未分组",
82 } 86 }
83 if v, ok := counterByDepartment[domain.DefaultDepartmentId]; ok { 87 if v, ok := counterByDepartment[domain.DefaultDepartmentId]; ok {
84 to.TotalUser = v 88 to.TotalUser = v
85 } 89 }
86 resp.List = append(resp.List, to) 90 resp.List = append(resp.List, to)
87 } 91 }
88 - }  
89 92
90 for _, item := range list { 93 for _, item := range list {
91 to := types.Department{ 94 to := types.Department{
@@ -40,7 +40,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -40,7 +40,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
40 "list": groups, 40 "list": groups,
41 } 41 }
42 company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId) 42 company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId)
43 - if err != nil { 43 + if err != nil || company == nil {
44 return nil, xerr.NewErrMsgErr("查找部门用户失败", err) 44 return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
45 } 45 }
46 _, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly()) 46 _, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly())
@@ -51,7 +51,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -51,7 +51,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
51 if err != nil { 51 if err != nil {
52 return nil, xerr.NewErrMsgErr("查找部门用户失败", err) 52 return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
53 } 53 }
54 - departments = append([]*domain.Department{&domain.Department{Id: 0, Name: company.Name}}, departments...) 54 + departments = append([]*domain.Department{&domain.Department{Id: 0, Name: "未分组"}}, departments...)
55 lo.ForEach(departments, func(item *domain.Department, index int) { 55 lo.ForEach(departments, func(item *domain.Department, index int) {
56 group := DepartmentUser{ 56 group := DepartmentUser{
57 Id: item.Id, 57 Id: item.Id,