diff options
Diffstat (limited to 'backend/models')
| -rw-r--r-- | backend/models/models.go | 113 | ||||
| -rw-r--r-- | backend/models/requests.go | 8 | ||||
| -rw-r--r-- | backend/models/responses.go | 54 |
3 files changed, 88 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 | ||
| 7 | type Response struct { | ||
| 8 | Success bool `json:"success"` | ||
| 9 | Message string `json:"message"` | ||
| 10 | Data any `json:"data"` | ||
| 11 | } | ||
| 12 | |||
| 13 | type LoginResponse struct { | ||
| 14 | Token string `json:"token"` | ||
| 15 | } | ||
| 16 | |||
| 17 | type User struct { | 7 | type 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 | ||
| 16 | type UserShort struct { | ||
| 17 | SteamID string `json:"steam_id"` | ||
| 18 | UserName string `json:"user_name"` | ||
| 19 | } | ||
| 20 | |||
| 26 | type Map struct { | 21 | type 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 | ||
| 29 | type MapShort struct { | ||
| 30 | ID int `json:"id"` | ||
| 31 | Name string `json:"name"` | ||
| 32 | } | ||
| 33 | |||
| 34 | type MapSummary struct { | 34 | type 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 | ||
| 60 | type UserRanking struct { | ||
| 61 | UserID string `json:"user_id"` | ||
| 62 | UserName string `json:"user_name"` | ||
| 63 | TotalScore int `json:"total_score"` | ||
| 64 | } | ||
| 65 | |||
| 66 | type Game struct { | ||
| 67 | ID int `json:"id"` | ||
| 68 | Name string `json:"name"` | ||
| 69 | } | ||
| 70 | |||
| 71 | type Chapter struct { | ||
| 72 | ID int `json:"id"` | ||
| 73 | Name string `json:"name"` | ||
| 74 | } | ||
| 75 | |||
| 60 | type RecordSP struct { | 76 | type 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 | ||
| 88 | type 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 | |||
| 95 | type UserRanking struct { | ||
| 96 | UserID string `json:"user_id"` | ||
| 97 | UserName string `json:"user_name"` | ||
| 98 | TotalScore int `json:"total_score"` | ||
| 99 | } | ||
| 100 | |||
| 101 | type RankingsResponse struct { | ||
| 102 | RankingsSP []UserRanking `json:"rankings_sp"` | ||
| 103 | RankingsMP []UserRanking `json:"rankings_mp"` | ||
| 104 | } | ||
| 105 | |||
| 106 | type 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 | |||
| 116 | type ScoreResponse struct { | ||
| 117 | MapID int `json:"map_id"` | ||
| 118 | Records any `json:"records"` | ||
| 119 | } | ||
| 120 | |||
| 121 | type 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 | |||
| 132 | type PlayerSummaries struct { | 104 | type 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 | |||
| 156 | type Game struct { | ||
| 157 | ID int `json:"id"` | ||
| 158 | Name string `json:"name"` | ||
| 159 | } | ||
| 160 | |||
| 161 | type ChaptersResponse struct { | ||
| 162 | Game Game `json:"game"` | ||
| 163 | Chapters []Chapter `json:"chapters"` | ||
| 164 | } | ||
| 165 | |||
| 166 | type Chapter struct { | ||
| 167 | ID int `json:"id"` | ||
| 168 | Name string `json:"name"` | ||
| 169 | } | ||
| 170 | |||
| 171 | type MapShort struct { | ||
| 172 | ID int `json:"id"` | ||
| 173 | Name string `json:"name"` | ||
| 174 | } | ||
| 175 | |||
| 176 | type ChapterMapsResponse struct { | ||
| 177 | Chapter Chapter `json:"chapter"` | ||
| 178 | Maps []MapShort `json:"maps"` | ||
| 179 | } | ||
| 180 | |||
| 181 | func ErrorResponse(message string) Response { | ||
| 182 | return Response{ | ||
| 183 | Success: false, | ||
| 184 | Message: message, | ||
| 185 | Data: nil, | ||
| 186 | } | ||
| 187 | } | ||
diff --git a/backend/models/requests.go b/backend/models/requests.go new file mode 100644 index 0000000..49b2d75 --- /dev/null +++ b/backend/models/requests.go | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | package models | ||
| 2 | |||
| 3 | type RecordRequest struct { | ||
| 4 | ScoreCount int `json:"score_count" form:"score_count" binding:"required"` | ||
| 5 | ScoreTime int `json:"score_time" form:"score_time" binding:"required"` | ||
| 6 | PartnerID string `json:"partner_id" form:"partner_id" binding:"required"` | ||
| 7 | IsPartnerOrange bool `json:"is_partner_orange" form:"is_partner_orange" binding:"required"` | ||
| 8 | } | ||
diff --git a/backend/models/responses.go b/backend/models/responses.go new file mode 100644 index 0000000..5a88353 --- /dev/null +++ b/backend/models/responses.go | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | package models | ||
| 2 | |||
| 3 | type Response struct { | ||
| 4 | Success bool `json:"success"` | ||
| 5 | Message string `json:"message"` | ||
| 6 | Data any `json:"data"` | ||
| 7 | } | ||
| 8 | |||
| 9 | type LoginResponse struct { | ||
| 10 | Token string `json:"token"` | ||
| 11 | } | ||
| 12 | |||
| 13 | type RankingsResponse struct { | ||
| 14 | RankingsSP []UserRanking `json:"rankings_sp"` | ||
| 15 | RankingsMP []UserRanking `json:"rankings_mp"` | ||
| 16 | } | ||
| 17 | |||
| 18 | type ProfileResponse struct { | ||
| 19 | Profile bool `json:"profile"` | ||
| 20 | SteamID string `json:"steam_id"` | ||
| 21 | UserName string `json:"user_name"` | ||
| 22 | AvatarLink string `json:"avatar_link"` | ||
| 23 | CountryCode string `json:"country_code"` | ||
| 24 | ScoresSP []ScoreResponse `json:"scores_sp"` | ||
| 25 | ScoresMP []ScoreResponse `json:"scores_mp"` | ||
| 26 | } | ||
| 27 | |||
| 28 | type ScoreResponse struct { | ||
| 29 | MapID int `json:"map_id"` | ||
| 30 | Records any `json:"records"` | ||
| 31 | } | ||
| 32 | |||
| 33 | type SearchResponse struct { | ||
| 34 | Players []UserShort `json:"players"` | ||
| 35 | Maps []MapShort `json:"maps"` | ||
| 36 | } | ||
| 37 | |||
| 38 | type ChaptersResponse struct { | ||
| 39 | Game Game `json:"game"` | ||
| 40 | Chapters []Chapter `json:"chapters"` | ||
| 41 | } | ||
| 42 | |||
| 43 | type ChapterMapsResponse struct { | ||
| 44 | Chapter Chapter `json:"chapter"` | ||
| 45 | Maps []MapShort `json:"maps"` | ||
| 46 | } | ||
| 47 | |||
| 48 | func ErrorResponse(message string) Response { | ||
| 49 | return Response{ | ||
| 50 | Success: false, | ||
| 51 | Message: message, | ||
| 52 | Data: nil, | ||
| 53 | } | ||
| 54 | } | ||