Closes #229 This is a MVP and only includes maps. Reviewed-on: #253 Reviewed-by: itzaname <itzaname@noreply@itzana.me> Co-authored-by: Rhys Lloyd <krakow20@gmail.com> Co-committed-by: Rhys Lloyd <krakow20@gmail.com>
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package dto
|
|
|
|
import (
|
|
"git.itzana.me/strafesnet/go-grpc/maps_extended"
|
|
"time"
|
|
)
|
|
|
|
type MapFilter struct {
|
|
GameID *uint32 `json:"game_id" form:"game_id"`
|
|
} // @name MapFilter
|
|
|
|
type Map struct {
|
|
ID int64 `json:"id"`
|
|
DisplayName string `json:"display_name"`
|
|
Creator string `json:"creator"`
|
|
GameID uint32 `json:"game_id"`
|
|
Date time.Time `json:"date"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Submitter uint64 `json:"submitter"`
|
|
Thumbnail uint64 `json:"thumbnail"`
|
|
AssetVersion uint64 `json:"asset_version"`
|
|
LoadCount uint32 `json:"load_count"`
|
|
Modes uint32 `json:"modes"`
|
|
} // @name Map
|
|
|
|
// FromGRPC converts a maps.MapResponse protobuf message to a Map domain object
|
|
func (m *Map) FromGRPC(resp *maps_extended.MapResponse) *Map {
|
|
if resp == nil {
|
|
return nil
|
|
}
|
|
|
|
m.ID = resp.ID
|
|
m.DisplayName = resp.DisplayName
|
|
m.Creator = resp.Creator
|
|
m.Date = time.Unix(resp.Date, 0)
|
|
m.GameID = resp.GameID
|
|
m.CreatedAt = time.Unix(resp.CreatedAt, 0)
|
|
m.UpdatedAt = time.Unix(resp.UpdatedAt, 0)
|
|
m.Submitter = resp.Submitter
|
|
m.Thumbnail = resp.Thumbnail
|
|
m.AssetVersion = resp.AssetVersion
|
|
m.LoadCount = resp.LoadCount
|
|
m.Modes = resp.Modes
|
|
|
|
return m
|
|
}
|