...
|
...
|
@@ -222,8 +222,18 @@ func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, |
|
|
}
|
|
|
|
|
|
// LikeComment 点赞评论
|
|
|
func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, sectionId int64, commentId int64, at int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, sectionId, commentId, "", []int64{at})
|
|
|
func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, at int64) (err error) {
|
|
|
return l.createMessage(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, 0, commentId, "", []int64{at})
|
|
|
}
|
|
|
|
|
|
// UnLikeArticle 取消点赞文章
|
|
|
func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64) (err error) {
|
|
|
return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0)
|
|
|
}
|
|
|
|
|
|
// 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) createMessage(
|
...
|
...
|
@@ -257,3 +267,27 @@ func (l *MiniBusinessLogic) createMessage( |
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId 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("articleId", articleId).
|
|
|
MustWithKV("commentId", commentId)
|
|
|
|
|
|
_, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, conn, queryOption)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
for i := range list {
|
|
|
_, err = l.svcCtx.MessageBusinessRepository.Delete(l.ctx, conn, list[i])
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
} |
...
|
...
|
|