Skip to content

Commit

Permalink
feat: search group name
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Sep 28, 2023
1 parent 78a3ea2 commit 489ceb5
Show file tree
Hide file tree
Showing 9 changed files with 491 additions and 48 deletions.
7 changes: 5 additions & 2 deletions cmd/migrate/danke_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ where true`).Error
return err
}

// update course_group.course_count
err = tx.Exec(`update course_group set course_count = (select count(*) from course where course.course_group_id = course_group.id) where true`).Error
// update course_group.course_count, course_group.credits
err = tx.Exec(`update course_group
set course_count = (select count(*) from course where course.course_group_id = course_group.id)
credits = (select concat('[', group_concat(distinct credit), ']') from course group by course_group_id);
where true`).Error

if m.HasColumn(&model.Review{}, "upvoters") {
err = m.DropColumn(&model.Review{}, "upvoters")
Expand Down
129 changes: 120 additions & 9 deletions internal/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const docTemplate = `{
},
"/courses/refresh": {
"get": {
"description": "refresh course group hash",
"description": "refresh course group hash, admin only",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -874,6 +874,64 @@ const docTemplate = `{
}
}
}
},
"/v3/course_groups/search": {
"get": {
"description": "search course group, no courses",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"CourseGroup"
],
"summary": "search course group",
"parameters": [
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "page_size",
"in": "query"
},
{
"type": "string",
"name": "query",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/schema.PagedResponse-schema_CourseGroupV3Response-any"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/schema.HttpError"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/schema.HttpBaseError"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/schema.HttpBaseError"
}
}
}
}
}
},
"definitions": {
Expand Down Expand Up @@ -934,6 +992,45 @@ const docTemplate = `{
}
}
},
"schema.CourseGroupV3Response": {
"type": "object",
"properties": {
"campus_name": {
"description": "开课校区",
"type": "string"
},
"code": {
"description": "课程组编号",
"type": "string"
},
"course_list": {
"description": "课程组下的课程,slices 必须非空",
"type": "array",
"items": {
"$ref": "#/definitions/schema.CourseV1Response"
}
},
"credits": {
"description": "学分",
"type": "array",
"items": {
"type": "number"
}
},
"department": {
"description": "开课学院",
"type": "string"
},
"id": {
"description": "课程组 ID",
"type": "integer"
},
"name": {
"description": "课程组名称",
"type": "string"
}
}
},
"schema.CourseV1Response": {
"type": "object",
"properties": {
Expand All @@ -942,7 +1039,7 @@ const docTemplate = `{
"type": "string"
},
"code": {
"description": "课程编号",
"description": "编号",
"type": "string"
},
"code_id": {
Expand All @@ -958,15 +1055,14 @@ const docTemplate = `{
"type": "string"
},
"id": {
"description": "课程 ID",
"type": "integer"
},
"max_student": {
"description": "最大选课人数",
"type": "integer"
},
"name": {
"description": "课程名称",
"description": "名称",
"type": "string"
},
"review_list": {
Expand Down Expand Up @@ -1236,7 +1332,7 @@ const docTemplate = `{
]
},
"group_id": {
"description": "课程组信息",
"description": "课程组 ID",
"type": "integer"
},
"history": {
Expand All @@ -1247,7 +1343,6 @@ const docTemplate = `{
}
},
"id": {
"description": "评教 ID",
"type": "integer"
},
"rank": {
Expand Down Expand Up @@ -1284,6 +1379,24 @@ const docTemplate = `{
}
}
},
"schema.PagedResponse-schema_CourseGroupV3Response-any": {
"type": "object",
"properties": {
"extra": {},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/schema.CourseGroupV3Response"
}
},
"page": {
"type": "integer"
},
"page_size": {
"type": "integer"
}
}
},
"schema.RandomReviewV1Response": {
"type": "object",
"properties": {
Expand All @@ -1308,7 +1421,7 @@ const docTemplate = `{
]
},
"group_id": {
"description": "课程组信息",
"description": "课程组 ID",
"type": "integer"
},
"history": {
Expand All @@ -1319,7 +1432,6 @@ const docTemplate = `{
}
},
"id": {
"description": "评教 ID",
"type": "integer"
},
"rank": {
Expand Down Expand Up @@ -1500,7 +1612,6 @@ const docTemplate = `{
}
},
"id": {
"description": "评教 ID",
"type": "integer"
},
"is_me": {
Expand Down
Loading

0 comments on commit 489ceb5

Please sign in to comment.