mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 14:04:08 +01:00
feat: add user to inventory domain
This commit is contained in:
parent
5a373b5f2b
commit
54c8fd433c
@ -17,6 +17,7 @@ const (
|
|||||||
|
|
||||||
type InventoryItem struct {
|
type InventoryItem struct {
|
||||||
ID string
|
ID string
|
||||||
|
UserID string
|
||||||
Name string
|
Name string
|
||||||
Category string
|
Category string
|
||||||
Type string
|
Type string
|
||||||
@ -29,6 +30,7 @@ type InventoryItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type InventoryFilter struct {
|
type InventoryFilter struct {
|
||||||
|
UserID string
|
||||||
Category string
|
Category string
|
||||||
Type string
|
Type string
|
||||||
Status InventoryStatus
|
Status InventoryStatus
|
||||||
@ -44,6 +46,7 @@ type InventorySort struct {
|
|||||||
|
|
||||||
func (i *InventoryItem) Validate() error {
|
func (i *InventoryItem) Validate() error {
|
||||||
return validation.ValidateStruct(i,
|
return validation.ValidateStruct(i,
|
||||||
|
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.Category, validation.Required),
|
||||||
validation.Field(&i.Type, validation.Required),
|
validation.Field(&i.Type, validation.Required),
|
||||||
@ -54,8 +57,9 @@ func (i *InventoryItem) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type InventoryRepository interface {
|
type InventoryRepository interface {
|
||||||
GetByID(ctx context.Context, id string) (InventoryItem, error)
|
GetByID(ctx context.Context, id, userID string) (InventoryItem, error)
|
||||||
GetWithFilter(ctx context.Context, filter InventoryFilter, sort InventorySort) ([]InventoryItem, error)
|
GetByUserID(ctx context.Context, userID string, filter InventoryFilter, sort InventorySort) ([]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 string) error
|
Delete(ctx context.Context, id, userID string) error
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user