|
@@ -7,7 +7,6 @@ import (
|
|
ybRequest "hongze/hongze_mobile_admin/models/request/yb"
|
|
ybRequest "hongze/hongze_mobile_admin/models/request/yb"
|
|
"hongze/hongze_mobile_admin/services/yb"
|
|
"hongze/hongze_mobile_admin/services/yb"
|
|
"hongze/hongze_mobile_admin/utils"
|
|
"hongze/hongze_mobile_admin/utils"
|
|
- "strings"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
type CommunityQuestionController struct {
|
|
type CommunityQuestionController struct {
|
|
@@ -17,10 +16,10 @@ type CommunityQuestionController struct {
|
|
// QuestionList
|
|
// QuestionList
|
|
// @Title 获取问答列表
|
|
// @Title 获取问答列表
|
|
// @Description 获取问答列表
|
|
// @Description 获取问答列表
|
|
|
|
+// @Param CommunityQuestionId query int false "问答的id,如果传入了问答的id,那么其他条件就默认过滤掉了"
|
|
// @Param ReplyStatus query int false "提问状态 1-待分配 2-待回答 3-已回答"
|
|
// @Param ReplyStatus query int false "提问状态 1-待分配 2-待回答 3-已回答"
|
|
// @Param ReplierIds query string false "回复人ID,多个用英文逗号分割"
|
|
// @Param ReplierIds query string false "回复人ID,多个用英文逗号分割"
|
|
-// @Param SortParam query string false "排序字段参数,用来排序的字段, 枚举值:'ClickNum':点击量"
|
|
|
|
-// @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
|
|
|
|
|
|
+// @Param Keyword query string false "关键字搜索"
|
|
// @Success 200 {object} response.CommunityQuestionListResp
|
|
// @Success 200 {object} response.CommunityQuestionListResp
|
|
// @router /community/question/list [get]
|
|
// @router /community/question/list [get]
|
|
func (c *CommunityQuestionController) QuestionList() {
|
|
func (c *CommunityQuestionController) QuestionList() {
|
|
@@ -35,32 +34,30 @@ func (c *CommunityQuestionController) QuestionList() {
|
|
|
|
|
|
condition := ""
|
|
condition := ""
|
|
pars := make([]interface{}, 0)
|
|
pars := make([]interface{}, 0)
|
|
- replyStatus, _ := c.GetInt("ReplyStatus", 0)
|
|
|
|
- if replyStatus > 0 {
|
|
|
|
- condition += ` AND q.reply_status = ?`
|
|
|
|
- pars = append(pars, replyStatus)
|
|
|
|
- }
|
|
|
|
- replierIds := c.GetString("ReplierIds", "")
|
|
|
|
- if replierIds != "" {
|
|
|
|
- condition += ` AND q.replier_admin_id IN (` + replierIds + `)`
|
|
|
|
- }
|
|
|
|
- // 排序相关
|
|
|
|
- sortParam := c.GetString("SortParam")
|
|
|
|
- sortType := c.GetString("SortType")
|
|
|
|
- orderStr := ""
|
|
|
|
- if sortType != "" && strings.ToLower(sortType) != "desc" && strings.ToLower(sortType) != "asc" {
|
|
|
|
- c.FailWithMessage("请输入正确的排序类型", "请输入正确的排序类型")
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- if sortParam == "ClickNum" {
|
|
|
|
- orderStr = " ORDER BY l.click_num"
|
|
|
|
- if sortType != "" {
|
|
|
|
- orderStr += " " + sortType
|
|
|
|
- } else {
|
|
|
|
- orderStr += " DESC"
|
|
|
|
|
|
+ //问答id
|
|
|
|
+ communityQuestionId, _ := c.GetInt("CommunityQuestionId", 0)
|
|
|
|
+
|
|
|
|
+ //如果有传入特定的问答id,那么就不用考虑其他状态了
|
|
|
|
+ if communityQuestionId > 0 {
|
|
|
|
+ condition += ` AND q.community_question_id = ? `
|
|
|
|
+ pars = append(pars, communityQuestionId)
|
|
|
|
+ } else {
|
|
|
|
+ //提问状态
|
|
|
|
+ replyStatus, _ := c.GetInt("ReplyStatus", 0)
|
|
|
|
+ if replyStatus > 0 {
|
|
|
|
+ condition += ` AND q.reply_status = ? `
|
|
|
|
+ pars = append(pars, replyStatus)
|
|
|
|
+ }
|
|
|
|
+ //回复人ID
|
|
|
|
+ replierIds := c.GetString("ReplierIds", "")
|
|
|
|
+ if replierIds != "" {
|
|
|
|
+ condition += ` AND q.replier_admin_id IN (` + replierIds + `)`
|
|
|
|
+ }
|
|
|
|
+ //关键字
|
|
|
|
+ keyword := c.GetString("Keyword", "")
|
|
|
|
+ if keyword != "" {
|
|
|
|
+ condition += ` AND q.question_content like "%` + keyword + `%"`
|
|
}
|
|
}
|
|
-
|
|
|
|
- orderStr += ", q.create_time DESC"
|
|
|
|
}
|
|
}
|
|
var startSize int
|
|
var startSize int
|
|
pageSize, _ := c.GetInt("PageSize")
|
|
pageSize, _ := c.GetInt("PageSize")
|
|
@@ -73,7 +70,7 @@ func (c *CommunityQuestionController) QuestionList() {
|
|
}
|
|
}
|
|
startSize = paging.StartIndex(currentIndex, pageSize)
|
|
startSize = paging.StartIndex(currentIndex, pageSize)
|
|
|
|
|
|
- total, resp, err := yb.GetQuestionList(condition, pars, orderStr, startSize, pageSize)
|
|
|
|
|
|
+ total, resp, err := yb.GetQuestionList(condition, pars, startSize, pageSize)
|
|
if err != nil {
|
|
if err != nil {
|
|
c.FailWithMessage("获取问答列表失败", "QuestionList ErrMsg:"+err.Error())
|
|
c.FailWithMessage("获取问答列表失败", "QuestionList ErrMsg:"+err.Error())
|
|
return
|
|
return
|