diff --git a/docs/docs.go b/docs/docs.go index dc3e84eb..9276de4f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -7545,6 +7545,10 @@ const docTemplate = `{ "schema.QuestionPageReq": { "type": "object", "properties": { + "inDays": { + "type": "integer", + "minimum": 1 + }, "orderCond": { "type": "string", "enum": [ diff --git a/docs/swagger.json b/docs/swagger.json index e5bb8b3c..f06e078d 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -7533,6 +7533,10 @@ "schema.QuestionPageReq": { "type": "object", "properties": { + "inDays": { + "type": "integer", + "minimum": 1 + }, "orderCond": { "type": "string", "enum": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 2f0c90e3..e9f6f1be 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1202,6 +1202,9 @@ definitions: type: object schema.QuestionPageReq: properties: + inDays: + minimum: 1 + type: integer orderCond: enum: - newest diff --git a/internal/repo/question/question_repo.go b/internal/repo/question/question_repo.go index 5b1ab705..26de8796 100644 --- a/internal/repo/question/question_repo.go +++ b/internal/repo/question/question_repo.go @@ -245,7 +245,7 @@ func (qr *questionRepo) GetQuestionIDsPage(ctx context.Context, page, pageSize i } // GetQuestionPage query question page -func (qr *questionRepo) GetQuestionPage(ctx context.Context, page, pageSize int, userID, tagID, orderCond string) ( +func (qr *questionRepo) GetQuestionPage(ctx context.Context, page, pageSize int, userID, tagID, orderCond string, inDays int) ( questionList []*entity.Question, total int64, err error) { questionList = make([]*entity.Question, 0) diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.go index 19a2c3fd..8ee24194 100644 --- a/internal/schema/question_schema.go +++ b/internal/schema/question_schema.go @@ -277,6 +277,7 @@ type QuestionPageReq struct { OrderCond string `validate:"omitempty,oneof=newest active frequent score unanswered" form:"order"` Tag string `validate:"omitempty,gt=0,lte=100" form:"tag"` Username string `validate:"omitempty,gt=0,lte=100" form:"username"` + InDays int `validate:"omitempty,min=1" form:"in_days"` LoginUserID string `json:"-"` UserIDBeSearched string `json:"-"` diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.go index a0d039fc..93623569 100644 --- a/internal/service/question_common/question.go +++ b/internal/service/question_common/question.go @@ -32,7 +32,7 @@ type QuestionRepo interface { UpdateQuestion(ctx context.Context, question *entity.Question, Cols []string) (err error) GetQuestion(ctx context.Context, id string) (question *entity.Question, exist bool, err error) GetQuestionList(ctx context.Context, question *entity.Question) (questions []*entity.Question, err error) - GetQuestionPage(ctx context.Context, page, pageSize int, userID, tagID, orderCond string) ( + GetQuestionPage(ctx context.Context, page, pageSize int, userID, tagID, orderCond string, inDays int) ( questionList []*entity.Question, total int64, err error) UpdateQuestionStatus(ctx context.Context, question *entity.Question) (err error) UpdateQuestionStatusWithOutUpdateTime(ctx context.Context, question *entity.Question) (err error) diff --git a/internal/service/question_service.go b/internal/service/question_service.go index 5c4b2f3f..9acb7f27 100644 --- a/internal/service/question_service.go +++ b/internal/service/question_service.go @@ -931,7 +931,7 @@ func (qs *QuestionService) GetQuestionPage(ctx context.Context, req *schema.Ques } questionList, total, err := qs.questionRepo.GetQuestionPage(ctx, req.Page, req.PageSize, - req.UserIDBeSearched, req.TagID, req.OrderCond) + req.UserIDBeSearched, req.TagID, req.OrderCond, req.InDays) if err != nil { return nil, 0, err }