mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-21 22:36:31 +00:00
31b34241e0
* change /content/ -> /homebox/ * add cache to code generators * update env variables to set data storage * update env variables * set env variables in prod container * implement attachment post route (WIP) * get attachment endpoint * attachment download * implement string utilities lib * implement generic drop zone * use explicit truncate * remove clean dir * drop strings composable for lib * update item types and add attachments * add attachment API * implement service context * consolidate API code * implement editing attachments * implement upload limit configuration * improve error handling * add docs for max upload size * fix test cases
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package mappers
|
|
|
|
import (
|
|
"github.com/hay-kot/homebox/backend/ent"
|
|
"github.com/hay-kot/homebox/backend/internal/repo"
|
|
"github.com/hay-kot/homebox/backend/internal/types"
|
|
)
|
|
|
|
func ToLocationCount(location *repo.LocationWithCount) *types.LocationCount {
|
|
return &types.LocationCount{
|
|
LocationSummary: types.LocationSummary{
|
|
ID: location.ID,
|
|
Name: location.Name,
|
|
Description: location.Description,
|
|
CreatedAt: location.CreatedAt,
|
|
UpdatedAt: location.UpdatedAt,
|
|
},
|
|
ItemCount: location.ItemCount,
|
|
}
|
|
}
|
|
|
|
func ToLocationCountErr(location *repo.LocationWithCount, err error) (*types.LocationCount, error) {
|
|
return ToLocationCount(location), err
|
|
}
|
|
|
|
func ToLocationSummary(location *ent.Location) *types.LocationSummary {
|
|
return &types.LocationSummary{
|
|
ID: location.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: types.LocationSummary{
|
|
ID: location.ID,
|
|
Name: location.Name,
|
|
Description: location.Description,
|
|
CreatedAt: location.CreatedAt,
|
|
UpdatedAt: location.UpdatedAt,
|
|
},
|
|
Items: MapEach(location.Edges.Items, ToItemSummary),
|
|
}
|
|
}
|
|
|
|
func ToLocationOutErr(location *ent.Location, err error) (*types.LocationOut, error) {
|
|
return ToLocationOut(location), err
|
|
}
|