50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package dto
|
|
|
|
import (
|
|
"git.itzana.me/strafesnet/go-grpc/ranks"
|
|
"time"
|
|
)
|
|
|
|
// RankFilter represents the filter criteria for retrieving rank information
|
|
type RankFilter struct {
|
|
StyleID int32 `json:"style_id" form:"style_id"`
|
|
GameID int32 `json:"game_id" form:"game_id"`
|
|
ModeID int32 `json:"mode_id" form:"mode_id"`
|
|
} // @name RankFilter
|
|
|
|
// Rank represents a player's rank information in the system
|
|
type Rank struct {
|
|
ID int64 `json:"id"`
|
|
User User `json:"user"`
|
|
StyleID int32 `json:"style_id"`
|
|
ModeID int32 `json:"mode_id"`
|
|
GameID int32 `json:"game_id"`
|
|
Rank float64 `json:"rank"`
|
|
Skill float64 `json:"skill"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
} // @name Rank
|
|
|
|
// FromGRPC converts a RankMessage from gRPC to a Rank DTO
|
|
func (r *Rank) FromGRPC(grpcRank *ranks.RankMessage) *Rank {
|
|
if grpcRank == nil {
|
|
return nil
|
|
}
|
|
|
|
rank := &Rank{
|
|
ID: grpcRank.ID,
|
|
StyleID: grpcRank.StyleID,
|
|
ModeID: grpcRank.ModeID,
|
|
GameID: grpcRank.GameID,
|
|
Rank: grpcRank.Rank,
|
|
Skill: grpcRank.Skill,
|
|
UpdatedAt: time.Unix(grpcRank.UpdatedAt, 0),
|
|
}
|
|
|
|
if grpcRank.User != nil {
|
|
var user User
|
|
rank.User = *user.FromGRPC(grpcRank.User)
|
|
}
|
|
|
|
return rank
|
|
}
|