|
@@ -28,6 +28,7 @@ type QuestionController struct {
|
|
|
// @Param PageSize query int true "每页数据条数"
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Param KeyWord query string true "搜索关键词"
|
|
|
+// @Param IsQueryDefault query bool true "是否默认:true,或者false"
|
|
|
// @Success 200 {object} []*rag.QuestionListListResp
|
|
|
// @router /question/list [get]
|
|
|
func (c *QuestionController) List() {
|
|
@@ -46,6 +47,7 @@ func (c *QuestionController) List() {
|
|
|
pageSize, _ := c.GetInt("PageSize")
|
|
|
currentIndex, _ := c.GetInt("CurrentIndex")
|
|
|
keyWord := c.GetString("KeyWord")
|
|
|
+ isQueryDefault, _ := c.GetBool("IsQueryDefault")
|
|
|
|
|
|
var startSize int
|
|
|
if pageSize <= 0 {
|
|
@@ -64,9 +66,15 @@ func (c *QuestionController) List() {
|
|
|
var pars []interface{}
|
|
|
|
|
|
if keyWord != "" {
|
|
|
- condition += fmt.Sprintf(` AND %s like ?`, rag.QuestionColumns.QuestionContent)
|
|
|
+ condition += fmt.Sprintf(` AND %s like ? `, rag.QuestionColumns.QuestionContent)
|
|
|
pars = append(pars, `%`+keyWord+`%`)
|
|
|
}
|
|
|
+
|
|
|
+ if isQueryDefault {
|
|
|
+ condition += fmt.Sprintf(` AND %s = ? `, rag.QuestionColumns.IsDefault)
|
|
|
+ pars = append(pars, 1)
|
|
|
+ }
|
|
|
+
|
|
|
obj := new(rag.Question)
|
|
|
tmpTotal, list, err := obj.GetPageListByCondition(condition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
@@ -84,7 +92,7 @@ func (c *QuestionController) List() {
|
|
|
//"ArticleCreateTime": "desc",
|
|
|
//"WechatArticleId": "desc",
|
|
|
}
|
|
|
- tmpTotal, list, err := elastic.RagQuestionEsSearch(keyWord, startSize, pageSize, sortMap)
|
|
|
+ tmpTotal, list, err := elastic.RagQuestionEsSearch(keyWord, isQueryDefault, startSize, pageSize, sortMap)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
@@ -114,6 +122,7 @@ func (c *QuestionController) List() {
|
|
|
// @Param PageSize query int true "每页数据条数"
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Param KeyWord query string true "搜索关键词"
|
|
|
+// @Param IsQueryDefault query bool true "是否默认:true,或者false"
|
|
|
// @Success 200 {object} []*rag.QuestionListListResp
|
|
|
// @router /question/title/list [get]
|
|
|
func (c *QuestionController) TitleList() {
|
|
@@ -132,6 +141,7 @@ func (c *QuestionController) TitleList() {
|
|
|
pageSize, _ := c.GetInt("PageSize")
|
|
|
currentIndex, _ := c.GetInt("CurrentIndex")
|
|
|
keyWord := c.GetString("KeyWord")
|
|
|
+ isQueryDefault, _ := c.GetBool("IsQueryDefault")
|
|
|
|
|
|
var startSize int
|
|
|
if pageSize <= 0 {
|
|
@@ -153,6 +163,12 @@ func (c *QuestionController) TitleList() {
|
|
|
condition += fmt.Sprintf(` AND %s like ?`, rag.QuestionColumns.QuestionContent)
|
|
|
pars = append(pars, `%`+keyWord+`%`)
|
|
|
}
|
|
|
+
|
|
|
+ if isQueryDefault {
|
|
|
+ condition += fmt.Sprintf(` AND %s = ? `, rag.QuestionColumns.IsDefault)
|
|
|
+ pars = append(pars, 1)
|
|
|
+ }
|
|
|
+
|
|
|
obj := new(rag.Question)
|
|
|
tmpTotal, list, err := obj.GetTitlePageListByCondition(condition, pars, startSize, pageSize)
|
|
|
if err != nil {
|
|
@@ -170,7 +186,7 @@ func (c *QuestionController) TitleList() {
|
|
|
//"ArticleCreateTime": "desc",
|
|
|
//"WechatArticleId": "desc",
|
|
|
}
|
|
|
- tmpTotal, esList, err := elastic.RagQuestionEsSearch(keyWord, startSize, pageSize, sortMap)
|
|
|
+ tmpTotal, esList, err := elastic.RagQuestionEsSearch(keyWord, isQueryDefault, startSize, pageSize, sortMap)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|