From b960100d246a2c54778dc3501599adb1d7e4b224 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 17 Jun 2023 17:26:46 +0300 Subject: fix: reorganize models (#44) --- backend/models/models.go | 113 +++++++++++------------------------------------ 1 file changed, 26 insertions(+), 87 deletions(-) (limited to 'backend/models/models.go') 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 ( "time" ) -type Response struct { - Success bool `json:"success"` - Message string `json:"message"` - Data any `json:"data"` -} - -type LoginResponse struct { - Token string `json:"token"` -} - type User struct { SteamID string `json:"steam_id"` UserName string `json:"user_name"` @@ -23,6 +13,11 @@ type User struct { UpdatedAt time.Time `json:"updated_at"` } +type UserShort struct { + SteamID string `json:"steam_id"` + UserName string `json:"user_name"` +} + type Map struct { ID int `json:"id"` GameName string `json:"game_name"` @@ -31,6 +26,11 @@ type Map struct { Data any `json:"data"` } +type MapShort struct { + ID int `json:"id"` + Name string `json:"name"` +} + type MapSummary struct { Description string `json:"description"` Showcase string `json:"showcase"` @@ -57,6 +57,22 @@ type MapHistory struct { Date time.Time `json:"date"` } +type UserRanking struct { + UserID string `json:"user_id"` + UserName string `json:"user_name"` + TotalScore int `json:"total_score"` +} + +type Game struct { + ID int `json:"id"` + Name string `json:"name"` +} + +type Chapter struct { + ID int `json:"id"` + Name string `json:"name"` +} + type RecordSP struct { RecordID int `json:"record_id"` Placement int `json:"placement"` @@ -85,50 +101,6 @@ type RecordMP struct { RecordDate time.Time `json:"record_date"` } -type RecordRequest struct { - ScoreCount int `json:"score_count" form:"score_count" binding:"required"` - ScoreTime int `json:"score_time" form:"score_time" binding:"required"` - PartnerID string `json:"partner_id" form:"partner_id" binding:"required"` - IsPartnerOrange bool `json:"is_partner_orange" form:"is_partner_orange" binding:"required"` -} - -type UserRanking struct { - UserID string `json:"user_id"` - UserName string `json:"user_name"` - TotalScore int `json:"total_score"` -} - -type RankingsResponse struct { - RankingsSP []UserRanking `json:"rankings_sp"` - RankingsMP []UserRanking `json:"rankings_mp"` -} - -type ProfileResponse struct { - Profile bool `json:"profile"` - SteamID string `json:"steam_id"` - UserName string `json:"user_name"` - AvatarLink string `json:"avatar_link"` - CountryCode string `json:"country_code"` - ScoresSP []ScoreResponse `json:"scores_sp"` - ScoresMP []ScoreResponse `json:"scores_mp"` -} - -type ScoreResponse struct { - MapID int `json:"map_id"` - Records any `json:"records"` -} - -type SearchResponse struct { - Players []struct { - SteamID string `json:"steam_id"` - UserName string `json:"user_name"` - } `json:"players"` - Maps []struct { - ID int `json:"id"` - Name string `json:"name"` - } `json:"maps"` -} - type PlayerSummaries struct { SteamId string `json:"steamid"` CommunityVisibilityState int `json:"communityvisibilitystate"` @@ -152,36 +124,3 @@ type PlayerSummaries struct { GameExtraInfo string `json:"gameextrainfo"` GameServerIp string `json:"gameserverip"` } - -type Game struct { - ID int `json:"id"` - Name string `json:"name"` -} - -type ChaptersResponse struct { - Game Game `json:"game"` - Chapters []Chapter `json:"chapters"` -} - -type Chapter struct { - ID int `json:"id"` - Name string `json:"name"` -} - -type MapShort struct { - ID int `json:"id"` - Name string `json:"name"` -} - -type ChapterMapsResponse struct { - Chapter Chapter `json:"chapter"` - Maps []MapShort `json:"maps"` -} - -func ErrorResponse(message string) Response { - return Response{ - Success: false, - Message: message, - Data: nil, - } -} -- cgit v1.2.3