|
@@ -6,6 +6,8 @@ import (
|
|
|
"hongze/hongze_yb/logic/yb_community_question"
|
|
|
"hongze/hongze_yb/models/request"
|
|
|
responseModel "hongze/hongze_yb/models/response"
|
|
|
+ "hongze/hongze_yb/models/tables/wx_user"
|
|
|
+ "hongze/hongze_yb/models/tables/yb_community_question_comment"
|
|
|
"hongze/hongze_yb/services"
|
|
|
userService "hongze/hongze_yb/services/user"
|
|
|
"strconv"
|
|
@@ -20,11 +22,28 @@ func Comment(c *gin.Context) {
|
|
|
}
|
|
|
userInfo := userService.GetInfoByClaims(c)
|
|
|
|
|
|
+ var qaAvatarUrl string
|
|
|
+ if userInfo.QaAvatarUrl == "" {
|
|
|
+ avatar, err := yb_community_question_comment.GetUserAvatarRandom()
|
|
|
+ if err != nil {
|
|
|
+ response.FailMsg("发布失败", err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ qaAvatarUrl = avatar.AvatarUrl
|
|
|
+ err = wx_user.ModifyQaAvatarUrl(qaAvatarUrl, userInfo.UserID)
|
|
|
+ if err != nil {
|
|
|
+ response.FailMsg("发布失败", err.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ qaAvatarUrl = userInfo.QaAvatarUrl
|
|
|
+ }
|
|
|
+
|
|
|
req.IsShowName = 0
|
|
|
if userInfo.NickName != `` { //非空串时为实名
|
|
|
req.IsShowName = 1
|
|
|
}
|
|
|
- ybCommunityQuestionComment, err, errMsg := yb_community_question.Comment(userInfo, req.CommunityQuestionID, req.Content, req.SourceAgent, req.IsShowName)
|
|
|
+ ybCommunityQuestionComment, err, errMsg := yb_community_question.Comment(userInfo, req.CommunityQuestionID, req.Content, req.SourceAgent, req.IsShowName,qaAvatarUrl)
|
|
|
if err != nil {
|
|
|
response.FailMsg(errMsg, err.Error(), c)
|
|
|
return
|