mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 14:04:08 +01:00
feat: add inventory status, category and units models
This commit is contained in:
parent
338733b12b
commit
10bb1a9475
@ -7,33 +7,41 @@ import (
|
|||||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InventoryStatus string
|
type InventoryStatus struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
type InventoryCategory struct {
|
||||||
StatusInStock InventoryStatus = "In Stock"
|
ID int `json:"id"`
|
||||||
StatusLowStock InventoryStatus = "Low Stock"
|
Name string `json:"name"`
|
||||||
StatusOutOfStock InventoryStatus = "Out of Stock"
|
}
|
||||||
)
|
|
||||||
|
type HarvestUnit struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
type InventoryItem struct {
|
type InventoryItem struct {
|
||||||
ID string
|
ID string
|
||||||
UserID string
|
UserID string
|
||||||
Name string
|
Name string
|
||||||
Category string
|
CategoryID int
|
||||||
Type string
|
Category InventoryCategory
|
||||||
Quantity float64
|
Quantity float64
|
||||||
Unit string
|
UnitID int
|
||||||
DateAdded time.Time
|
Unit HarvestUnit
|
||||||
Status InventoryStatus
|
DateAdded time.Time
|
||||||
CreatedAt time.Time
|
StatusID int
|
||||||
UpdatedAt time.Time
|
Status InventoryStatus
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type InventoryFilter struct {
|
type InventoryFilter struct {
|
||||||
UserID string
|
UserID string
|
||||||
Category string
|
CategoryID int
|
||||||
Type string
|
StatusID int
|
||||||
Status InventoryStatus
|
|
||||||
StartDate time.Time
|
StartDate time.Time
|
||||||
EndDate time.Time
|
EndDate time.Time
|
||||||
SearchQuery string
|
SearchQuery string
|
||||||
@ -48,11 +56,11 @@ func (i *InventoryItem) Validate() error {
|
|||||||
return validation.ValidateStruct(i,
|
return validation.ValidateStruct(i,
|
||||||
validation.Field(&i.UserID, validation.Required),
|
validation.Field(&i.UserID, validation.Required),
|
||||||
validation.Field(&i.Name, validation.Required),
|
validation.Field(&i.Name, validation.Required),
|
||||||
validation.Field(&i.Category, validation.Required),
|
validation.Field(&i.CategoryID, validation.Required),
|
||||||
validation.Field(&i.Type, validation.Required),
|
|
||||||
validation.Field(&i.Quantity, validation.Required, validation.Min(0.0)),
|
validation.Field(&i.Quantity, validation.Required, validation.Min(0.0)),
|
||||||
validation.Field(&i.Unit, validation.Required),
|
validation.Field(&i.UnitID, validation.Required),
|
||||||
validation.Field(&i.Status, validation.Required, validation.In(StatusInStock, StatusLowStock, StatusOutOfStock)),
|
validation.Field(&i.StatusID, validation.Required),
|
||||||
|
validation.Field(&i.DateAdded, validation.Required),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,4 +70,10 @@ type InventoryRepository interface {
|
|||||||
GetAll(ctx context.Context) ([]InventoryItem, error)
|
GetAll(ctx context.Context) ([]InventoryItem, error)
|
||||||
CreateOrUpdate(ctx context.Context, item *InventoryItem) error
|
CreateOrUpdate(ctx context.Context, item *InventoryItem) error
|
||||||
Delete(ctx context.Context, id, userID string) error
|
Delete(ctx context.Context, id, userID string) error
|
||||||
|
GetStatuses(ctx context.Context) ([]InventoryStatus, error)
|
||||||
|
GetCategories(ctx context.Context) ([]InventoryCategory, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type HarvestRepository interface {
|
||||||
|
GetUnits(ctx context.Context) ([]HarvestUnit, error)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user