diff options
| author | Nidboj132 <lol2s@vp.plm> | 2023-09-05 18:23:11 +0200 |
|---|---|---|
| committer | Nidboj132 <lol2s@vp.plm> | 2023-09-05 18:23:11 +0200 |
| commit | 3869cb67351ccf3bc45b076f31afdc7133292c39 (patch) | |
| tree | dc03341e147dde0964bf6be84b14e13424c647b7 /backend/models | |
| parent | added graph and fixed some css (diff) | |
| parent | fix: create map summary, why the fuck does this have to be a pointer integer?? (diff) | |
| download | lphub-3869cb67351ccf3bc45b076f31afdc7133292c39.tar.gz lphub-3869cb67351ccf3bc45b076f31afdc7133292c39.tar.bz2 lphub-3869cb67351ccf3bc45b076f31afdc7133292c39.zip | |
Merge branch 'main' of https://github.com/pektezol/LeastPortalsHub
Former-commit-id: 221385f463b7f5b0fc43a093b2c7c46e68d46d68
Diffstat (limited to 'backend/models')
| -rw-r--r-- | backend/models/models.go | 63 | ||||
| -rw-r--r-- | backend/models/requests.go | 39 | ||||
| -rw-r--r-- | backend/models/responses.go | 64 |
3 files changed, 33 insertions, 133 deletions
diff --git a/backend/models/models.go b/backend/models/models.go index 1231cb1..2d54295 100644 --- a/backend/models/models.go +++ b/backend/models/models.go | |||
| @@ -4,6 +4,20 @@ 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 | func ErrorResponse(message string) Response { | ||
| 14 | return Response{ | ||
| 15 | Success: false, | ||
| 16 | Message: message, | ||
| 17 | Data: nil, | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 7 | type User struct { | 21 | type User struct { |
| 8 | SteamID string `json:"steam_id"` | 22 | SteamID string `json:"steam_id"` |
| 9 | UserName string `json:"user_name"` | 23 | UserName string `json:"user_name"` |
| @@ -11,7 +25,7 @@ type User struct { | |||
| 11 | CountryCode string `json:"country_code"` | 25 | CountryCode string `json:"country_code"` |
| 12 | CreatedAt time.Time `json:"created_at"` | 26 | CreatedAt time.Time `json:"created_at"` |
| 13 | UpdatedAt time.Time `json:"updated_at"` | 27 | UpdatedAt time.Time `json:"updated_at"` |
| 14 | Titles []string `json:"titles"` | 28 | Titles []Title `json:"titles"` |
| 15 | } | 29 | } |
| 16 | 30 | ||
| 17 | type UserShort struct { | 31 | type UserShort struct { |
| @@ -19,6 +33,12 @@ type UserShort struct { | |||
| 19 | UserName string `json:"user_name"` | 33 | UserName string `json:"user_name"` |
| 20 | } | 34 | } |
| 21 | 35 | ||
| 36 | type UserShortWithAvatar struct { | ||
| 37 | SteamID string `json:"steam_id"` | ||
| 38 | UserName string `json:"user_name"` | ||
| 39 | AvatarLink string `json:"avatar_link"` | ||
| 40 | } | ||
| 41 | |||
| 22 | type Map struct { | 42 | type Map struct { |
| 23 | ID int `json:"id"` | 43 | ID int `json:"id"` |
| 24 | GameName string `json:"game_name"` | 44 | GameName string `json:"game_name"` |
| @@ -57,9 +77,8 @@ type MapRecords struct { | |||
| 57 | } | 77 | } |
| 58 | 78 | ||
| 59 | type UserRanking struct { | 79 | type UserRanking struct { |
| 60 | UserID string `json:"user_id"` | 80 | User UserShort `json:"user"` |
| 61 | UserName string `json:"user_name"` | 81 | TotalScore int `json:"total_score"` |
| 62 | TotalScore int `json:"total_score"` | ||
| 63 | } | 82 | } |
| 64 | 83 | ||
| 65 | type Game struct { | 84 | type Game struct { |
| @@ -78,32 +97,16 @@ type Category struct { | |||
| 78 | Name string `json:"name"` | 97 | Name string `json:"name"` |
| 79 | } | 98 | } |
| 80 | 99 | ||
| 81 | type RecordSP struct { | 100 | type Title struct { |
| 82 | RecordID int `json:"record_id"` | 101 | Name string `json:"name"` |
| 83 | Placement int `json:"placement"` | 102 | Color string `json:"color"` |
| 84 | UserID string `json:"user_id"` | 103 | } |
| 85 | UserName string `json:"user_name"` | 104 | |
| 86 | UserAvatar string `json:"user_avatar"` | 105 | type Links struct { |
| 87 | ScoreCount int `json:"score_count"` | 106 | P2SR string `json:"p2sr"` |
| 88 | ScoreTime int `json:"score_time"` | 107 | Steam string `json:"stream"` |
| 89 | DemoID string `json:"demo_id"` | 108 | YouTube string `json:"youtube"` |
| 90 | RecordDate time.Time `json:"record_date"` | 109 | Twitch string `json:"twitch"` |
| 91 | } | ||
| 92 | |||
| 93 | type RecordMP struct { | ||
| 94 | RecordID int `json:"record_id"` | ||
| 95 | Placement int `json:"placement"` | ||
| 96 | HostID string `json:"host_id"` | ||
| 97 | HostName string `json:"host_name"` | ||
| 98 | HostAvatar string `json:"host_avatar"` | ||
| 99 | PartnerID string `json:"partner_id"` | ||
| 100 | PartnerName string `json:"partner_name"` | ||
| 101 | PartnerAvatar string `json:"partner_avatar"` | ||
| 102 | ScoreCount int `json:"score_count"` | ||
| 103 | ScoreTime int `json:"score_time"` | ||
| 104 | HostDemoID string `json:"host_demo_id"` | ||
| 105 | PartnerDemoID string `json:"partner_demo_id"` | ||
| 106 | RecordDate time.Time `json:"record_date"` | ||
| 107 | } | 110 | } |
| 108 | 111 | ||
| 109 | type PlayerSummaries struct { | 112 | type PlayerSummaries struct { |
diff --git a/backend/models/requests.go b/backend/models/requests.go deleted file mode 100644 index 0113597..0000000 --- a/backend/models/requests.go +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | package models | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "mime/multipart" | ||
| 5 | "time" | ||
| 6 | ) | ||
| 7 | |||
| 8 | type CreateMapSummaryRequest struct { | ||
| 9 | CategoryID int `json:"category_id" binding:"required"` | ||
| 10 | Description string `json:"description" binding:"required"` | ||
| 11 | Showcase string `json:"showcase"` | ||
| 12 | UserName string `json:"user_name" binding:"required"` | ||
| 13 | ScoreCount *int `json:"score_count" binding:"required"` | ||
| 14 | RecordDate time.Time `json:"record_date" binding:"required"` | ||
| 15 | } | ||
| 16 | |||
| 17 | type EditMapSummaryRequest struct { | ||
| 18 | RouteID int `json:"route_id" binding:"required"` | ||
| 19 | Description string `json:"description" binding:"required"` | ||
| 20 | Showcase string `json:"showcase"` | ||
| 21 | UserName string `json:"user_name" binding:"required"` | ||
| 22 | ScoreCount *int `json:"score_count" binding:"required"` | ||
| 23 | RecordDate time.Time `json:"record_date" binding:"required"` | ||
| 24 | } | ||
| 25 | |||
| 26 | type DeleteMapSummaryRequest struct { | ||
| 27 | RouteID int `json:"route_id" binding:"required"` | ||
| 28 | } | ||
| 29 | |||
| 30 | type EditMapImageRequest struct { | ||
| 31 | Image string `json:"image" binding:"required"` | ||
| 32 | } | ||
| 33 | |||
| 34 | type RecordRequest struct { | ||
| 35 | HostDemo *multipart.FileHeader `json:"host_demo" form:"host_demo" binding:"required" swaggerignore:"true"` | ||
| 36 | PartnerDemo *multipart.FileHeader `json:"partner_demo" form:"partner_demo" swaggerignore:"true"` | ||
| 37 | IsPartnerOrange bool `json:"is_partner_orange" form:"is_partner_orange"` | ||
| 38 | PartnerID string `json:"partner_id" form:"partner_id"` | ||
| 39 | } | ||
diff --git a/backend/models/responses.go b/backend/models/responses.go deleted file mode 100644 index 459911c..0000000 --- a/backend/models/responses.go +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 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 MapSummaryResponse struct { | ||
| 34 | Map Map `json:"map"` | ||
| 35 | Summary MapSummary `json:"summary"` | ||
| 36 | } | ||
| 37 | |||
| 38 | type SearchResponse struct { | ||
| 39 | Players []UserShort `json:"players"` | ||
| 40 | Maps []MapShort `json:"maps"` | ||
| 41 | } | ||
| 42 | |||
| 43 | type ChaptersResponse struct { | ||
| 44 | Game Game `json:"game"` | ||
| 45 | Chapters []Chapter `json:"chapters"` | ||
| 46 | } | ||
| 47 | |||
| 48 | type ChapterMapsResponse struct { | ||
| 49 | Chapter Chapter `json:"chapter"` | ||
| 50 | Maps []MapShort `json:"maps"` | ||
| 51 | } | ||
| 52 | |||
| 53 | type RecordResponse struct { | ||
| 54 | ScoreCount int `json:"score_count"` | ||
| 55 | ScoreTime int `json:"score_time"` | ||
| 56 | } | ||
| 57 | |||
| 58 | func ErrorResponse(message string) Response { | ||
| 59 | return Response{ | ||
| 60 | Success: false, | ||
| 61 | Message: message, | ||
| 62 | Data: nil, | ||
| 63 | } | ||
| 64 | } | ||