正在显示
6 个修改的文件
包含
76 行增加
和
10 行删除
@@ -102,7 +102,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeArticle(req *types.MiniSetUserLi | @@ -102,7 +102,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeArticle(req *types.MiniSetUserLi | ||
102 | 102 | ||
103 | // 删除点赞文章消息 | 103 | // 删除点赞文章消息 |
104 | var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) | 104 | var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) |
105 | - err = messageLogic.UnLikeArticle(c, articleInfo.Id) | 105 | + err = messageLogic.UnLikeArticle(c, articleInfo.Id, articleInfo.AuthorId) |
106 | if err != nil { | 106 | if err != nil { |
107 | return err | 107 | return err |
108 | } | 108 | } |
@@ -183,7 +183,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeComment(req *types.MiniSetUserLi | @@ -183,7 +183,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeComment(req *types.MiniSetUserLi | ||
183 | 183 | ||
184 | // 删除点赞评论消息 | 184 | // 删除点赞评论消息 |
185 | var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) | 185 | var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) |
186 | - err = messageLogic.UnLikeComment(c, commentInfo.ArticleId, commentInfo.Id) | 186 | + err = messageLogic.UnLikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.FromUserId) |
187 | if err != nil { | 187 | if err != nil { |
188 | return err | 188 | return err |
189 | } | 189 | } |
@@ -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 { |
@@ -248,13 +248,13 @@ func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, | @@ -248,13 +248,13 @@ func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, | ||
248 | } | 248 | } |
249 | 249 | ||
250 | // UnLikeArticle 取消点赞文章 | 250 | // UnLikeArticle 取消点赞文章 |
251 | -func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64) (err error) { | ||
252 | - return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0) | 251 | +func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64, recipientId int64) (err error) { |
252 | + return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0, recipientId) | ||
253 | } | 253 | } |
254 | 254 | ||
255 | // UnLikeComment 取消点赞评论 | 255 | // UnLikeComment 取消点赞评论 |
256 | -func (l *MiniBusinessLogic) UnLikeComment(conn transaction.Conn, articleId int64, commentId int64) (err error) { | ||
257 | - return l.deleteMessage(conn, domain.OptTypeComment, articleId, commentId) | 256 | +func (l *MiniBusinessLogic) UnLikeComment(conn transaction.Conn, articleId int64, commentId int64, recipientId int64) (err error) { |
257 | + return l.deleteMessage(conn, domain.OptTypeComment, articleId, commentId, recipientId) | ||
258 | } | 258 | } |
259 | 259 | ||
260 | func (l *MiniBusinessLogic) createMessage( | 260 | func (l *MiniBusinessLogic) createMessage( |
@@ -287,14 +287,14 @@ func (l *MiniBusinessLogic) createMessage( | @@ -287,14 +287,14 @@ func (l *MiniBusinessLogic) createMessage( | ||
287 | return nil | 287 | return nil |
288 | } | 288 | } |
289 | 289 | ||
290 | -func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId int64) (err error) { | 290 | +func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId int64, recipientId int64) (err error) { |
291 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) | 291 | var userToken = contextdata.GetUserTokenFromCtx(l.ctx) |
292 | 292 | ||
293 | queryOption := domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1). | 293 | queryOption := domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1). |
294 | MustWithKV("type", domain.MsgTypeLike). | 294 | MustWithKV("type", domain.MsgTypeLike). |
295 | MustWithKV("optType", optType). | 295 | MustWithKV("optType", optType). |
296 | MustWithKV("companyId", userToken.CompanyId). | 296 | MustWithKV("companyId", userToken.CompanyId). |
297 | - MustWithKV("recipientId", userToken.UserId). | 297 | + MustWithKV("recipientId", recipientId). |
298 | MustWithKV("articleId", articleId). | 298 | MustWithKV("articleId", articleId). |
299 | MustWithKV("commentId", commentId) | 299 | MustWithKV("commentId", commentId) |
300 | 300 |
@@ -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 | +} |
-
请 注册 或 登录 后发表评论