diff options
| author | Nidboj132 <lol2s@vp.plm> | 2023-07-12 17:58:23 +0200 |
|---|---|---|
| committer | Nidboj132 <lol2s@vp.plm> | 2023-07-12 17:58:23 +0200 |
| commit | 781289455037431d8adbaa0b293b755c88169747 (patch) | |
| tree | 773824f97c3b21d353b9066afdbde30bee2da4c5 /backend/models/models.go | |
| parent | summary (diff) | |
| parent | fix: 0 score count / showcase not required (#47) (diff) | |
| download | lphub-781289455037431d8adbaa0b293b755c88169747.tar.gz lphub-781289455037431d8adbaa0b293b755c88169747.tar.bz2 lphub-781289455037431d8adbaa0b293b755c88169747.zip | |
Merge branch 'main' of https://github.com/pektezol/LeastPortals
Former-commit-id: af8d8680aafc3d662f8b53a4f50f0ea356b26c26
Diffstat (limited to '')
| -rw-r--r-- | backend/models/models.go | 150 |
1 files changed, 47 insertions, 103 deletions
diff --git a/backend/models/models.go b/backend/models/models.go index 6f5173a..1231cb1 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"` |
| @@ -21,6 +11,12 @@ type User struct { | |||
| 21 | CountryCode string `json:"country_code"` | 11 | CountryCode string `json:"country_code"` |
| 22 | CreatedAt time.Time `json:"created_at"` | 12 | CreatedAt time.Time `json:"created_at"` |
| 23 | UpdatedAt time.Time `json:"updated_at"` | 13 | UpdatedAt time.Time `json:"updated_at"` |
| 14 | Titles []string `json:"titles"` | ||
| 15 | } | ||
| 16 | |||
| 17 | type UserShort struct { | ||
| 18 | SteamID string `json:"steam_id"` | ||
| 19 | UserName string `json:"user_name"` | ||
| 24 | } | 20 | } |
| 25 | 21 | ||
| 26 | type Map struct { | 22 | type Map struct { |
| @@ -28,33 +24,58 @@ type Map struct { | |||
| 28 | GameName string `json:"game_name"` | 24 | GameName string `json:"game_name"` |
| 29 | ChapterName string `json:"chapter_name"` | 25 | ChapterName string `json:"chapter_name"` |
| 30 | MapName string `json:"map_name"` | 26 | MapName string `json:"map_name"` |
| 31 | Data any `json:"data"` | 27 | Image string `json:"image"` |
| 28 | IsCoop bool `json:"is_coop"` | ||
| 29 | } | ||
| 30 | |||
| 31 | type MapShort struct { | ||
| 32 | ID int `json:"id"` | ||
| 33 | Name string `json:"name"` | ||
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | type MapSummary struct { | 36 | type MapSummary struct { |
| 35 | Description string `json:"description"` | 37 | Routes []MapRoute `json:"routes"` |
| 36 | Showcase string `json:"showcase"` | ||
| 37 | CategoryScores MapCategoryScores `json:"category_scores"` | ||
| 38 | Rating float32 `json:"rating"` | ||
| 39 | Routers []string `json:"routers"` | ||
| 40 | History []MapHistory `json:"history"` | ||
| 41 | } | 38 | } |
| 42 | 39 | ||
| 43 | type MapCategoryScores struct { | 40 | type MapHistory struct { |
| 44 | CM int `json:"cm"` | 41 | RunnerName string `json:"runner_name"` |
| 45 | NoSLA int `json:"no_sla"` | 42 | ScoreCount int `json:"score_count"` |
| 46 | InboundsSLA int `json:"inbounds_sla"` | 43 | Date time.Time `json:"date"` |
| 47 | Any int `json:"any"` | 44 | } |
| 45 | |||
| 46 | type MapRoute struct { | ||
| 47 | RouteID int `json:"route_id"` | ||
| 48 | Category Category `json:"category"` | ||
| 49 | History MapHistory `json:"history"` | ||
| 50 | Rating float32 `json:"rating"` | ||
| 51 | Description string `json:"description"` | ||
| 52 | Showcase string `json:"showcase"` | ||
| 48 | } | 53 | } |
| 49 | 54 | ||
| 50 | type MapRecords struct { | 55 | type MapRecords struct { |
| 51 | Records any `json:"records"` | 56 | Records any `json:"records"` |
| 52 | } | 57 | } |
| 53 | 58 | ||
| 54 | type MapHistory struct { | 59 | type UserRanking struct { |
| 55 | RunnerName string `json:"runner_name"` | 60 | UserID string `json:"user_id"` |
| 56 | ScoreCount int `json:"score_count"` | 61 | UserName string `json:"user_name"` |
| 57 | Date time.Time `json:"date"` | 62 | TotalScore int `json:"total_score"` |
| 63 | } | ||
| 64 | |||
| 65 | type Game struct { | ||
| 66 | ID int `json:"id"` | ||
| 67 | Name string `json:"name"` | ||
| 68 | IsCoop bool `json:"is_coop"` | ||
| 69 | } | ||
| 70 | |||
| 71 | type Chapter struct { | ||
| 72 | ID int `json:"id"` | ||
| 73 | Name string `json:"name"` | ||
| 74 | } | ||
| 75 | |||
| 76 | type Category struct { | ||
| 77 | ID int `json:"id"` | ||
| 78 | Name string `json:"name"` | ||
| 58 | } | 79 | } |
| 59 | 80 | ||
| 60 | type RecordSP struct { | 81 | type RecordSP struct { |
| @@ -85,50 +106,6 @@ type RecordMP struct { | |||
| 85 | RecordDate time.Time `json:"record_date"` | 106 | RecordDate time.Time `json:"record_date"` |
| 86 | } | 107 | } |
| 87 | 108 | ||
| 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 { | 109 | type PlayerSummaries struct { |
| 133 | SteamId string `json:"steamid"` | 110 | SteamId string `json:"steamid"` |
| 134 | CommunityVisibilityState int `json:"communityvisibilitystate"` | 111 | CommunityVisibilityState int `json:"communityvisibilitystate"` |
| @@ -152,36 +129,3 @@ type PlayerSummaries struct { | |||
| 152 | GameExtraInfo string `json:"gameextrainfo"` | 129 | GameExtraInfo string `json:"gameextrainfo"` |
| 153 | GameServerIp string `json:"gameserverip"` | 130 | GameServerIp string `json:"gameserverip"` |
| 154 | } | 131 | } |
| 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 | } | ||