...
|
...
|
@@ -44,6 +44,8 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty |
|
|
_, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
|
|
|
MustWithKV("companyId", userToken.CompanyId).
|
|
|
WithKV("auditStatus", []int{domain.UserAuditStatusPassed}))
|
|
|
|
|
|
// 统计部门用户数量
|
|
|
var counterByDepartment = make(map[int64]int)
|
|
|
lo.ForEach(users, func(item *domain.User, index int) {
|
|
|
if len(item.Departments) == 0 {
|
...
|
...
|
@@ -73,18 +75,19 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty |
|
|
TotalUser: len(users),
|
|
|
})
|
|
|
}
|
|
|
if req.IncludeDefaultDepartment {
|
|
|
to := types.Department{
|
|
|
Id: domain.DefaultDepartmentId,
|
|
|
CompanyId: company.Id,
|
|
|
ParentId: 0,
|
|
|
Name: "默认分组",
|
|
|
}
|
|
|
if v, ok := counterByDepartment[domain.DefaultDepartmentId]; ok {
|
|
|
to.TotalUser = v
|
|
|
}
|
|
|
resp.List = append(resp.List, to)
|
|
|
}
|
|
|
|
|
|
if req.IncludeDefaultDepartment {
|
|
|
to := types.Department{
|
|
|
Id: domain.DefaultDepartmentId,
|
|
|
CompanyId: userToken.CompanyId,
|
|
|
ParentId: 0,
|
|
|
Name: "未分组",
|
|
|
}
|
|
|
if v, ok := counterByDepartment[domain.DefaultDepartmentId]; ok {
|
|
|
to.TotalUser = v
|
|
|
}
|
|
|
resp.List = append(resp.List, to)
|
|
|
}
|
|
|
|
|
|
for _, item := range list {
|
...
|
...
|
|