作者 yangfu

fix:分组用户修改

... ... @@ -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,19 +75,20 @@ func (l *SystemListLogic) SystemList(req *types.DepartmentListRequest) (resp *ty
TotalUser: len(users),
})
}
}
if req.IncludeDefaultDepartment {
to := types.Department{
Id: domain.DefaultDepartmentId,
CompanyId: company.Id,
CompanyId: userToken.CompanyId,
ParentId: 0,
Name: "默认分组",
Name: "未分组",
}
if v, ok := counterByDepartment[domain.DefaultDepartmentId]; ok {
to.TotalUser = v
}
resp.List = append(resp.List, to)
}
}
for _, item := range list {
to := types.Department{
... ...
... ... @@ -40,7 +40,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
"list": groups,
}
company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId)
if err != nil {
if err != nil || company == nil {
return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
}
_, 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
if err != nil {
return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
}
departments = append([]*domain.Department{&domain.Department{Id: 0, Name: company.Name}}, departments...)
departments = append([]*domain.Department{&domain.Department{Id: 0, Name: "未分组"}}, departments...)
lo.ForEach(departments, func(item *domain.Department, index int) {
group := DepartmentUser{
Id: item.Id,
... ...