mirror of https://gitee.com/answerdev/answer.git
Merge branch 'fix/search' into 'main'
Fix/search See merge request opensource/answer!156
This commit is contained in:
commit
861477234a
|
@ -62,6 +62,12 @@ const docTemplate = `{
|
||||||
"description": "answer id or question title",
|
"description": "answer id or question title",
|
||||||
"name": "query",
|
"name": "query",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "question id",
|
||||||
|
"name": "question_id",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
|
@ -50,6 +50,12 @@
|
||||||
"description": "answer id or question title",
|
"description": "answer id or question title",
|
||||||
"name": "query",
|
"name": "query",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "question id",
|
||||||
|
"name": "question_id",
|
||||||
|
"in": "query"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
|
@ -1394,6 +1394,10 @@ paths:
|
||||||
in: query
|
in: query
|
||||||
name: query
|
name: query
|
||||||
type: string
|
type: string
|
||||||
|
- description: question id
|
||||||
|
in: query
|
||||||
|
name: question_id
|
||||||
|
type: string
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
|
|
|
@ -391,6 +391,7 @@ func (qc *QuestionController) CmsSearchList(ctx *gin.Context) {
|
||||||
// @Param page_size query int false "page size"
|
// @Param page_size query int false "page size"
|
||||||
// @Param status query string false "user status" Enums(available,deleted)
|
// @Param status query string false "user status" Enums(available,deleted)
|
||||||
// @Param query query string false "answer id or question title"
|
// @Param query query string false "answer id or question title"
|
||||||
|
// @Param question_id query string false "question id"
|
||||||
// @Success 200 {object} handler.RespBody
|
// @Success 200 {object} handler.RespBody
|
||||||
// @Router /answer/admin/api/answer/page [get]
|
// @Router /answer/admin/api/answer/page [get]
|
||||||
func (qc *QuestionController) CmsSearchAnswerList(ctx *gin.Context) {
|
func (qc *QuestionController) CmsSearchAnswerList(ctx *gin.Context) {
|
||||||
|
|
|
@ -45,6 +45,7 @@ type CmsAnswerSearch struct {
|
||||||
Status int `json:"-" form:"-"`
|
Status int `json:"-" form:"-"`
|
||||||
StatusStr string `json:"status" form:"status"` // Status 1 Available 2 closed 10 Deleted
|
StatusStr string `json:"status" form:"status"` // Status 1 Available 2 closed 10 Deleted
|
||||||
Query string `validate:"omitempty,gt=0,lte=100" json:"query" form:"query" ` //Query string
|
Query string `validate:"omitempty,gt=0,lte=100" json:"query" form:"query" ` //Query string
|
||||||
|
QuestionID string `validate:"omitempty,gt=0,lte=24" json:"question_id" form:"question_id" ` //Query string
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminSetAnswerStatusRequest struct {
|
type AdminSetAnswerStatusRequest struct {
|
||||||
|
|
|
@ -257,6 +257,13 @@ func (ar *answerRepo) CmsSearchList(ctx context.Context, search *entity.CmsAnswe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check search by question id
|
||||||
|
if len(search.QuestionID) > 0 {
|
||||||
|
session.And(builder.Eq{
|
||||||
|
"question_id": search.QuestionID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
offset := search.Page * search.PageSize
|
offset := search.Page * search.PageSize
|
||||||
session.
|
session.
|
||||||
OrderBy("a.updated_at desc").
|
OrderBy("a.updated_at desc").
|
||||||
|
|
Loading…
Reference in New Issue