作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -102,7 +102,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeArticle(req *types.MiniSetUserLi
// 删除点赞文章消息
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
err = messageLogic.UnLikeArticle(c, articleInfo.Id)
err = messageLogic.UnLikeArticle(c, articleInfo.Id, articleInfo.AuthorId)
if err != nil {
return err
}
... ... @@ -183,7 +183,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeComment(req *types.MiniSetUserLi
// 删除点赞评论消息
var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
err = messageLogic.UnLikeComment(c, commentInfo.ArticleId, commentInfo.Id)
err = messageLogic.UnLikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.FromUserId)
if err != nil {
return err
}
... ...
... ... @@ -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 {
... ...
... ... @@ -248,13 +248,13 @@ func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64,
}
// UnLikeArticle 取消点赞文章
func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64) (err error) {
return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0)
func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64, recipientId int64) (err error) {
return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0, recipientId)
}
// UnLikeComment 取消点赞评论
func (l *MiniBusinessLogic) UnLikeComment(conn transaction.Conn, articleId int64, commentId int64) (err error) {
return l.deleteMessage(conn, domain.OptTypeComment, articleId, commentId)
func (l *MiniBusinessLogic) UnLikeComment(conn transaction.Conn, articleId int64, commentId int64, recipientId int64) (err error) {
return l.deleteMessage(conn, domain.OptTypeComment, articleId, commentId, recipientId)
}
func (l *MiniBusinessLogic) createMessage(
... ... @@ -287,14 +287,14 @@ func (l *MiniBusinessLogic) createMessage(
return nil
}
func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId int64) (err error) {
func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId int64, recipientId int64) (err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
queryOption := domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1).
MustWithKV("type", domain.MsgTypeLike).
MustWithKV("optType", optType).
MustWithKV("companyId", userToken.CompanyId).
MustWithKV("recipientId", userToken.UserId).
MustWithKV("recipientId", recipientId).
MustWithKV("articleId", articleId).
MustWithKV("commentId", commentId)
... ...
... ... @@ -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
}
... ...