Initial commit
CI / test (push) Canceled after 0s

This commit is contained in:
2026-09-12 22:22:17 +02:00
commit 904d14b64c
314 changed files with 31884 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package storage
import (
"strings"
"time"
"gardomatic.kleiax.de/internal/platform/validate"
)
// GardenModelInterface persists gardens and their initial owner membership.
type GardenModelInterface interface {
Insert(garden Garden, ownerID int) (Garden, error)
Get(id int) (Garden, error)
GetAllForUser(userID int) ([]Garden, error)
Update(garden Garden) (Garden, error)
Delete(id int) error
}
// Garden is the tenant boundary for garden-specific resources.
type Garden struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ImageData string `json:"image_data,omitempty"`
ImageID *int `json:"image_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Version int `json:"version"`
Role GardenRole `json:"role,omitempty"`
Permissions []GardenPermission `json:"permissions"`
}
// ValidateGarden applies persistence-independent garden validation rules.
func ValidateGarden(v *validate.Validator, garden Garden) {
v.Check(strings.TrimSpace(garden.Name) != "", "name", "must be provided")
v.Check(len(garden.Name) <= 500, "name", "must not be more than 500 bytes long")
v.Check(len(garden.Description) <= 5000, "description", "must not be more than 5000 bytes long")
}