You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
1.2 KiB

package models
import "context"
type Item struct {
ID string `json:"id" db:"item_id"`
UserID string `json:"-" db:"user_id"`
GroupID string `json:"groupId" db:"group_id"`
GroupWeight int `json:"groupWeight" db:"group_weight"`
Icon string `json:"icon" db:"icon"`
Name string `json:"name" db:"name"`
Description string `json:"description" db:"description"`
}
func (item *Item) Update(update ItemUpdate) {
if update.GroupWeight != nil {
item.GroupWeight = *update.GroupWeight
}
if update.Name != nil {
item.Name = *update.Name
}
if update.Description != nil {
item.Description = *update.Description
}
}
type ItemUpdate struct {
GroupWeight *int `json:"groupWeight"`
Name *string `json:"name"`
Description *string `json:"description"`
}
type ItemResult struct {
Item
Group *Group `json:"group"`
}
type ItemFilter struct {
UserID string
IDs []string
GroupIDs []string
}
type ItemRepository interface {
Find(ctx context.Context, id string) (*Item, error)
List(ctx context.Context, filter ItemFilter) ([]*Item, error)
Insert(ctx context.Context, item Item) error
Update(ctx context.Context, item Item) error
Delete(ctx context.Context, item Item) error
}