|
@@ -6,7 +6,6 @@ import (
|
|
|
"hongze/hongze_yb/global"
|
|
|
"hongze/hongze_yb/models/response"
|
|
|
"hongze/hongze_yb/models/tables/wx_user"
|
|
|
- "hongze/hongze_yb/models/tables/yb_comment"
|
|
|
"hongze/hongze_yb/models/tables/yb_comment_anonymous_user"
|
|
|
"hongze/hongze_yb/models/tables/yb_community_question_comment"
|
|
|
"hongze/hongze_yb/services/user"
|
|
@@ -140,16 +139,11 @@ func Delete(user user.UserInfo, communityQuestionCommentID uint64) (err error, e
|
|
|
}
|
|
|
|
|
|
// MyList 我的留言列表
|
|
|
-func MyList(userId uint64, communityQuestionID int, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, total int64, isShowName int8, err error, errMsg string) {
|
|
|
+func MyList(userId uint64, communityQuestionID int, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, total int64, err error, errMsg string) {
|
|
|
list, total, err, errMsg = List(userId, communityQuestionID, false, page, pageSize)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- //查询我的最新一条留言是否勾选匿名的设置
|
|
|
- lastComment, tErr := yb_comment.GetMyLatestComment(userId)
|
|
|
- if tErr == nil {
|
|
|
- isShowName = lastComment.IsShowName
|
|
|
- }
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -304,6 +298,9 @@ func HandleCommentByCommunityQuestionItemList(userId uint64, questionList []*res
|
|
|
}
|
|
|
idArr := make([]uint32, 0)
|
|
|
idMap := make(map[uint32]int)
|
|
|
+
|
|
|
+ userIds := []uint64{userId} //所有的评论人
|
|
|
+
|
|
|
for i := 0; i < listLen; i++ {
|
|
|
idArr = append(idArr, uint32(questionList[i].CommunityQuestionID))
|
|
|
idMap[uint32(questionList[i].CommunityQuestionID)] = 1
|
|
@@ -320,6 +317,9 @@ func HandleCommentByCommunityQuestionItemList(userId uint64, questionList []*res
|
|
|
for _, v := range hotList {
|
|
|
ybCommunityQuestionCommentMap[v.CommunityQuestionID] = v
|
|
|
delete(idMap, v.CommunityQuestionID)
|
|
|
+
|
|
|
+ //评论人id
|
|
|
+ userIds = append(userIds, v.UserID)
|
|
|
}
|
|
|
|
|
|
myIdArr := make([]uint32, 0)
|
|
@@ -346,15 +346,33 @@ func HandleCommentByCommunityQuestionItemList(userId uint64, questionList []*res
|
|
|
numCommentMap[v.CommunityQuestionID] = v.Total
|
|
|
}
|
|
|
|
|
|
+ var userOthers []*wx_user.WxUser
|
|
|
+ if len(userIds) > 0 {
|
|
|
+ userOthers, err = wx_user.GetByUserIds(userIds)
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("查询精选留言用户出错")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ usersMap := make(map[uint64]*wx_user.WxUser)
|
|
|
+ for _, v := range userOthers {
|
|
|
+ usersMap[v.UserID] = v
|
|
|
+ }
|
|
|
+
|
|
|
for _, v := range questionList {
|
|
|
//评论汇总数
|
|
|
if tmpTotal, ok := numCommentMap[uint32(v.CommunityQuestionID)]; ok {
|
|
|
v.CommentTotal = tmpTotal
|
|
|
}
|
|
|
|
|
|
- //最近一条评论
|
|
|
+ //最近一条 精选/我的 评论
|
|
|
if ybCommunityQuestionCommentInfo, ok := ybCommunityQuestionCommentMap[uint32(v.CommunityQuestionID)]; ok {
|
|
|
v.Comment = ybCommunityQuestionCommentInfo.Content
|
|
|
+ v.CommentUserName = "匿名用户" + strconv.Itoa(int(3333+ybCommunityQuestionCommentInfo.UserID))
|
|
|
+ if info, ok := usersMap[ybCommunityQuestionCommentInfo.UserID]; ok && ybCommunityQuestionCommentInfo.IsShowName == 1 {
|
|
|
+ v.CommentUserName = info.NickName
|
|
|
+ //v.UserImgUrl = info.Headimgurl
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return
|