37 lines
959 B
Go
37 lines
959 B
Go
package apimodel
|
|
|
|
import (
|
|
"gitea.dwysokinski.me/twhelp/corev3/internal/domain"
|
|
)
|
|
|
|
func NewEnnoblement(withRelations domain.EnnoblementWithRelations) Ennoblement {
|
|
e := withRelations.Ennoblement()
|
|
return Ennoblement{
|
|
CreatedAt: e.CreatedAt(),
|
|
Id: e.ID(),
|
|
Points: e.Points(),
|
|
Village: NewVillageMeta(
|
|
withRelations.Village().WithRelations(withRelations.OldOwner().WithRelations(withRelations.OldTribe())),
|
|
),
|
|
NewOwner: NewNullPlayerMeta(withRelations.NewOwner().WithRelations(withRelations.NewTribe())),
|
|
}
|
|
}
|
|
|
|
func NewListEnnoblementsResponse(res domain.ListEnnoblementsWithRelationsResult) ListEnnoblementsResponse {
|
|
ennoblements := res.Ennoblements()
|
|
|
|
resp := ListEnnoblementsResponse{
|
|
Data: make([]Ennoblement, 0, len(ennoblements)),
|
|
Cursor: Cursor{
|
|
Next: res.Next().Encode(),
|
|
Self: res.Self().Encode(),
|
|
},
|
|
}
|
|
|
|
for _, e := range ennoblements {
|
|
resp.Data = append(resp.Data, NewEnnoblement(e))
|
|
}
|
|
|
|
return resp
|
|
}
|