|
@@ -19,8 +19,8 @@ import (
|
|
|
|
|
|
// GetQuestionList 获取问答列表
|
|
|
func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStatus, groupId int, userInfo user.UserInfo) (resp []*response.CommunityQuestionItem, err error) {
|
|
|
- condition := make(map[string]interface{})
|
|
|
- condition["is_deleted ="] = 0
|
|
|
+ condition := " is_deleted = 0"
|
|
|
+ var pars []interface{}
|
|
|
// 用户身份
|
|
|
isResearcher, _, e := user.GetResearcherByUserInfo(userInfo)
|
|
|
if e != nil {
|
|
@@ -28,34 +28,41 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
|
|
|
return
|
|
|
}
|
|
|
if onlyMine == 1 {
|
|
|
- if isResearcher {
|
|
|
- condition["replier_user_id ="] = userInfo.UserID
|
|
|
- } else {
|
|
|
- condition["user_id ="] = userInfo.UserID
|
|
|
- }
|
|
|
- }
|
|
|
- if replyStatus > 0 {
|
|
|
- if replyStatus == 2 && !isResearcher {
|
|
|
- // 普通用户待回答为待分配和待回答
|
|
|
- condition["reply_status >"] = 0
|
|
|
- condition["reply_status <"] = 3
|
|
|
+ if isResearcher { //如果是研究员
|
|
|
+ if replyStatus == 4 { //分配给研究员未回答的问题
|
|
|
+ condition += " and replier_user_id=? and reply_status = 2"
|
|
|
+ pars = append(pars, userInfo.UserID)
|
|
|
+ } else if replyStatus == 2 { //研究员提问的问题未分配或者未回答的问题
|
|
|
+ condition += " and user_id=? and reply_status >0 and reply_status <3"
|
|
|
+ pars = append(pars, userInfo.UserID)
|
|
|
+ } else if replyStatus == 3 { //分配给研究员的已回答和研究员提问的被回答的问题
|
|
|
+ condition += " and (replier_user_id=? or user_id=?) and reply_status =3"
|
|
|
+ pars = append(pars, userInfo.UserID, userInfo.UserID)
|
|
|
+ }else if replyStatus == 0 { //分配给研究员或者研究员提问的所以问题
|
|
|
+ condition += " and (replier_user_id=? or user_id=?)"
|
|
|
+ pars = append(pars, userInfo.UserID, userInfo.UserID)
|
|
|
+ }
|
|
|
} else {
|
|
|
- condition["reply_status ="] = replyStatus
|
|
|
- }
|
|
|
- } else {
|
|
|
- if isResearcher {
|
|
|
- // 不展示未分配的
|
|
|
- condition["reply_status >"] = 1
|
|
|
+ condition += " and user_id=?"
|
|
|
+ pars = append(pars, userInfo.UserID)
|
|
|
+ if replyStatus == 2 { // 普通用户未回答为待分配和未回答
|
|
|
+ condition += " and reply_status >0 and reply_status <3"
|
|
|
+ } else if replyStatus == 3{
|
|
|
+ condition += " and reply_status = 3"
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if chartPermissionId > 0 {
|
|
|
- condition["chart_permission_id ="] = chartPermissionId
|
|
|
+ condition += " and chart_permission_id =?"
|
|
|
+ pars = append(pars, chartPermissionId)
|
|
|
}
|
|
|
if groupId > 0 {
|
|
|
- condition["research_group_second_id ="] = groupId
|
|
|
+ condition += " and research_group_second_id =?"
|
|
|
+ pars = append(pars, groupId)
|
|
|
}
|
|
|
// 问题列表
|
|
|
- questionList, e := yb_community_question.GetPageListByCondition(condition, pageIndex, pageSize)
|
|
|
+ questionList, e := yb_community_question.GetPageListByCondition(condition, pars, pageIndex, pageSize)
|
|
|
if e != nil {
|
|
|
err = errors.New("获取问题列表失败 Err:" + e.Error())
|
|
|
return
|
|
@@ -121,7 +128,7 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
|
|
|
//PermissionInfo: permissionInfo,
|
|
|
AudioList: audios,
|
|
|
}
|
|
|
- if !isResearcher && item.IsRead == 0 && item.UserId == userId {
|
|
|
+ if item.IsRead == 0 && item.UserId == userId {
|
|
|
item.IsTop = 1
|
|
|
}
|
|
|
resp = append(resp, item)
|
|
@@ -308,38 +315,52 @@ func GetQuestionListTotal(userInfo user.UserInfo) (resp *response.CommunityQuest
|
|
|
err = errors.New("获取用户身份失败 Err:" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- condition := make(map[string]interface{}, 0)
|
|
|
- condition["is_deleted ="] = 0
|
|
|
+ condition := " is_deleted = 0"
|
|
|
+ var pars []interface{}
|
|
|
if isResearcher {
|
|
|
- condition["replier_user_id ="] = userInfo.UserID
|
|
|
+ condition += " and (replier_user_id=? or user_id=?)"
|
|
|
+ pars = append(pars, userInfo.UserID, userInfo.UserID)
|
|
|
} else {
|
|
|
- condition["user_id ="] = userInfo.UserID
|
|
|
+ condition += " and user_id=?"
|
|
|
+ pars = append(pars, userInfo.UserID)
|
|
|
}
|
|
|
- countList, e := yb_community_question.GetQuestionListCount(condition)
|
|
|
+ countList, e := yb_community_question.GetQuestionListCount(condition, pars)
|
|
|
if e != nil {
|
|
|
err = errors.New("获取回复人问题统计失败 Err:" + e.Error())
|
|
|
return
|
|
|
}
|
|
|
resp = new(response.CommunityQuestionListTotal)
|
|
|
- var distribute, wait, replied int
|
|
|
+ var distribute, wait, replied, total int
|
|
|
for _, v := range countList {
|
|
|
- if v.ReplyStatus == 1 {
|
|
|
- distribute = v.Total
|
|
|
- }
|
|
|
- if v.ReplyStatus == 2 {
|
|
|
- wait = v.Total
|
|
|
- }
|
|
|
- if v.ReplyStatus == 3 {
|
|
|
- replied = v.Total
|
|
|
+ total += v.Total
|
|
|
+ if isResearcher {
|
|
|
+ if v.UserId == userInfo.UserID {
|
|
|
+ if v.ReplyStatus == 1 || v.ReplyStatus == 2 { //研究员提问的待分配的问题
|
|
|
+ wait += v.Total
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if v.ReplierUserId == userInfo.UserID && v.ReplyStatus == 2{ //分配给研究员的未回答的问题
|
|
|
+ distribute += v.Total
|
|
|
+ }
|
|
|
+ if v.ReplyStatus == 3 {
|
|
|
+ replied += v.Total
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if v.ReplyStatus == 1 || v.ReplyStatus == 2 { //未分配和未回答的数量
|
|
|
+ wait += v.Total
|
|
|
+ }else if v.ReplyStatus == 3 { //已回答的数量
|
|
|
+ replied += v.Total
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
if isResearcher {
|
|
|
- resp.Wait = wait
|
|
|
- } else {
|
|
|
- resp.Wait = distribute + wait
|
|
|
+ resp.Distribute = distribute
|
|
|
}
|
|
|
+ resp.Wait = wait
|
|
|
resp.Replied = replied
|
|
|
- resp.Total = resp.Wait + resp.Replied
|
|
|
+ resp.Total = total
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|