作者 tangxvhui

修复bug 4512

... ... @@ -96,8 +96,10 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
if err != nil {
return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
}
if len(atWhoIds) != len(atWhoList) {
return nil, xerr.NewErrMsg("检查@的人员失败")
for _, val := range atWhoList {
if val.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
}
}
}
// 处理文本内容
... ...
... ... @@ -36,6 +36,30 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
if commetInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("没有操作权限")
}
{
//检查运营点赞的值
//查找对应的文章
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, commetInfo.ArticleId)
if err != nil {
return nil, xerr.NewErrMsgErr("没有找到对应的文章", err)
}
var maxCount int
//获取文章可以被多少人查看
if articleInfo.TargetUser == domain.ArticleTargetLimit {
maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
} else {
//统计全员人数
queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
}
maxCount = commetInfo.MaxCountAdminLove(int(cnt))
}
if maxCount < req.CountAdminLove {
return nil, xerr.NewErrMsg("运营点数设置错误")
}
}
commetInfo.CountAdminLove = req.CountAdminLove
commetInfo.Content = req.Content
var increaseCount int
... ...
... ... @@ -47,6 +47,35 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type
if err != nil {
return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
}
for _, commetInfo := range commetList {
//检查运营点赞的值
//查找对应的文章
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, commetInfo.ArticleId)
if err != nil {
return nil, xerr.NewErrMsgErr("没有找到对应的文章", err)
}
var maxCount int
//获取文章可以被多少人查看
if articleInfo.TargetUser == domain.ArticleTargetLimit {
maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
} else {
//统计全员人数
queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
}
maxCount = commetInfo.MaxCountAdminLove(int(cnt))
}
if paramCountData, ok := paramMap[commetInfo.Id]; ok {
if maxCount < paramCountData {
return nil, xerr.NewErrMsg("运营点数设置错误")
}
}
}
// 更新运营点赞数
resp = &types.SystemEditCommentLoveResponse{}
for _, val := range commetList {
if val.CompanyId != req.CompanyId {
... ...
... ... @@ -81,3 +81,14 @@ type ArticleCommentRepository interface {
CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error)
}
// 运营点数 填写的最大值
func (m *ArticleComment) MaxCountAdminLove(articleWhoRead int) int {
// 帖子的可见人数/3向上取整
x := articleWhoRead / 3 // 取商
y := articleWhoRead % 3 // 取余
if y > 0 {
x = x + 1
}
return x
}
... ...