generated from VLADIMIR/template
44 lines
914 B
Go
44 lines
914 B
Go
package app
|
|
|
|
import (
|
|
"evening_detective_server/internal/services/game_service"
|
|
"evening_detective_server/proto"
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
)
|
|
|
|
func mapGame(
|
|
o *game_service.Game,
|
|
) *proto.Game {
|
|
var startedAt *timestamppb.Timestamp
|
|
if o.StartedAt != nil {
|
|
startedAt = timestamppb.New(*o.StartedAt)
|
|
}
|
|
var endedAt *timestamppb.Timestamp
|
|
if o.EndedAt != nil {
|
|
endedAt = timestamppb.New(*o.EndedAt)
|
|
}
|
|
|
|
return &proto.Game{
|
|
Id: int32(o.ID),
|
|
Name: o.Name,
|
|
Description: o.Description,
|
|
StartAt: timestamppb.New(o.StartAt),
|
|
Status: o.Status,
|
|
Scenario: mapScenario(o.Scenario),
|
|
Teams: mapTeams(o.Teams),
|
|
StartedAt: startedAt,
|
|
EndedAt: endedAt,
|
|
}
|
|
}
|
|
|
|
func mapGames(
|
|
o []*game_service.Game,
|
|
) []*proto.Game {
|
|
res := make([]*proto.Game, 0, len(o))
|
|
for _, item := range o {
|
|
res = append(res, mapGame(item))
|
|
}
|
|
return res
|
|
}
|