mirror of https://gitee.com/answerdev/answer.git
feat: admin's answer list filter by question id
This commit is contained in:
parent
c3f42f1d9e
commit
c6d703321f
|
@ -391,6 +391,7 @@ func (qc *QuestionController) CmsSearchList(ctx *gin.Context) {
|
|||
// @Param page_size query int false "page size"
|
||||
// @Param status query string false "user status" Enums(available,deleted)
|
||||
// @Param query query string false "answer id or question title"
|
||||
// @Param question_id query string false "question id"
|
||||
// @Success 200 {object} handler.RespBody
|
||||
// @Router /answer/admin/api/answer/page [get]
|
||||
func (qc *QuestionController) CmsSearchAnswerList(ctx *gin.Context) {
|
||||
|
|
|
@ -40,11 +40,12 @@ type AnswerSearch struct {
|
|||
}
|
||||
|
||||
type CmsAnswerSearch struct {
|
||||
Page int `json:"page" form:"page"` // Query number of pages
|
||||
PageSize int `json:"page_size" form:"page_size"` // Search page size
|
||||
Status int `json:"-" form:"-"`
|
||||
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
|
||||
Page int `json:"page" form:"page"` // Query number of pages
|
||||
PageSize int `json:"page_size" form:"page_size"` // Search page size
|
||||
Status int `json:"-" form:"-"`
|
||||
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
|
||||
QuestionID string `validate:"omitempty,gt=0,lte=24" json:"question_id" form:"question_id" ` //Query string
|
||||
}
|
||||
|
||||
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
|
||||
session.
|
||||
OrderBy("a.updated_at desc").
|
||||
|
|
Loading…
Reference in New Issue