作者 庄敏学
@@ -34,10 +34,15 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -34,10 +34,15 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
34 users []*domain.User 34 users []*domain.User
35 departments []*domain.Department 35 departments []*domain.Department
36 groups = make([]DepartmentUser, 0) 36 groups = make([]DepartmentUser, 0)
  37 + company *domain.Company
37 ) 38 )
38 resp = map[string]interface{}{ 39 resp = map[string]interface{}{
39 "list": groups, 40 "list": groups,
40 } 41 }
  42 + company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId)
  43 + if err != nil {
  44 + return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
  45 + }
41 _, 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())
42 if err != nil { 47 if err != nil {
43 return nil, xerr.NewErrMsgErr("查找部门用户失败", err) 48 return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
@@ -46,6 +51,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -46,6 +51,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
46 if err != nil { 51 if err != nil {
47 return nil, xerr.NewErrMsgErr("查找部门用户失败", err) 52 return nil, xerr.NewErrMsgErr("查找部门用户失败", err)
48 } 53 }
  54 + departments = append([]*domain.Department{&domain.Department{Id: 0, Name: company.Name}}, departments...)
49 lo.ForEach(departments, func(item *domain.Department, index int) { 55 lo.ForEach(departments, func(item *domain.Department, index int) {
50 group := DepartmentUser{ 56 group := DepartmentUser{
51 Id: item.Id, 57 Id: item.Id,
@@ -54,7 +60,16 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -54,7 +60,16 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
54 } 60 }
55 groupUserSet := collection.NewSet() 61 groupUserSet := collection.NewSet()
56 for _, user := range users { 62 for _, user := range users {
  63 + // 未分配部门的归类到公司底下
57 if len(user.Departments) == 0 { 64 if len(user.Departments) == 0 {
  65 + if !groupUserSet.Contains(user.Id) {
  66 + group.Users = append(group.Users, &domain.User{
  67 + Id: user.Id,
  68 + Name: user.Name,
  69 + PinYinName: user.PinYinName,
  70 + Avatar: user.Avatar,
  71 + })
  72 + }
58 continue 73 continue
59 } 74 }
60 if lo.Contains(user.Departments, item.Id) && !groupUserSet.Contains(user.Id) { 75 if lo.Contains(user.Departments, item.Id) && !groupUserSet.Contains(user.Id) {
@@ -68,6 +83,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs @@ -68,6 +83,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs
68 } 83 }
69 groups = append(groups, group) 84 groups = append(groups, group)
70 }) 85 })
  86 +
71 resp = map[string]interface{}{ 87 resp = map[string]interface{}{
72 "list": groups, 88 "list": groups,
73 } 89 }
@@ -102,7 +102,6 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { @@ -102,7 +102,6 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
102 //设置内容概要 102 //设置内容概要
103 103
104 // 截取内容 50个字 104 // 截取内容 50个字
105 - runeNumber := 0 //字数  
106 stringIndex := 0 //字符串长度 105 stringIndex := 0 //字符串长度
107 content := "" 106 content := ""
108 for i := range sectionList { 107 for i := range sectionList {
@@ -112,12 +111,9 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) { @@ -112,12 +111,9 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
112 break 111 break
113 } 112 }
114 } 113 }
115 - for i := range content {  
116 - if runeNumber > 50 {  
117 - break  
118 - }  
119 - runeNumber += 1  
120 - stringIndex = i 114 + stringIndex = len(content)
  115 + if len(content) > 50 {
  116 + stringIndex = 50
121 } 117 }
122 m.Summary = content[0:stringIndex] 118 m.Summary = content[0:stringIndex]
123 } 119 }