@@ -0,0 +1,35 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gardomatic.kleiax.de/internal/platform/validate"
|
||||
)
|
||||
|
||||
// TaskPriorityModelInterface manages the application-wide priority catalogue.
|
||||
type TaskPriorityModelInterface interface {
|
||||
Insert(priority TaskPriority) (TaskPriority, error)
|
||||
Get(id int) (TaskPriority, error)
|
||||
GetAll() ([]TaskPriority, error)
|
||||
Update(priority TaskPriority) (TaskPriority, error)
|
||||
}
|
||||
|
||||
// TaskPriority maps a user-facing label to the numeric value stored on tasks.
|
||||
type TaskPriority struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Value int `json:"value"`
|
||||
SortOrder int `json:"sort_order"`
|
||||
Active bool `json:"active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Version int `json:"version"`
|
||||
}
|
||||
|
||||
// ValidateTaskPriority applies catalogue-entry validation rules.
|
||||
func ValidateTaskPriority(v *validate.Validator, priority TaskPriority) {
|
||||
v.Check(strings.TrimSpace(priority.Name) != "", "name", "must be provided")
|
||||
v.Check(len(priority.Name) <= 100, "name", "must not be more than 100 bytes long")
|
||||
v.Check(priority.Value >= -100 && priority.Value <= 100, "value", "must be between -100 and 100")
|
||||
}
|
||||
Reference in New Issue
Block a user