...
|
...
|
@@ -25,6 +25,7 @@ func NewMiniGetArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceConte |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 获取单条评论详情
|
|
|
func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArticleCommentRequest) (resp *types.MiniGetArticleCommentResponse, err error) {
|
|
|
var conn = l.svcCtx.DefaultDBConn()
|
|
|
//获取主评论
|
...
|
...
|
@@ -42,7 +43,18 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt |
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
|
|
|
}
|
|
|
//TODO 获取我点赞的评论
|
|
|
queryOption = domain.NewQueryOptions().WithFindOnly().
|
|
|
MustWithKV("articleId", commentInfo.ArticleId).
|
|
|
MustWithKV("userId", req.UserId)
|
|
|
//TODO 获取我点赞的评论
|
|
|
_, userFlagList, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption)
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
|
|
|
}
|
|
|
flagMap := map[int64]struct{}{}
|
|
|
for _, val := range userFlagList {
|
|
|
flagMap[val.CommentId] = struct{}{}
|
|
|
}
|
|
|
|
|
|
//混合数据
|
|
|
commentResp := types.ArticleCommentItem{
|
...
|
...
|
@@ -73,6 +85,10 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt |
|
|
CountAdminLove: commentInfo.CountAdminLove,
|
|
|
AtWho: []types.CommentAuthor{},
|
|
|
CreatedAt: commentInfo.CreatedAt,
|
|
|
MeLoveFlag: 0,
|
|
|
}
|
|
|
if _, ok := flagMap[commentInfo.Id]; ok {
|
|
|
commentResp.MeLoveFlag = 1
|
|
|
}
|
|
|
for _, val := range commentInfo.AtWho {
|
|
|
commentResp.AtWho = append(commentResp.AtWho, types.CommentAuthor{
|
...
|
...
|
@@ -115,6 +131,9 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt |
|
|
CreatedAt: val.CreatedAt,
|
|
|
MeLoveFlag: 0,
|
|
|
}
|
|
|
if _, ok := flagMap[val.Id]; ok {
|
|
|
reply.MeLoveFlag = 1
|
|
|
}
|
|
|
for _, val2 := range val.AtWho {
|
|
|
reply.AtWho = append(reply.AtWho, types.CommentAuthor{
|
|
|
Id: val2.Id,
|
...
|
...
|
|