feat: better API returns, asset update

This commit is contained in:
2024-01-21 01:02:40 -06:00
parent a8ee837dee
commit b2c8c2915f
7 changed files with 93 additions and 10 deletions

View File

@@ -26,6 +26,11 @@ type IndexResponse struct {
Version APIVersion `json:"version"`
}
type CountResponse struct {
*Response
Count int64 `json:"count"`
}
type APIError struct {
*Response
Err error `json:"-"`

View File

@@ -14,7 +14,7 @@ import (
type Building struct {
ID uint64 `gorm:"primarykey" json:"id"`
Name string `json:"name"`
ShelfLocations []ShelfLocation `json:"shelves"`
ShelfLocations []ShelfLocation `json:"shelves,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

View File

@@ -17,7 +17,7 @@ type ShelfLocation struct {
RoomNumber string `json:"room_number,omitempty"`
Description string `json:"description,omitempty"`
BuildingID uint64 `json:"-"`
Building Building `json:"building"`
Building Building `json:"building",omitempty`
Assets []Asset `json:"assets,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`