diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-01-06 23:55:12 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2023-01-06 23:55:12 +0300 |
| commit | 4820c7696db3c54959258b1a5b00c77e1246cbd7 (patch) | |
| tree | 179edfca03618395939df1c3afccf2c90c64d424 /backend/models | |
| parent | (#20) successful integration of demo upload to drive (diff) | |
| download | lphub-4820c7696db3c54959258b1a5b00c77e1246cbd7.tar.gz lphub-4820c7696db3c54959258b1a5b00c77e1246cbd7.tar.bz2 lphub-4820c7696db3c54959258b1a5b00c77e1246cbd7.zip | |
what the fuck is this mess (#21)
Diffstat (limited to 'backend/models')
| -rw-r--r-- | backend/models/models.go | 25 | ||||
| -rw-r--r-- | backend/models/responses.go | 27 |
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 | |||
| 3 | import "time" | 3 | import "time" |
| 4 | 4 | ||
| 5 | type User struct { | 5 | type 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 | |||
| 15 | func (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 @@ | |||
| 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 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 | |||
| 21 | func ErrorResponse(message string) Response { | ||
| 22 | return Response{ | ||
| 23 | Success: false, | ||
| 24 | Message: message, | ||
| 25 | Data: nil, | ||
| 26 | } | ||
| 27 | } | ||