feat: Add name field to storage space and create dedicated storage page
This commit is contained in:
parent
699dca3328
commit
9d2f8e27c5
6 changed files with 255 additions and 115 deletions
|
@ -43,6 +43,7 @@ func (h *StorageHandler) GetStorageSpaces(c echo.Context) error {
|
|||
"id": space.ID,
|
||||
"parent": space.Parent,
|
||||
"location": space.Location,
|
||||
"name": space.Name,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,6 +192,7 @@ func (h *StorageHandler) CreateStorageSpace(c echo.Context) error {
|
|||
|
||||
// Parse request body
|
||||
type StorageSpaceRequest struct {
|
||||
Name string `json:"name"`
|
||||
Location string `json:"location"`
|
||||
Parent *struct {
|
||||
Valid bool `json:"valid"`
|
||||
|
@ -234,10 +236,18 @@ func (h *StorageHandler) CreateStorageSpace(c echo.Context) error {
|
|||
location.String = req.Location
|
||||
}
|
||||
|
||||
// Convert name to sql.NullString
|
||||
var name sql.NullString
|
||||
if req.Name != "" {
|
||||
name.Valid = true
|
||||
name.String = req.Name
|
||||
}
|
||||
|
||||
// Create storage space
|
||||
err := h.db.CreateStorageSpace(ctx, db.CreateStorageSpaceParams{
|
||||
Parent: parent,
|
||||
Location: location,
|
||||
Name: name,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue