From ba74c83ecbf33b0d76f2e5d71ef13c94484f22d2 Mon Sep 17 00:00:00 2001 From: Ke Chen Date: Mon, 16 Oct 2023 11:34:05 +0800 Subject: [PATCH] feat: update search course_group default page = 1; update docs --- internal/docs/docs.go | 2 +- internal/docs/swagger.json | 2 +- internal/docs/swagger.yaml | 2 +- internal/schema/course_group.go | 2 +- internal/service/course_group.go | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/docs/docs.go b/internal/docs/docs.go index 182222d..48fc722 100644 --- a/internal/docs/docs.go +++ b/internal/docs/docs.go @@ -892,7 +892,7 @@ const docTemplate = `{ { "minimum": 0, "type": "integer", - "example": 0, + "example": 1, "name": "page", "in": "query" }, diff --git a/internal/docs/swagger.json b/internal/docs/swagger.json index 5ba8e8f..4dd1b6c 100644 --- a/internal/docs/swagger.json +++ b/internal/docs/swagger.json @@ -889,7 +889,7 @@ { "minimum": 0, "type": "integer", - "example": 0, + "example": 1, "name": "page", "in": "query" }, diff --git a/internal/docs/swagger.yaml b/internal/docs/swagger.yaml index ea6b62a..c574d37 100644 --- a/internal/docs/swagger.yaml +++ b/internal/docs/swagger.yaml @@ -1175,7 +1175,7 @@ paths: - application/json description: search course group, no courses parameters: - - example: 0 + - example: 1 in: query minimum: 0 name: page diff --git a/internal/schema/course_group.go b/internal/schema/course_group.go index e70c6e9..8adb25d 100644 --- a/internal/schema/course_group.go +++ b/internal/schema/course_group.go @@ -50,7 +50,7 @@ func (r *CourseGroupHashV1Response) FromModel(hash string) *CourseGroupHashV1Res type CourseGroupSearchV3Request struct { Query string `json:"query" form:"query" query:"query" validate:"required" example:"计算机"` - Page int `json:"page" form:"page" query:"page" validate:"min=0" example:"0"` + Page int `json:"page" form:"page" query:"page" validate:"min=0" example:"1"` PageSize int `json:"page_size" form:"page_size" query:"page_size" validate:"min=0,max=100" example:"10"` } diff --git a/internal/service/course_group.go b/internal/service/course_group.go index d523ebe..af373cf 100644 --- a/internal/service/course_group.go +++ b/internal/service/course_group.go @@ -181,6 +181,7 @@ func (c *courseGroupService) SearchCourseGroupV3( } db = db.Limit(pageSize).Offset((page - 1) * pageSize) } else { + page = 1 if pageSize > 0 { db = db.Limit(pageSize) }