Skip to content

Commit b6a5fdb

Browse files
authored
Merge pull request #37 from sea-kg/feature/add_user_profile_and_team_history
Add a user profile and command history
2 parents f5b277b + 3de582e commit b6a5fdb

File tree

13 files changed

+683
-202
lines changed

13 files changed

+683
-202
lines changed

api/openapi.yaml

Lines changed: 157 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ paths:
160160
description: Bad request
161161
'500':
162162
description: Failed response
163-
'/api/v1/users/{uuid}':
163+
'/api/v1/users/{userId}':
164164
get:
165165
tags:
166166
- Users
167167
summary: Get a user by ID
168168
operationId: getUserById
169169
parameters:
170-
- name: uuid
170+
- name: userId
171171
in: path
172172
required: true
173173
style: simple
@@ -193,7 +193,7 @@ paths:
193193
summary: Update a user
194194
operationId: updateUser
195195
parameters:
196-
- name: uuid
196+
- name: userId
197197
in: path
198198
required: true
199199
style: simple
@@ -221,7 +221,7 @@ paths:
221221
summary: Delete a user
222222
operationId: deleteUser
223223
parameters:
224-
- name: uuid
224+
- name: userId
225225
in: path
226226
required: true
227227
style: simple
@@ -238,6 +238,33 @@ paths:
238238
content:
239239
application/json:
240240
schema: {}
241+
'/api/v1/users/{userId}/profile':
242+
get:
243+
tags:
244+
- Users
245+
summary: Get a profile by user ID
246+
operationId: getProfileById
247+
parameters:
248+
- name: userId
249+
in: path
250+
required: true
251+
style: simple
252+
explode: false
253+
schema:
254+
type: string
255+
format: uuid
256+
example: 81e17cb6-5c46-4934-b6d5-5c8356712cb6
257+
responses:
258+
'200':
259+
description: Detailed information of a profile
260+
content:
261+
application/json:
262+
schema:
263+
$ref: '#/components/schemas/ProfileResponse'
264+
'400':
265+
description: Bad request
266+
'500':
267+
description: Failed response
241268
/api/v1/games:
242269
get:
243270
tags:
@@ -276,14 +303,14 @@ paths:
276303
description: Bad request
277304
'500':
278305
description: Failed response
279-
'/api/v1/games/{uuid}':
306+
'/api/v1/games/{gameId}':
280307
get:
281308
tags:
282309
- Games
283310
summary: Get a game by ID
284311
operationId: getGameById
285312
parameters:
286-
- name: uuid
313+
- name: gameId
287314
in: path
288315
required: true
289316
style: simple
@@ -309,7 +336,7 @@ paths:
309336
summary: Update a game
310337
operationId: updateGame
311338
parameters:
312-
- name: uuid
339+
- name: gameId
313340
in: path
314341
required: true
315342
style: simple
@@ -343,7 +370,7 @@ paths:
343370
summary: Delete a game
344371
operationId: deleteGame
345372
parameters:
346-
- name: uuid
373+
- name: gameId
347374
in: path
348375
required: true
349376
style: simple
@@ -411,14 +438,14 @@ paths:
411438
content:
412439
application/json:
413440
schema: {}
414-
'/api/v1/teams/{uuid}':
441+
'/api/v1/teams/{teamId}':
415442
get:
416443
tags:
417444
- Teams
418445
summary: Get a team by ID
419446
operationId: getTeamById
420447
parameters:
421-
- name: uuid
448+
- name: teamId
422449
in: path
423450
required: true
424451
style: simple
@@ -440,7 +467,7 @@ paths:
440467
summary: Update a team
441468
operationId: updateTeam
442469
parameters:
443-
- name: uuid
470+
- name: teamId
444471
in: path
445472
required: true
446473
style: simple
@@ -464,7 +491,7 @@ paths:
464491
summary: Delete a team
465492
operationId: deleteTeam
466493
parameters:
467-
- name: uuid
494+
- name: teamId
468495
in: path
469496
required: true
470497
style: simple
@@ -476,6 +503,66 @@ paths:
476503
responses:
477504
'200':
478505
description: Team deleted successfully
506+
/api/v1/teams/{teamId}/join/{userId}:
507+
post:
508+
tags:
509+
- Teams
510+
summary: Connect user with team
511+
parameters:
512+
- in: path
513+
name: teamId
514+
required: true
515+
schema:
516+
type: string
517+
format: uuid
518+
description: The ID of the team
519+
- in: path
520+
name: userId
521+
required: true
522+
schema:
523+
type: string
524+
format: uuid
525+
description: The ID of the user
526+
responses:
527+
'200':
528+
description: Connect successfully
529+
content:
530+
application/json:
531+
schema:
532+
type: object
533+
properties:
534+
message:
535+
type: string
536+
/api/v1/teams/{teamId}/leave/{userId}:
537+
post:
538+
tags:
539+
- Teams
540+
summary: Leave user from team
541+
parameters:
542+
- in: path
543+
name: teamId
544+
required: true
545+
schema:
546+
type: string
547+
format: uuid
548+
description: The ID of the team
549+
- in: path
550+
name: userId
551+
required: true
552+
schema:
553+
type: string
554+
format: uuid
555+
description: The ID of the user
556+
responses:
557+
'200':
558+
description: Left successfully
559+
content:
560+
application/json:
561+
schema:
562+
type: object
563+
properties:
564+
message:
565+
type: string
479566
/api/v1/results:
480567
get:
481568
tags:
@@ -508,14 +595,14 @@ paths:
508595
responses:
509596
'200':
510597
description: Result created successfully
511-
'/api/v1/results/{uuid}':
598+
'/api/v1/results/{resultId}':
512599
get:
513600
tags:
514601
- Results
515602
summary: Get a result by ID
516603
operationId: getResultById
517604
parameters:
518-
- name: uuid
605+
- name: resultId
519606
in: path
520607
required: true
521608
style: simple
@@ -563,14 +650,14 @@ paths:
563650
responses:
564651
'200':
565652
description: Service created successfully
566-
'/api/v1/services/{uuid}':
653+
'/api/v1/services/{serviceId}':
567654
get:
568655
tags:
569656
- Services
570657
summary: Get a service by ID
571658
operationId: getServiceById
572659
parameters:
573-
- name: uuid
660+
- name: serviceId
574661
in: path
575662
required: true
576663
style: simple
@@ -592,7 +679,7 @@ paths:
592679
summary: Update a service
593680
operationId: updateService
594681
parameters:
595-
- name: uuid
682+
- name: serviceId
596683
in: path
597684
required: true
598685
style: simple
@@ -616,7 +703,7 @@ paths:
616703
summary: Delete a service
617704
operationId: deleteService
618705
parameters:
619-
- name: uuid
706+
- name: serviceId
620707
in: path
621708
required: true
622709
style: simple
@@ -628,7 +715,7 @@ paths:
628715
responses:
629716
'200':
630717
description: Service deleted successfully
631-
/api/v1/services/{uuid}/upload/checker:
718+
/api/v1/services/{serviceId}/upload/checker:
632719
post:
633720
tags:
634721
- Services
@@ -637,7 +724,7 @@ paths:
637724
Handler for upload zip-archive with checker
638725
parameters:
639726
- in: path
640-
name: uuid
727+
name: serviceId
641728
required: true
642729
schema:
643730
type: string
@@ -659,7 +746,7 @@ paths:
659746
content:
660747
application/json:
661748
{}
662-
/api/v1/services/{uuid}/upload/service:
749+
/api/v1/services/{serviceId}/upload/service:
663750
post:
664751
summary: Upload zip service
665752
description: |
@@ -668,7 +755,7 @@ paths:
668755
- Services
669756
parameters:
670757
- in: path
671-
name: uuid
758+
name: serviceId
672759
required: true
673760
schema:
674761
type: string
@@ -747,6 +834,50 @@ components:
747834
format: uuid
748835
example: 81e17cb6-5c46-4934-b6d5-5c8356712cb6
749836
description: Unique identifier for the result entry
837+
ProfileResponse:
838+
type: object
839+
description: The response schema for a user's profile, including id, timestamps, team name, and team history.
840+
properties:
841+
id:
842+
type: string
843+
format: uuid
844+
description: The unique identifier for the user.
845+
created_at:
846+
type: string
847+
format: date-time
848+
description: The timestamp when the user profile was created.
849+
updated_at:
850+
type: string
851+
format: date-time
852+
description: The timestamp when the user profile was last updated.
853+
team_name:
854+
type: string
855+
description: The current name of the user's team.
856+
team_history:
857+
type: array
858+
description: The list of teams the user has been part of, including the periods of membership.
859+
items:
860+
$ref: '#/components/schemas/TeamHistory'
861+
TeamHistory:
862+
required:
863+
- name
864+
- join
865+
type: object
866+
description: The schema for recording the history of teams a user has joined and left.
867+
properties:
868+
name:
869+
type: string
870+
description: The name of the team.
871+
join:
872+
type: string
873+
format: date-time
874+
description: The timestamp when the user joined the team.
875+
example: '2024-01-23T04:56:07.000Z'
876+
left:
877+
type: string
878+
format: date-time
879+
description: The timestamp when the user left the team.
880+
example: '2024-01-23T04:56:07.000Z'
750881
UserResponse:
751882
type: object
752883
properties:
@@ -784,12 +915,12 @@ components:
784915
type: string
785916
description: The start time of the game
786917
format: date-time
787-
example: '2000-01-23T04:56:07.000Z'
918+
example: '2024-01-23T04:56:07.000Z'
788919
end_time:
789920
type: string
790921
description: The end time of the game
791922
format: date-time
792-
example: '2000-01-24T04:56:07.000Z'
923+
example: '2024-01-24T04:56:07.000Z'
793924
description:
794925
type: string
795926
description: A brief description of the game
@@ -808,12 +939,12 @@ components:
808939
type: string
809940
description: The start time of the game
810941
format: date-time
811-
example: '2000-01-23T04:56:07.000Z'
942+
example: '2024-01-23T04:56:07.000Z'
812943
end_time:
813944
type: string
814945
description: The end time of the game
815946
format: date-time
816-
example: '2000-01-24T04:56:07.000Z'
947+
example: '2024-01-24T04:56:07.000Z'
817948
description:
818949
type: string
819950
description: A brief description of the game

internal/app/database/struct_updater.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ func RegisterAllUpdates() map[string][]DatabaseUpdateFunc {
4141
allUpdates = RegisterDatabaseUpdate(allUpdates, DatabaseUpdate_update0014_update0014fix1)
4242
allUpdates = RegisterDatabaseUpdate(allUpdates, DatabaseUpdate_update0014_update0015)
4343
allUpdates = RegisterDatabaseUpdate(allUpdates, DatabaseUpdate_update0015_update0015testdata)
44+
allUpdates = RegisterDatabaseUpdate(allUpdates, DatabaseUpdate_update0015_update0016)
45+
allUpdates = RegisterDatabaseUpdate(allUpdates, DatabaseUpdate_update0016_update0016testdata)
4446
return allUpdates
4547
}
4648

0 commit comments

Comments
 (0)