作者 yangfu
... ... @@ -42,7 +42,10 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr
var userList []*domain.User
if articleInfo.TargetUser == domain.ArticleTargetAll {
//获取所有人
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId)
queryOption := domain.NewQueryOptions().WithFindOnly().
MustWithKV("companyId", articleInfo.CompanyId).
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed})
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
resp = &types.MiniArticleCommentAtWhoResponse{}
... ...
... ... @@ -91,7 +91,9 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
atWhoIds = append(atWhoIds, val.Id)
}
atWhoIds = lo.Uniq(atWhoIds)
queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", atWhoIds)
queryOption := domain.NewQueryOptions().WithFindOnly().
WithKV("ids", atWhoIds).
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed})
_, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
... ...
... ... @@ -49,7 +49,9 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
} else {
//统计全员人数
queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
queryOption := domain.NewQueryOptions().WithCountOnly().
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
MustWithKV("companyId", req.CompanyId)
cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
... ...
... ... @@ -61,7 +61,9 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type
maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
} else {
//统计全员人数
queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
queryOption := domain.NewQueryOptions().WithCountOnly().
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
MustWithKV("companyId", req.CompanyId)
cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
... ...
... ... @@ -2,6 +2,7 @@ package department
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
... ... @@ -58,7 +59,9 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re
// 获取公司下的所有用户
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithFindOnly().
WithKV("companyId", one.CompanyId))
WithKV("companyId", one.CompanyId).MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}),
)
if err != nil {
return nil, err
}
... ...
... ... @@ -267,22 +267,29 @@ func (l *MiniBusinessLogic) createMessage(
at []int64) (err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
// 评论中携带了 @其他用户
var dupMap = make(map[int64]int64, 0)
// 评论中携带了 @用户
for i := range at {
var msg = &domain.MessageBusiness{
Type: msgType,
OptType: optType,
CompanyId: userToken.CompanyId,
UserId: userToken.UserId,
RecipientId: at[i],
ArticleId: articleId,
CommentId: commentId,
CommentParentId: commentParentId,
}
msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)
if err != nil {
return err
if _, ok := dupMap[at[i]]; ok { /* ID去重 */
// do nothing ...
} else {
var msg = &domain.MessageBusiness{
Type: msgType,
OptType: optType,
CompanyId: userToken.CompanyId,
UserId: userToken.UserId,
RecipientId: at[i],
ArticleId: articleId,
CommentId: commentId,
CommentParentId: commentParentId,
}
msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)
if err != nil {
return err
}
dupMap[at[i]] = at[i]
}
}
return nil
}
... ...