作者 tangxvhui

修复bug 4512

@@ -96,8 +96,10 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini @@ -96,8 +96,10 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
96 if err != nil { 96 if err != nil {
97 return nil, xerr.NewErrMsgErr("检查@的人员失败", err) 97 return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
98 } 98 }
99 - if len(atWhoIds) != len(atWhoList) {  
100 - return nil, xerr.NewErrMsg("检查@的人员失败") 99 + for _, val := range atWhoList {
  100 + if val.CompanyId != req.CompanyId {
  101 + return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
  102 + }
101 } 103 }
102 } 104 }
103 // 处理文本内容 105 // 处理文本内容
@@ -36,6 +36,30 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System @@ -36,6 +36,30 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
36 if commetInfo.CompanyId != req.CompanyId { 36 if commetInfo.CompanyId != req.CompanyId {
37 return nil, xerr.NewErrMsg("没有操作权限") 37 return nil, xerr.NewErrMsg("没有操作权限")
38 } 38 }
  39 + {
  40 + //检查运营点赞的值
  41 + //查找对应的文章
  42 + articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, commetInfo.ArticleId)
  43 + if err != nil {
  44 + return nil, xerr.NewErrMsgErr("没有找到对应的文章", err)
  45 + }
  46 + var maxCount int
  47 + //获取文章可以被多少人查看
  48 + if articleInfo.TargetUser == domain.ArticleTargetLimit {
  49 + maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
  50 + } else {
  51 + //统计全员人数
  52 + queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
  53 + cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
  54 + if err != nil {
  55 + return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
  56 + }
  57 + maxCount = commetInfo.MaxCountAdminLove(int(cnt))
  58 + }
  59 + if maxCount < req.CountAdminLove {
  60 + return nil, xerr.NewErrMsg("运营点数设置错误")
  61 + }
  62 + }
39 commetInfo.CountAdminLove = req.CountAdminLove 63 commetInfo.CountAdminLove = req.CountAdminLove
40 commetInfo.Content = req.Content 64 commetInfo.Content = req.Content
41 var increaseCount int 65 var increaseCount int
@@ -47,6 +47,35 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type @@ -47,6 +47,35 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type
47 if err != nil { 47 if err != nil {
48 return nil, xerr.NewErrMsgErr("编辑评论信息失败", err) 48 return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
49 } 49 }
  50 +
  51 + for _, commetInfo := range commetList {
  52 + //检查运营点赞的值
  53 + //查找对应的文章
  54 + articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, commetInfo.ArticleId)
  55 + if err != nil {
  56 + return nil, xerr.NewErrMsgErr("没有找到对应的文章", err)
  57 + }
  58 + var maxCount int
  59 + //获取文章可以被多少人查看
  60 + if articleInfo.TargetUser == domain.ArticleTargetLimit {
  61 + maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
  62 + } else {
  63 + //统计全员人数
  64 + queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
  65 + cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
  66 + if err != nil {
  67 + return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
  68 + }
  69 + maxCount = commetInfo.MaxCountAdminLove(int(cnt))
  70 + }
  71 +
  72 + if paramCountData, ok := paramMap[commetInfo.Id]; ok {
  73 + if maxCount < paramCountData {
  74 + return nil, xerr.NewErrMsg("运营点数设置错误")
  75 + }
  76 + }
  77 + }
  78 + // 更新运营点赞数
50 resp = &types.SystemEditCommentLoveResponse{} 79 resp = &types.SystemEditCommentLoveResponse{}
51 for _, val := range commetList { 80 for _, val := range commetList {
52 if val.CompanyId != req.CompanyId { 81 if val.CompanyId != req.CompanyId {
@@ -81,3 +81,14 @@ type ArticleCommentRepository interface { @@ -81,3 +81,14 @@ type ArticleCommentRepository interface {
81 CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int, 81 CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
82 topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error) 82 topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error)
83 } 83 }
  84 +
  85 +// 运营点数 填写的最大值
  86 +func (m *ArticleComment) MaxCountAdminLove(articleWhoRead int) int {
  87 + // 帖子的可见人数/3向上取整
  88 + x := articleWhoRead / 3 // 取商
  89 + y := articleWhoRead % 3 // 取余
  90 + if y > 0 {
  91 + x = x + 1
  92 + }
  93 + return x
  94 +}