aboutsummaryrefslogtreecommitdiff
path: root/backend/models/models.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/models/models.go')
-rw-r--r--backend/models/models.go113
1 files changed, 26 insertions, 87 deletions
diff --git a/backend/models/models.go b/backend/models/models.go
index 6f5173a..49a4f82 100644
--- a/backend/models/models.go
+++ b/backend/models/models.go
@@ -4,16 +4,6 @@ import (
4 "time" 4 "time"
5) 5)
6 6
7type Response struct {
8 Success bool `json:"success"`
9 Message string `json:"message"`
10 Data any `json:"data"`
11}
12
13type LoginResponse struct {
14 Token string `json:"token"`
15}
16
17type User struct { 7type User struct {
18 SteamID string `json:"steam_id"` 8 SteamID string `json:"steam_id"`
19 UserName string `json:"user_name"` 9 UserName string `json:"user_name"`
@@ -23,6 +13,11 @@ type User struct {
23 UpdatedAt time.Time `json:"updated_at"` 13 UpdatedAt time.Time `json:"updated_at"`
24} 14}
25 15
16type UserShort struct {
17 SteamID string `json:"steam_id"`
18 UserName string `json:"user_name"`
19}
20
26type Map struct { 21type Map struct {
27 ID int `json:"id"` 22 ID int `json:"id"`
28 GameName string `json:"game_name"` 23 GameName string `json:"game_name"`
@@ -31,6 +26,11 @@ type Map struct {
31 Data any `json:"data"` 26 Data any `json:"data"`
32} 27}
33 28
29type MapShort struct {
30 ID int `json:"id"`
31 Name string `json:"name"`
32}
33
34type MapSummary struct { 34type MapSummary struct {
35 Description string `json:"description"` 35 Description string `json:"description"`
36 Showcase string `json:"showcase"` 36 Showcase string `json:"showcase"`
@@ -57,6 +57,22 @@ type MapHistory struct {
57 Date time.Time `json:"date"` 57 Date time.Time `json:"date"`
58} 58}
59 59
60type UserRanking struct {
61 UserID string `json:"user_id"`
62 UserName string `json:"user_name"`
63 TotalScore int `json:"total_score"`
64}
65
66type Game struct {
67 ID int `json:"id"`
68 Name string `json:"name"`
69}
70
71type Chapter struct {
72 ID int `json:"id"`
73 Name string `json:"name"`
74}
75
60type RecordSP struct { 76type RecordSP struct {
61 RecordID int `json:"record_id"` 77 RecordID int `json:"record_id"`
62 Placement int `json:"placement"` 78 Placement int `json:"placement"`
@@ -85,50 +101,6 @@ type RecordMP struct {
85 RecordDate time.Time `json:"record_date"` 101 RecordDate time.Time `json:"record_date"`
86} 102}
87 103
88type RecordRequest struct {
89 ScoreCount int `json:"score_count" form:"score_count" binding:"required"`
90 ScoreTime int `json:"score_time" form:"score_time" binding:"required"`
91 PartnerID string `json:"partner_id" form:"partner_id" binding:"required"`
92 IsPartnerOrange bool `json:"is_partner_orange" form:"is_partner_orange" binding:"required"`
93}
94
95type UserRanking struct {
96 UserID string `json:"user_id"`
97 UserName string `json:"user_name"`
98 TotalScore int `json:"total_score"`
99}
100
101type RankingsResponse struct {
102 RankingsSP []UserRanking `json:"rankings_sp"`
103 RankingsMP []UserRanking `json:"rankings_mp"`
104}
105
106type ProfileResponse struct {
107 Profile bool `json:"profile"`
108 SteamID string `json:"steam_id"`
109 UserName string `json:"user_name"`
110 AvatarLink string `json:"avatar_link"`
111 CountryCode string `json:"country_code"`
112 ScoresSP []ScoreResponse `json:"scores_sp"`
113 ScoresMP []ScoreResponse `json:"scores_mp"`
114}
115
116type ScoreResponse struct {
117 MapID int `json:"map_id"`
118 Records any `json:"records"`
119}
120
121type SearchResponse struct {
122 Players []struct {
123 SteamID string `json:"steam_id"`
124 UserName string `json:"user_name"`
125 } `json:"players"`
126 Maps []struct {
127 ID int `json:"id"`
128 Name string `json:"name"`
129 } `json:"maps"`
130}
131
132type PlayerSummaries struct { 104type PlayerSummaries struct {
133 SteamId string `json:"steamid"` 105 SteamId string `json:"steamid"`
134 CommunityVisibilityState int `json:"communityvisibilitystate"` 106 CommunityVisibilityState int `json:"communityvisibilitystate"`
@@ -152,36 +124,3 @@ type PlayerSummaries struct {
152 GameExtraInfo string `json:"gameextrainfo"` 124 GameExtraInfo string `json:"gameextrainfo"`
153 GameServerIp string `json:"gameserverip"` 125 GameServerIp string `json:"gameserverip"`
154} 126}
155
156type Game struct {
157 ID int `json:"id"`
158 Name string `json:"name"`
159}
160
161type ChaptersResponse struct {
162 Game Game `json:"game"`
163 Chapters []Chapter `json:"chapters"`
164}
165
166type Chapter struct {
167 ID int `json:"id"`
168 Name string `json:"name"`
169}
170
171type MapShort struct {
172 ID int `json:"id"`
173 Name string `json:"name"`
174}
175
176type ChapterMapsResponse struct {
177 Chapter Chapter `json:"chapter"`
178 Maps []MapShort `json:"maps"`
179}
180
181func ErrorResponse(message string) Response {
182 return Response{
183 Success: false,
184 Message: message,
185 Data: nil,
186 }
187}