Skip to content

Commit 7ee0f7a

Browse files
committed
feat: ListDriverExams
1 parent ef235ea commit 7ee0f7a

File tree

6 files changed

+196
-17
lines changed

6 files changed

+196
-17
lines changed

backend/apis/exam/exam.go

+25-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,31 @@ func ListExams(ctx *fiber.Ctx) (err error) {
2727
return
2828
}
2929
var exams Exams
30-
err = DB.Where("user_id = ?", tmpUser.ID).Find(&exams).Error
30+
err = DB.Where("user_id = ? and exam_type = 'exam'", tmpUser.ID).Find(&exams).Error
31+
if err != nil {
32+
return
33+
}
34+
return ctx.JSON(exams)
35+
}
36+
37+
// ListDriverExams @ListDriverExams
38+
// @Router /api/drivers [get]
39+
// @Summary list my driver exams
40+
// @Description list my driver exams
41+
// @Tags Driver
42+
// @Accept json
43+
// @Produce json
44+
// @Success 200 {object} Exams
45+
// @Failure 400 {object} common.HttpError
46+
// @Failure 401 {object} common.HttpError
47+
// @param Authorization header string true "Bearer和token空格拼接"
48+
func ListDriverExams(ctx *fiber.Ctx) (err error) {
49+
tmpUser, err := GetGeneralUser(ctx)
50+
if err != nil {
51+
return
52+
}
53+
var exams Exams
54+
err = DB.Where("user_id = ? and exam_type = 'driver'", tmpUser.ID).Find(&exams).Error
3155
if err != nil {
3256
return
3357
}

backend/apis/exam/route.go

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func RegisterRoutes(routes fiber.Router) {
3030
//routes.Put("/answers/:id", ModifyAnswer)
3131
//routes.Delete("/answers/:id", DeleteAnswer)
3232

33+
routes.Get("/drivers", ListDriverExams)
34+
3335
routes.Get("/drivers/punishments/:id", GetDriverPunishment)
3436
routes.Post("/drivers/punishments/", AddDriverPunishment)
3537
routes.Get("/drivers/punishments/", ListDriverPunishments)

backend/apis/message/api.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func DeleteChat(c *fiber.Ctx) (err error) {
106106
// @Router /api/chats/{id}/records [get]
107107
// @Summary list records by chat ID
108108
// @Description list records by chat ID
109-
// @Tags Record
109+
// @Tags ChatRecord
110110
// @Accept json
111111
// @Produce json
112112
// @Param id path int true "Chat ID"
@@ -144,7 +144,7 @@ func ListChatRecords(c *fiber.Ctx) (err error) {
144144
// @Router /api/chats/{id}/records/me [get]
145145
// @Summary list my records
146146
// @Description list my records
147-
// @Tags Record
147+
// @Tags ChatRecord
148148
// @Accept json
149149
// @Produce json
150150
// @Success 200 {object} Records
@@ -183,7 +183,7 @@ func addRecord(addRecordsRequest AddRecordsRequest) (err error) {
183183
// @Router /api/records [post]
184184
// @Summary Add records
185185
// @Description Add records
186-
// @Tags Record
186+
// @Tags ChatRecord
187187
// @Accept json
188188
// @Produce json
189189
// @Param json body AddRecordsRequest true "json"
@@ -203,7 +203,7 @@ func AddRecords(c *fiber.Ctx) (err error) {
203203
// @Router /api/records [get]
204204
// @Summary list my records
205205
// @Description list my records
206-
// @Tags Record
206+
// @Tags ChatRecord
207207
// @Accept json
208208
// @Produce json
209209
// @Success 200 {object} Records

backend/docs/docs.go

+61-4
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const docTemplate = `{
200200
"application/json"
201201
],
202202
"tags": [
203-
"Record"
203+
"ChatRecord"
204204
],
205205
"summary": "list records by chat ID",
206206
"parameters": [
@@ -260,7 +260,7 @@ const docTemplate = `{
260260
"application/json"
261261
],
262262
"tags": [
263-
"Record"
263+
"ChatRecord"
264264
],
265265
"summary": "list my records",
266266
"parameters": [
@@ -297,6 +297,53 @@ const docTemplate = `{
297297
}
298298
}
299299
},
300+
"/api/drivers": {
301+
"get": {
302+
"description": "list my driver exams",
303+
"consumes": [
304+
"application/json"
305+
],
306+
"produces": [
307+
"application/json"
308+
],
309+
"tags": [
310+
"Driver"
311+
],
312+
"summary": "list my driver exams",
313+
"parameters": [
314+
{
315+
"type": "string",
316+
"description": "Bearer和token空格拼接",
317+
"name": "Authorization",
318+
"in": "header",
319+
"required": true
320+
}
321+
],
322+
"responses": {
323+
"200": {
324+
"description": "OK",
325+
"schema": {
326+
"type": "array",
327+
"items": {
328+
"$ref": "#/definitions/models.Exam"
329+
}
330+
}
331+
},
332+
"400": {
333+
"description": "Bad Request",
334+
"schema": {
335+
"$ref": "#/definitions/common.HttpError"
336+
}
337+
},
338+
"401": {
339+
"description": "Unauthorized",
340+
"schema": {
341+
"$ref": "#/definitions/common.HttpError"
342+
}
343+
}
344+
}
345+
}
346+
},
300347
"/api/drivers/punishments/": {
301348
"get": {
302349
"description": "List driver punishments",
@@ -1106,7 +1153,7 @@ const docTemplate = `{
11061153
"application/json"
11071154
],
11081155
"tags": [
1109-
"Record"
1156+
"ChatRecord"
11101157
],
11111158
"summary": "list my records",
11121159
"parameters": [
@@ -1151,7 +1198,7 @@ const docTemplate = `{
11511198
"application/json"
11521199
],
11531200
"tags": [
1154-
"Record"
1201+
"ChatRecord"
11551202
],
11561203
"summary": "Add records",
11571204
"parameters": [
@@ -1596,6 +1643,9 @@ const docTemplate = `{
15961643
"properties": {
15971644
"id": {
15981645
"type": "integer"
1646+
},
1647+
"normal": {
1648+
"type": "boolean"
15991649
}
16001650
}
16011651
},
@@ -1756,6 +1806,9 @@ const docTemplate = `{
17561806
"is_public": {
17571807
"type": "boolean"
17581808
},
1809+
"normal": {
1810+
"type": "boolean"
1811+
},
17591812
"score": {
17601813
"type": "integer"
17611814
},
@@ -1886,6 +1939,8 @@ const docTemplate = `{
18861939
"time.Duration": {
18871940
"type": "integer",
18881941
"enum": [
1942+
-9223372036854775808,
1943+
9223372036854775807,
18891944
1,
18901945
1000,
18911946
1000000,
@@ -1894,6 +1949,8 @@ const docTemplate = `{
18941949
3600000000000
18951950
],
18961951
"x-enum-varnames": [
1952+
"minDuration",
1953+
"maxDuration",
18971954
"Nanosecond",
18981955
"Microsecond",
18991956
"Millisecond",

backend/docs/swagger.json

+61-4
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
"application/json"
193193
],
194194
"tags": [
195-
"Record"
195+
"ChatRecord"
196196
],
197197
"summary": "list records by chat ID",
198198
"parameters": [
@@ -252,7 +252,7 @@
252252
"application/json"
253253
],
254254
"tags": [
255-
"Record"
255+
"ChatRecord"
256256
],
257257
"summary": "list my records",
258258
"parameters": [
@@ -289,6 +289,53 @@
289289
}
290290
}
291291
},
292+
"/api/drivers": {
293+
"get": {
294+
"description": "list my driver exams",
295+
"consumes": [
296+
"application/json"
297+
],
298+
"produces": [
299+
"application/json"
300+
],
301+
"tags": [
302+
"Driver"
303+
],
304+
"summary": "list my driver exams",
305+
"parameters": [
306+
{
307+
"type": "string",
308+
"description": "Bearer和token空格拼接",
309+
"name": "Authorization",
310+
"in": "header",
311+
"required": true
312+
}
313+
],
314+
"responses": {
315+
"200": {
316+
"description": "OK",
317+
"schema": {
318+
"type": "array",
319+
"items": {
320+
"$ref": "#/definitions/models.Exam"
321+
}
322+
}
323+
},
324+
"400": {
325+
"description": "Bad Request",
326+
"schema": {
327+
"$ref": "#/definitions/common.HttpError"
328+
}
329+
},
330+
"401": {
331+
"description": "Unauthorized",
332+
"schema": {
333+
"$ref": "#/definitions/common.HttpError"
334+
}
335+
}
336+
}
337+
}
338+
},
292339
"/api/drivers/punishments/": {
293340
"get": {
294341
"description": "List driver punishments",
@@ -1098,7 +1145,7 @@
10981145
"application/json"
10991146
],
11001147
"tags": [
1101-
"Record"
1148+
"ChatRecord"
11021149
],
11031150
"summary": "list my records",
11041151
"parameters": [
@@ -1143,7 +1190,7 @@
11431190
"application/json"
11441191
],
11451192
"tags": [
1146-
"Record"
1193+
"ChatRecord"
11471194
],
11481195
"summary": "Add records",
11491196
"parameters": [
@@ -1588,6 +1635,9 @@
15881635
"properties": {
15891636
"id": {
15901637
"type": "integer"
1638+
},
1639+
"normal": {
1640+
"type": "boolean"
15911641
}
15921642
}
15931643
},
@@ -1748,6 +1798,9 @@
17481798
"is_public": {
17491799
"type": "boolean"
17501800
},
1801+
"normal": {
1802+
"type": "boolean"
1803+
},
17511804
"score": {
17521805
"type": "integer"
17531806
},
@@ -1878,6 +1931,8 @@
18781931
"time.Duration": {
18791932
"type": "integer",
18801933
"enum": [
1934+
-9223372036854775808,
1935+
9223372036854775807,
18811936
1,
18821937
1000,
18831938
1000000,
@@ -1886,6 +1941,8 @@
18861941
3600000000000
18871942
],
18881943
"x-enum-varnames": [
1944+
"minDuration",
1945+
"maxDuration",
18891946
"Nanosecond",
18901947
"Microsecond",
18911948
"Millisecond",

0 commit comments

Comments
 (0)