mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-17 06:08:42 +00:00
32 lines
916 B
Go
32 lines
916 B
Go
package mappers
|
|
|
|
import (
|
|
"github.com/hay-kot/content/backend/ent"
|
|
"github.com/hay-kot/content/backend/internal/types"
|
|
)
|
|
|
|
func ToLocationSummary(location *ent.Location) *types.LocationSummary {
|
|
return &types.LocationSummary{
|
|
ID: location.ID,
|
|
GroupID: location.Edges.Group.ID,
|
|
Name: location.Name,
|
|
Description: location.Description,
|
|
CreatedAt: location.CreatedAt,
|
|
UpdatedAt: location.UpdatedAt,
|
|
}
|
|
}
|
|
|
|
func ToLocationSummaryErr(location *ent.Location, err error) (*types.LocationSummary, error) {
|
|
return ToLocationSummary(location), err
|
|
}
|
|
|
|
func ToLocationOut(location *ent.Location) *types.LocationOut {
|
|
return &types.LocationOut{
|
|
LocationSummary: *ToLocationSummary(location),
|
|
Items: MapEach(location.Edges.Items, ToItemSummary),
|
|
}
|
|
}
|
|
|
|
func ToLocationOutErr(location *ent.Location, err error) (*types.LocationOut, error) {
|
|
return ToLocationOut(location), err
|
|
}
|