|
@@ -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,18 +75,19 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty |
|
@@ -73,18 +75,19 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty |
73
|
TotalUser: len(users),
|
75
|
TotalUser: len(users),
|
74
|
})
|
76
|
})
|
75
|
}
|
77
|
}
|
76
|
- if req.IncludeDefaultDepartment {
|
|
|
77
|
- to := types.Department{
|
|
|
78
|
- Id: domain.DefaultDepartmentId,
|
|
|
79
|
- CompanyId: company.Id,
|
|
|
80
|
- ParentId: 0,
|
|
|
81
|
- Name: "默认分组",
|
|
|
82
|
- }
|
|
|
83
|
- if v, ok := counterByDepartment[domain.DefaultDepartmentId]; ok {
|
|
|
84
|
- to.TotalUser = v
|
|
|
85
|
- }
|
|
|
86
|
- resp.List = append(resp.List, to)
|
78
|
+ }
|
|
|
79
|
+
|
|
|
80
|
+ if req.IncludeDefaultDepartment {
|
|
|
81
|
+ to := types.Department{
|
|
|
82
|
+ Id: domain.DefaultDepartmentId,
|
|
|
83
|
+ CompanyId: userToken.CompanyId,
|
|
|
84
|
+ ParentId: 0,
|
|
|
85
|
+ Name: "未分组",
|
87
|
}
|
86
|
}
|
|
|
87
|
+ if v, ok := counterByDepartment[domain.DefaultDepartmentId]; ok {
|
|
|
88
|
+ to.TotalUser = v
|
|
|
89
|
+ }
|
|
|
90
|
+ resp.List = append(resp.List, to)
|
88
|
}
|
91
|
}
|
89
|
|
92
|
|
90
|
for _, item := range list {
|
93
|
for _, item := range list {
|