aboutsummaryrefslogtreecommitdiff
path: root/backend/models/models.go
blob: 8f77a93b1c5bcebccd5aa88b8a564683ce366f5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package models

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"`
	AvatarLink  string    `json:"avatar_link"`
	CountryCode string    `json:"country_code"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type Map struct {
	ID          int    `json:"id"`
	GameName    string `json:"game_name"`
	ChapterName string `json:"chapter_name"`
	MapName     string `json:"map_name"`
	Data        any    `json:"data"`
}

type MapSummary struct {
	Description    string            `json:"description"`
	Showcase       string            `json:"showcase"`
	CategoryScores MapCategoryScores `json:"category_scores"`
	Rating         float32           `json:"rating"`
	Routers        []string          `json:"routers"`
	History        []MapHistory      `json:"history"`
}

type MapCategoryScores struct {
	CM          int `json:"cm"`
	NoSLA       int `json:"no_sla"`
	InboundsSLA int `json:"inbounds_sla"`
	Any         int `json:"any"`
}

type MapRecords struct {
	Records any `json:"records"`
}

type MapHistory struct {
	RunnerName string    `json:"runner_name"`
	ScoreCount int       `json:"score_count"`
	Date       time.Time `json:"date"`
}

type RecordSP struct {
	RecordID   int       `json:"record_id"`
	Placement  int       `json:"placement"`
	UserID     string    `json:"user_id"`
	UserName   string    `json:"user_name"`
	UserAvatar string    `json:"user_avatar"`
	ScoreCount int       `json:"score_count"`
	ScoreTime  int       `json:"score_time"`
	DemoID     string    `json:"demo_id"`
	RecordDate time.Time `json:"record_date"`
}

type RecordMP struct {
	RecordID      int       `json:"record_id"`
	Placement     int       `json:"placement"`
	HostID        string    `json:"host_id"`
	HostName      string    `json:"host_name"`
	HostAvatar    string    `json:"host_avatar"`
	PartnerID     string    `json:"partner_id"`
	PartnerName   string    `json:"partner_name"`
	PartnerAvatar string    `json:"partner_avatar"`
	ScoreCount    int       `json:"score_count"`
	ScoreTime     int       `json:"score_time"`
	HostDemoID    string    `json:"host_demo_id"`
	PartnerDemoID string    `json:"partner_demo_id"`
	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"`
	ProfileState             int    `json:"profilestate"`
	PersonaName              string `json:"personaname"`
	LastLogOff               int    `json:"lastlogoff"`
	ProfileUrl               string `json:"profileurl"`
	Avatar                   string `json:"avatar"`
	AvatarMedium             string `json:"avatarmedium"`
	AvatarFull               string `json:"avatarfull"`
	PersonaState             int    `json:"personastate"`

	CommentPermission int    `json:"commentpermission"`
	RealName          string `json:"realname"`
	PrimaryClanId     string `json:"primaryclanid"`
	TimeCreated       int    `json:"timecreated"`
	LocCountryCode    string `json:"loccountrycode"`
	LocStateCode      string `json:"locstatecode"`
	LocCityId         int    `json:"loccityid"`
	GameId            int    `json:"gameid"`
	GameExtraInfo     string `json:"gameextrainfo"`
	GameServerIp      string `json:"gameserverip"`
}

type Game struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type Chapter struct {
	ID     int    `json:"id"`
	GameID int    `json:"game_id"`
	Name   string `json:"name"`
}

type MapShort struct {
	ID        int    `json:"id"`
	ChapterID int    `json:"chapter_id"`
	Name      string `json:"name"`
}

func ErrorResponse(message string) Response {
	return Response{
		Success: false,
		Message: message,
		Data:    nil,
	}
}