aboutsummaryrefslogtreecommitdiff
path: root/backend/models
diff options
context:
space:
mode:
Diffstat (limited to 'backend/models')
-rw-r--r--backend/models/models.go25
-rw-r--r--backend/models/responses.go27
2 files changed, 33 insertions, 19 deletions
diff --git a/backend/models/models.go b/backend/models/models.go
index 2be8765..c49eaeb 100644
--- a/backend/models/models.go
+++ b/backend/models/models.go
@@ -3,23 +3,10 @@ package models
3import "time" 3import "time"
4 4
5type User struct { 5type User struct {
6 SteamID string 6 SteamID string `json:"steam_id"`
7 Username string 7 Username string `json:"username"`
8 AvatarLink string 8 AvatarLink string `json:"avatar_link"`
9 CountryCode string 9 CountryCode string `json:"country_code"`
10 CreatedAt time.Time 10 CreatedAt time.Time `json:"created_at"`
11 UpdatedAt time.Time 11 UpdatedAt time.Time `json:"updated_at"`
12 UserType int16
13}
14
15func (user *User) TypeToString() []string {
16 var list []string
17 switch user.UserType {
18 case 0:
19 list = append(list, "Normal")
20 }
21 if len(list) == 0 {
22 list = append(list, "Unknown")
23 }
24 return list
25} 12}
diff --git a/backend/models/responses.go b/backend/models/responses.go
new file mode 100644
index 0000000..70ee1b6
--- /dev/null
+++ b/backend/models/responses.go
@@ -0,0 +1,27 @@
1package models
2
3type Response struct {
4 Success bool `json:"success"`
5 Message string `json:"message"`
6 Data any `json:"data"`
7}
8
9type LoginResponse struct {
10 Token string `json:"token"`
11}
12
13type ProfileResponse struct {
14 Profile bool `json:"profile"`
15 SteamID string `json:"steam_id"`
16 Username string `json:"username"`
17 AvatarLink string `json:"avatar_link"`
18 CountryCode string `json:"country_code"`
19}
20
21func ErrorResponse(message string) Response {
22 return Response{
23 Success: false,
24 Message: message,
25 Data: nil,
26 }
27}