作者 tangxvhui

Merge branch 'dev' into test

@@ -20,10 +20,6 @@ func MiniUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -20,10 +20,6 @@ func MiniUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
20 20
21 l := user.NewMiniUserInfoLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserInfoLogic(r.Context(), svcCtx)
22 resp, err := l.MiniUserInfo(&req) 22 resp, err := l.MiniUserInfo(&req)
23 - if len(resp.Accounts) == 0 { // 无账号时登出  
24 - httpx.WriteJson(w, http.StatusUnauthorized, nil)  
25 - return  
26 - }  
27 result.HttpResult(r, w, resp, err) 23 result.HttpResult(r, w, resp, err)
28 } 24 }
29 } 25 }
@@ -42,7 +42,10 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr @@ -42,7 +42,10 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr
42 var userList []*domain.User 42 var userList []*domain.User
43 if articleInfo.TargetUser == domain.ArticleTargetAll { 43 if articleInfo.TargetUser == domain.ArticleTargetAll {
44 //获取所有人 44 //获取所有人
45 - queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId) 45 + queryOption := domain.NewQueryOptions().WithFindOnly().
  46 + MustWithKV("companyId", articleInfo.CompanyId).
  47 + MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed})
  48 +
46 _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) 49 _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
47 if err != nil { 50 if err != nil {
48 resp = &types.MiniArticleCommentAtWhoResponse{} 51 resp = &types.MiniArticleCommentAtWhoResponse{}
@@ -91,7 +91,9 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini @@ -91,7 +91,9 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
91 atWhoIds = append(atWhoIds, val.Id) 91 atWhoIds = append(atWhoIds, val.Id)
92 } 92 }
93 atWhoIds = lo.Uniq(atWhoIds) 93 atWhoIds = lo.Uniq(atWhoIds)
94 - queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", atWhoIds) 94 + queryOption := domain.NewQueryOptions().WithFindOnly().
  95 + WithKV("ids", atWhoIds).
  96 + MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed})
95 _, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) 97 _, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
96 if err != nil { 98 if err != nil {
97 return nil, xerr.NewErrMsgErr("检查@的人员失败", err) 99 return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
@@ -49,7 +49,9 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System @@ -49,7 +49,9 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
49 maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead)) 49 maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
50 } else { 50 } else {
51 //统计全员人数 51 //统计全员人数
52 - queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId) 52 + queryOption := domain.NewQueryOptions().WithCountOnly().
  53 + MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
  54 + MustWithKV("companyId", req.CompanyId)
53 cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) 55 cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
54 if err != nil { 56 if err != nil {
55 return nil, xerr.NewErrMsgErr("获取人员数据失败", err) 57 return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
@@ -61,7 +61,9 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type @@ -61,7 +61,9 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type
61 maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead)) 61 maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
62 } else { 62 } else {
63 //统计全员人数 63 //统计全员人数
64 - queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId) 64 + queryOption := domain.NewQueryOptions().WithCountOnly().
  65 + MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
  66 + MustWithKV("companyId", req.CompanyId)
65 cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) 67 cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
66 if err != nil { 68 if err != nil {
67 return nil, xerr.NewErrMsgErr("获取人员数据失败", err) 69 return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
@@ -69,7 +69,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan @@ -69,7 +69,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan
69 return nil, xerr.NewErrMsgErr("公司列表获取失败", err) 69 return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
70 } 70 }
71 } else if req.Flag == 2 { 71 } else if req.Flag == 2 {
72 - total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("excludeIds", companyJoinedList)) 72 + if len(companyJoinedList) > 0 {
  73 + queryOptions.MustWithKV("excludeIds", companyJoinedList)
  74 + }
  75 + total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions)
