mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-18 21:44: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"
|
||||
)
|
||||
|
||||
type InventoryStatus string
|
||||
type InventoryStatus struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
const (
|
||||
StatusInStock InventoryStatus = "In Stock"
|
||||
StatusLowStock InventoryStatus = "Low Stock"
|
||||
StatusOutOfStock InventoryStatus = "Out of Stock"
|
||||
)
|
||||
type InventoryCategory struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type HarvestUnit struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type InventoryItem struct {
|
||||
ID string
|
||||
UserID string
|
||||
Name string
|
||||
Category string
|
||||
Type string
|
||||
Quantity float64
|
||||
Unit string
|
||||
DateAdded time.Time
|
||||
Status InventoryStatus
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ID string
|
||||
UserID string
|
||||
Name string
|
||||
CategoryID int
|
||||
Category InventoryCategory
|
||||
Quantity float64
|
||||
UnitID int
|
||||
Unit HarvestUnit
|
||||
DateAdded time.Time
|
||||
StatusID int
|
||||
Status InventoryStatus
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type InventoryFilter struct {
|
||||
UserID string
|
||||
Category string
|
||||
Type string
|
||||
Status InventoryStatus
|
||||
CategoryID int
|
||||
StatusID int
|
||||
StartDate time.Time
|
||||
EndDate time.Time
|
||||
SearchQuery string
|
||||
@ -48,11 +56,11 @@ func (i *InventoryItem) Validate() error {
|
||||
return validation.ValidateStruct(i,
|
||||
validation.Field(&i.UserID, validation.Required),
|
||||
validation.Field(&i.Name, validation.Required),
|
||||
validation.Field(&i.Category, validation.Required),
|
||||
validation.Field(&i.Type, validation.Required),
|
||||
validation.Field(&i.CategoryID, validation.Required),
|
||||
validation.Field(&i.Quantity, validation.Required, validation.Min(0.0)),
|
||||
validation.Field(&i.Unit, validation.Required),
|
||||
validation.Field(&i.Status, validation.Required, validation.In(StatusInStock, StatusLowStock, StatusOutOfStock)),
|
||||
validation.Field(&i.UnitID, validation.Required),
|
||||
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)
|
||||
CreateOrUpdate(ctx context.Context, item *InventoryItem) 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