|
@@ -12,6 +12,7 @@ import (
|
|
|
"hongze/hongze_yb/models/tables/yb_comment_anonymous_user"
|
|
|
"hongze/hongze_yb/models/tables/yb_community_question"
|
|
|
"hongze/hongze_yb/models/tables/yb_community_question_comment"
|
|
|
+ "hongze/hongze_yb/models/tables/yb_community_video"
|
|
|
"hongze/hongze_yb/services/alarm_msg"
|
|
|
"hongze/hongze_yb/services/company_approval_message"
|
|
|
"hongze/hongze_yb/services/user"
|
|
@@ -23,7 +24,7 @@ import (
|
|
|
)
|
|
|
|
|
|
// Comment 发布留言
|
|
|
-func Comment(user user.UserInfo, communityQuestionID uint32, content string, sourceAgent, isShowName int8, qaAvatarUrl string) (ybCommunityQuestionComment *yb_community_question_comment.YbCommunityQuestionComment, err error, errMsg string) {
|
|
|
+func Comment(user user.UserInfo, communityQuestionID uint32, content string, sourceAgent, isShowName, source int8, qaAvatarUrl string) (ybCommunityQuestionComment *yb_community_question_comment.YbCommunityQuestionComment, err error, errMsg string) {
|
|
|
errMsg = "发布留言失败"
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -51,6 +52,12 @@ func Comment(user user.UserInfo, communityQuestionID uint32, content string, sou
|
|
|
err = errors.New(errMsg)
|
|
|
return
|
|
|
}
|
|
|
+ if source <= 0 {
|
|
|
+ errMsg = "来源有误"
|
|
|
+ err = errors.New(errMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
// 敏感词过滤
|
|
|
if user.RecordInfo.OpenID != "" && user.RecordInfo.CreatePlatform == 6 { //只有小程序的用户才能走敏感词过滤接口
|
|
|
checkResult, tErr := wx_app.MsgSecCheck(user.RecordInfo.OpenID, content)
|
|
@@ -95,6 +102,7 @@ func Comment(user user.UserInfo, communityQuestionID uint32, content string, sou
|
|
|
ModifyTime: now,
|
|
|
CreateTime: now,
|
|
|
QaAvatarUrl: qaAvatarUrl,
|
|
|
+ Source: source,
|
|
|
}
|
|
|
err = ybCommunityQuestionComment.Create()
|
|
|
if err != nil {
|
|
@@ -155,8 +163,8 @@ func Delete(user user.UserInfo, communityQuestionCommentID uint64) (err error, e
|
|
|
}
|
|
|
|
|
|
// MyList 我的留言列表
|
|
|
-func MyList(userId uint64, communityQuestionID int, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, hotTotal, myTotal int64, err error, errMsg string) {
|
|
|
- list, hotTotal, myTotal, err, errMsg = List(userId, communityQuestionID, false, page, pageSize)
|
|
|
+func MyList(userId uint64, communityQuestionID, source int, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, hotTotal, myTotal int64, err error, errMsg string) {
|
|
|
+ list, hotTotal, myTotal, err, errMsg = List(userId, communityQuestionID, source, false, page, pageSize)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -164,7 +172,7 @@ func MyList(userId uint64, communityQuestionID int, page, pageSize int) (list []
|
|
|
}
|
|
|
|
|
|
// List 查询精选留言列表或我的留言列表
|
|
|
-func List(userId uint64, communityQuestionID int, hotFlag bool, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, hotTotal, myTotal int64, err error, errMsg string) {
|
|
|
+func List(userId uint64, communityQuestionID, source int, hotFlag bool, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, hotTotal, myTotal int64, err error, errMsg string) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
global.LOG.Critical(fmt.Sprintf("comment List: userId=%d, err:%s, errMsg:%s", userId, err.Error(), errMsg))
|
|
@@ -178,14 +186,14 @@ func List(userId uint64, communityQuestionID int, hotFlag bool, page, pageSize i
|
|
|
}
|
|
|
|
|
|
//精选留言数
|
|
|
- hotTotal, err = yb_community_question_comment.GetHotListTotalByCommunityQuestionID(communityQuestionID)
|
|
|
+ hotTotal, err = yb_community_question_comment.GetHotListTotalByCommunityQuestionID(communityQuestionID, source)
|
|
|
if err != nil {
|
|
|
errMsg = `查询精选留言总数出错`
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 我的留言数
|
|
|
- myTotal, err = yb_community_question_comment.GetListTotalByUserIdCommunityQuestionID(userId, communityQuestionID)
|
|
|
+ myTotal, err = yb_community_question_comment.GetListTotalByUserIdCommunityQuestionID(userId, communityQuestionID, source)
|
|
|
if err != nil {
|
|
|
errMsg = `查询我的留言总数出错`
|
|
|
return
|
|
@@ -194,7 +202,7 @@ func List(userId uint64, communityQuestionID int, hotFlag bool, page, pageSize i
|
|
|
var commentList []*yb_community_question_comment.YbCommunityQuestionComment
|
|
|
//查询精选留言
|
|
|
if hotFlag {
|
|
|
- commentList, err = yb_community_question_comment.GetHotListByCommunityQuestionID(communityQuestionID, (page-1)*pageSize, pageSize)
|
|
|
+ commentList, err = yb_community_question_comment.GetHotListByCommunityQuestionID(communityQuestionID, (page-1)*pageSize, pageSize, source)
|
|
|
if err != nil {
|
|
|
errMsg = `查询精选留言列表出错`
|
|
|
return
|
|
@@ -202,7 +210,7 @@ func List(userId uint64, communityQuestionID int, hotFlag bool, page, pageSize i
|
|
|
|
|
|
} else {
|
|
|
//查询个人留言
|
|
|
- commentList, err = yb_community_question_comment.GetListByUserIdCommunityQuestionID(userId, communityQuestionID)
|
|
|
+ commentList, err = yb_community_question_comment.GetListByUserIdCommunityQuestionID(userId, communityQuestionID, source)
|
|
|
if err != nil {
|
|
|
errMsg = `查询我的留言列表出错`
|
|
|
return
|
|
@@ -329,14 +337,14 @@ func HandleCommentByCommunityQuestionItemList(userId uint64, questionList []*res
|
|
|
}
|
|
|
|
|
|
// 精选评论数据
|
|
|
- hotList, err := yb_community_question_comment.GetHotListByCommunityQuestionIds(idArr)
|
|
|
+ hotList, err := yb_community_question_comment.GetHotListByCommunityQuestionIds(idArr, yb_community_question_comment.SourceQuestion)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
for _, v := range hotList {
|
|
|
questionIdCommentsMap[v.CommunityQuestionID] = append(questionIdCommentsMap[v.CommunityQuestionID], &response.CommunityQuestionCommentListItem{
|
|
|
QaAvatarUrl: v.QaAvatarUrl,
|
|
|
- Comment: v.Content,
|
|
|
+ Comment: v.Content,
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -384,7 +392,12 @@ func systemMessageToAdmin(adminInfo admin.Admin, wxUser user.UserInfo, community
|
|
|
|
|
|
var msgType, sourceType, approvalStatus int8
|
|
|
msgType = company_approval_message.CompanyApprovalMessageMessageTypeByApply
|
|
|
- sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByQuestionComment
|
|
|
+ // 消息来源: 6-问答社区; 7-视频社区
|
|
|
+ if communityQuestionComment.Source == 1 {
|
|
|
+ sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByQuestionComment
|
|
|
+ } else {
|
|
|
+ sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByVideoComment
|
|
|
+ }
|
|
|
approvalStatus = company_approval_message.CompanyApprovalMessageApprovalStatusByPending
|
|
|
|
|
|
companyInfo, err := company.GetByCompanyId(wxUser.CompanyID)
|
|
@@ -401,21 +414,40 @@ func systemMessageToAdmin(adminInfo admin.Admin, wxUser user.UserInfo, community
|
|
|
companyName := companyInfo.CompanyName
|
|
|
remark := `您有新的问答评论待查阅`
|
|
|
content := `您有新的问答评论待查阅`
|
|
|
-
|
|
|
- // 获取评论对应的问答信息
|
|
|
- communityQuestion, err := yb_community_question.GetItemById(int(communityQuestionComment.CommunityQuestionID))
|
|
|
- if err != nil {
|
|
|
- err = errors.New("获取评论对应的问答失败,err:" + err.Error())
|
|
|
+ if communityQuestionComment.Source == 2 {
|
|
|
+ remark = `您有新的视频评论待查阅`
|
|
|
+ content = `您有新的视频评论待查阅`
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取评论对应的问答/视频信息
|
|
|
+ msgContent := ``
|
|
|
+ extra := ``
|
|
|
+ if communityQuestionComment.Source == 1 {
|
|
|
+ communityQuestion, e := yb_community_question.GetItemById(int(communityQuestionComment.CommunityQuestionID))
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取评论对应的问答失败,err:" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ msgContent = communityQuestion.QuestionContent
|
|
|
+ } else {
|
|
|
+ communityVideo, e := yb_community_video.GetItemById(int(communityQuestionComment.CommunityQuestionID))
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取评论对应的视频失败,err:" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ msgContent = communityVideo.Title
|
|
|
+ extra = communityVideo.VarietyTagName
|
|
|
}
|
|
|
messageInfo := company_approval_message.MessageInfo{
|
|
|
CompanyName: companyInfo.CompanyName,
|
|
|
ProductId: productId,
|
|
|
CompanyProductStatus: companyProductInfo.Status,
|
|
|
Title: communityQuestionComment.Content,
|
|
|
- Content: communityQuestion.QuestionContent,
|
|
|
+ Content: msgContent,
|
|
|
UserId: wxUser.UserID,
|
|
|
UserName: communityQuestionComment.RealName,
|
|
|
CreateTime: communityQuestionComment.CreateTime,
|
|
|
+ Extra: extra, // 附加字段
|
|
|
}
|
|
|
//客户添加消息
|
|
|
err = company_approval_message.AddCompanyApprovalMessage(utils.AdminId, receiveUserId, int(wxUser.CompanyID), int(communityQuestionComment.CommunityQuestionCommentID), msgType, sourceType, approvalStatus, companyName, remark, content, messageInfo)
|
|
@@ -451,6 +483,10 @@ func afterDelete(communityQuestionComment *yb_community_question_comment.YbCommu
|
|
|
go alarm_msg.SendAlarmMsg("问答评论信息删除后,标记站内消息失败"+time.Now().Format("2006-01-02 15:04:05")+";Err:"+err.Error(), 3)
|
|
|
}
|
|
|
}()
|
|
|
- err = company_approval_message.CancelCompanyApprovalMessage(int(communityQuestionComment.CommunityQuestionCommentID), company_approval_message.CompanyApprovalMessageSourceTypeByQuestionComment)
|
|
|
+ sourceType := company_approval_message.CompanyApprovalMessageSourceTypeByQuestionComment
|
|
|
+ if communityQuestionComment.Source == 2 {
|
|
|
+ sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByVideoComment
|
|
|
+ }
|
|
|
+ err = company_approval_message.CancelCompanyApprovalMessage(int(communityQuestionComment.CommunityQuestionCommentID), int8(sourceType))
|
|
|
return
|
|
|
}
|