作者 庄敏学
... ... @@ -34,10 +34,15 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
users []*domain.User
departments []*domain.Department
groups = make([]DepartmentUser, 0)
company *domain.Company
)
resp = map[string]interface{}{
"list": groups,
}
company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId)
if err != nil {
return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
}
_, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly())
if err != nil {
return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
... ... @@ -46,6 +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...)
lo.ForEach(departments, func(item *domain.Department, index int) {
group := DepartmentUser{
Id: item.Id,
... ... @@ -54,7 +60,16 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
}
groupUserSet := collection.NewSet()
for _, user := range users {
// 未分配部门的归类到公司底下
if len(user.Departments) == 0 {
if !groupUserSet.Contains(user.Id) {
group.Users = append(group.Users, &domain.User{
Id: user.Id,
Name: user.Name,
PinYinName: user.PinYinName,
Avatar: user.Avatar,
})
}
continue
}
if lo.Contains(user.Departments, item.Id) && !groupUserSet.Contains(user.Id) {
... ... @@ -68,6 +83,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
}
groups = append(groups, group)
})
resp = map[string]interface{}{
"list": groups,
}
... ...
... ... @@ -102,7 +102,6 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
//设置内容概要
// 截取内容 50个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
content := ""
for i := range sectionList {
... ... @@ -112,12 +111,9 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
break
}
}
for i := range content {
if runeNumber > 50 {
break
}
runeNumber += 1
stringIndex = i
stringIndex = len(content)
if len(content) > 50 {
stringIndex = 50
}
m.Summary = content[0:stringIndex]
}
... ...