Skip to content

Commit

Permalink
fix: search code; docs: id string to integer
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Oct 3, 2023
1 parent ae27ab2 commit 5ec032b
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/docs/docs.go
Original file line number Diff line number Diff line change
@@ -527,7 +527,7 @@ const docTemplate = `{
"deprecated": true,
"parameters": [
{
"type": "string",
"type": "integer",
"description": "course group id",
"name": "id",
"in": "path",
@@ -955,7 +955,7 @@ const docTemplate = `{
"summary": "/v3/course_groups/{group_id}",
"parameters": [
{
"type": "string",
"type": "integer",
"description": "course group id",
"name": "id",
"in": "path",
4 changes: 2 additions & 2 deletions internal/docs/swagger.json
Original file line number Diff line number Diff line change
@@ -524,7 +524,7 @@
"deprecated": true,
"parameters": [
{
"type": "string",
"type": "integer",
"description": "course group id",
"name": "id",
"in": "path",
@@ -952,7 +952,7 @@
"summary": "/v3/course_groups/{group_id}",
"parameters": [
{
"type": "string",
"type": "integer",
"description": "course group id",
"name": "id",
"in": "path",
4 changes: 2 additions & 2 deletions internal/docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -904,7 +904,7 @@ paths:
in: path
name: id
required: true
type: string
type: integer
produces:
- application/json
responses:
@@ -1146,7 +1146,7 @@ paths:
in: path
name: id
required: true
type: string
type: integer
produces:
- application/json
responses:
4 changes: 2 additions & 2 deletions internal/handler/course_group.go
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ func (h *courseGroupHandler) RegisterRoute(router fiber.Router) {
// @Produce json
// @Deprecated
// @Router /group/{id} [get]
// @Param id path string true "course group id"
// @Param id path int true "course group id"
// @Success 200 {object} schema.CourseGroupV1Response
// @Failure 400 {object} schema.HttpError
// @Failure 404 {object} schema.HttpBaseError
@@ -178,7 +178,7 @@ func (h *courseGroupHandler) SearchCourseGroupV3(c *fiber.Ctx) (err error) {
// @Accept json
// @Produce json
// @Router /v3/course_groups/{id} [get]
// @Param id path string true "course group id"
// @Param id path int true "course group id"
// @Success 200 {object} schema.CourseGroupV3Response
// @Failure 400 {object} schema.HttpError
// @Failure 404 {object} schema.HttpBaseError
2 changes: 1 addition & 1 deletion internal/service/course_group.go
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ func (c *courseGroupService) SearchCourseGroupV3(
)
groups, err := c.courseGroupRepository.FindGroups(ctx, func(db *gorm.DB) *gorm.DB {
if model.CourseCodeRegexp.MatchString(query) {
db = db.Where("code = ?", "%"+query)
db = db.Where("code LIKE ?", query+"%")
} else {
db = db.Where("name LIKE ?", "%"+query+"%")
}

0 comments on commit 5ec032b

Please sign in to comment.