forked from mirrors/homebox
location endpoints
This commit is contained in:
parent
9583847f94
commit
c7cfb4335b
10 changed files with 395 additions and 51 deletions
|
@ -24,6 +24,22 @@ func ToLocationOut(location *ent.Location, err error) (*types.LocationOut, error
|
|||
}, err
|
||||
}
|
||||
|
||||
func (svc *LocationService) GetAll(ctx context.Context, groupId uuid.UUID) ([]*types.LocationOut, error) {
|
||||
panic("not implemented")
|
||||
func (svc *LocationService) Create(ctx context.Context, groupId uuid.UUID, data types.LocationCreate) (*types.LocationOut, error) {
|
||||
location, err := svc.repos.Locations.Create(ctx, groupId, data)
|
||||
return ToLocationOut(location, err)
|
||||
}
|
||||
|
||||
func (svc *LocationService) GetAll(ctx context.Context, groupId uuid.UUID) ([]*types.LocationOut, error) {
|
||||
locations, err := svc.repos.Locations.GetAll(ctx, groupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
locationsOut := make([]*types.LocationOut, len(locations))
|
||||
for i, location := range locations {
|
||||
locationOut, _ := ToLocationOut(location, nil)
|
||||
locationsOut[i] = locationOut
|
||||
}
|
||||
|
||||
return locationsOut, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue