|
@@ -5,14 +5,13 @@ import (
|
|
|
"fmt"
|
|
|
"hongze/hongze_yb/models/request"
|
|
|
"hongze/hongze_yb/models/response"
|
|
|
+ "hongze/hongze_yb/models/tables/user_record"
|
|
|
"hongze/hongze_yb/models/tables/yb_community_question"
|
|
|
"hongze/hongze_yb/models/tables/yb_community_question_audio"
|
|
|
"hongze/hongze_yb/services/company"
|
|
|
"hongze/hongze_yb/services/user"
|
|
|
"hongze/hongze_yb/services/wechat"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -21,7 +20,7 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
|
|
|
condition := make(map[string]interface{})
|
|
|
condition["is_deleted ="] = 0
|
|
|
// 用户身份
|
|
|
- isAdmin, adminInfo, e := user.GetAdminByUserInfo(userInfo)
|
|
|
+ isAdmin, _, e := user.GetAdminByUserInfo(userInfo)
|
|
|
if e != nil {
|
|
|
err = errors.New("获取用户身份失败 Err:" + e.Error())
|
|
|
return
|
|
@@ -36,7 +35,7 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
|
|
|
// 问题列表
|
|
|
if onlyMine == 1 {
|
|
|
if isAdmin {
|
|
|
- condition["replier_user_id ="] = adminInfo.AdminID
|
|
|
+ condition["replier_user_id ="] = userInfo.UserID
|
|
|
} else {
|
|
|
condition["user_id ="] = userInfo.UserID
|
|
|
}
|
|
@@ -54,17 +53,16 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
|
|
|
err = errors.New("获取问题列表失败 Err:" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- idArr := make([]string, 0)
|
|
|
listLen := len(questionList)
|
|
|
if listLen == 0 {
|
|
|
return
|
|
|
}
|
|
|
+ idArr := make([]int, 0)
|
|
|
for i := 0; i < listLen; i++ {
|
|
|
- idArr = append(idArr, strconv.Itoa(questionList[i].CommunityQuestionID))
|
|
|
+ idArr = append(idArr, questionList[i].CommunityQuestionID)
|
|
|
}
|
|
|
- idStr := strings.Join(idArr, ",")
|
|
|
// 音频列表
|
|
|
- audioList, e := yb_community_question_audio.GetListByQuestrionIds(idStr)
|
|
|
+ audioList, e := yb_community_question_audio.GetListByQuestrionIds(idArr)
|
|
|
if e != nil {
|
|
|
err = errors.New("获取音频列表失败 Err:" + e.Error())
|
|
|
return
|
|
@@ -168,7 +166,17 @@ func GetQuestionDetail(questionId int, userInfo user.UserInfo) (item *response.C
|
|
|
}
|
|
|
|
|
|
// CreateQuestion 新增问答
|
|
|
-func CreateQuestion(userId int, mobile, openid, realName, content string) (err error) {
|
|
|
+func CreateQuestion(userId int, mobile, realName, content string) (err error) {
|
|
|
+ // 获取用户公众号openid, 获取不到则置空
|
|
|
+ userRecord, e := user_record.GetByUserId(userId, utils.USER_RECORD_PLATFORM_RDDP)
|
|
|
+ if e != nil && e == utils.ErrNoRow {
|
|
|
+ err = errors.New("获取用户公众号openid失败 Err:" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ openid := ""
|
|
|
+ if userRecord != nil {
|
|
|
+ openid = userRecord.OpenID
|
|
|
+ }
|
|
|
item := &yb_community_question.YbCommunityQuestion{
|
|
|
UserID: userId,
|
|
|
UserOpenid: openid,
|