73 if err != nil { 76 if err != nil {
74 return nil, xerr.NewErrMsgErr("公司列表获取失败", err) 77 return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
75 } 78 }
@@ -2,6 +2,7 @@ package department @@ -2,6 +2,7 @@ package department
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 +
5 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
@@ -58,7 +59,9 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re @@ -58,7 +59,9 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re
58 // 获取公司下的所有用户 59 // 获取公司下的所有用户
59 _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions(). 60 _, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
60 WithFindOnly(). 61 WithFindOnly().
61 - WithKV("companyId", one.CompanyId)) 62 + WithKV("companyId", one.CompanyId).MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}),
  63 + )
  64 +
62 if err != nil { 65 if err != nil {
63 return nil, err 66 return nil, err
64 } 67 }
@@ -267,22 +267,29 @@ func (l *MiniBusinessLogic) createMessage( @@ -267,22 +267,29 @@ func (l *MiniBusinessLogic) createMessage(
267 at []int64) (err error) { 267 at []int64) (err error) {
268 268
269 var userToken = contextdata.GetUserTokenFromCtx(l.ctx) 269 var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
270 - // 评论中携带了 @其他用户 270 + var dupMap = make(map[int64]int64, 0)
  271 + // 评论中携带了 @用户
271 for i := range at { 272 for i := range at {
272 - var msg = &domain.MessageBusiness{  
273 - Type: msgType,  
274 - OptType: optType,  
275 - CompanyId: userToken.CompanyId,  
276 - UserId: userToken.UserId,  
277 - RecipientId: at[i],  
278 - ArticleId: articleId,  
279 - CommentId: commentId,  
280 - CommentParentId: commentParentId,  
281 - }  
282 - msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)  
283 - if err != nil {  
284 - return err 273 + if _, ok := dupMap[at[i]]; ok { /* ID去重 */
  274 + // do nothing ...
  275 + } else {
  276 + var msg = &domain.MessageBusiness{
  277 + Type: msgType,
  278 + OptType: optType,
  279 + CompanyId: userToken.CompanyId,
  280 + UserId: userToken.UserId,
  281 + RecipientId: at[i],
  282 + ArticleId: articleId,
  283 + CommentId: commentId,
  284 + CommentParentId: commentParentId,
  285 + }
  286 + msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)
  287 + if err != nil {
  288 + return err
  289 + }
  290 + dupMap[at[i]] = at[i]
285 } 291 }
  292 +
286 } 293 }
287 return nil 294 return nil
288 } 295 }
@@ -43,7 +43,8 @@ func (l *SystemUserAccountSearchLogic) SystemUserAccountSearch(req *types.System @@ -43,7 +43,8 @@ func (l *SystemUserAccountSearchLogic) SystemUserAccountSearch(req *types.System
43 WithKV("roleId", req.RoleId). 43 WithKV("roleId", req.RoleId).
44 WithKV("enable", req.Enable). 44 WithKV("enable", req.Enable).
45 WithKV("beginTime", req.BeginTime). 45 WithKV("beginTime", req.BeginTime).
46 - WithKV("endTime", req.EndTime) 46 + WithKV("endTime", req.EndTime).
  47 + WithKV("auditStatus", []int{domain.UserAuditStatusPassed})
47 if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil { 48 if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil {
48 return nil, xerr.NewErr(err) 49 return nil, xerr.NewErr(err)
49 } 50 }
@@ -41,7 +41,8 @@ func (l *SystemUserSearchLogic) SystemUserSearch(req *types.SystemUserSearchRequ @@ -41,7 +41,8 @@ func (l *SystemUserSearchLogic) SystemUserSearch(req *types.SystemUserSearchRequ
41 WithKV("likePhone", req.Phone). 41 WithKV("likePhone", req.Phone).
42 WithKV("position", req.Position). 42 WithKV("position", req.Position).
43 WithKV("enable", req.Enable). 43 WithKV("enable", req.Enable).
44 - WithKV("departmentId", req.DepartmentId) 44 + WithKV("departmentId", req.DepartmentId).
  45 + WithKV("auditStatus", []int{domain.UserAuditStatusPassed})
45 if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil { 46 if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil {
46 return nil, xerr.NewErr(err) 47 return nil, xerr.NewErr(err)
47 } 48 }