-
Notifications
You must be signed in to change notification settings - Fork 0
/
shop.go
52 lines (46 loc) · 1.35 KB
/
shop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package aumo
import "upper.io/db.v3/lib/sqlbuilder"
// Shop is a shop in aumo
type Shop struct {
ID uint `json:"id" db:"shop_id,omitempty"`
Name string `json:"name" db:"name"`
Image string `json:"image" db:"image"`
Owners []User `json:"owners,omitempty" db:"-"`
Products []Product `json:"products,omitempty" db:"-"`
}
// NewShop is a constructor for `Shop`
func NewShop(name, image string) *Shop {
return &Shop{
Name: name,
Image: image,
Owners: []User{},
}
}
// ShopService contains all `Shop`
// related business logic
type ShopService interface {
Shop(id uint, withOwners bool) (*Shop, error)
Shops() ([]Shop, error)
AddOwner(id uint, email string) error
RemoveOwner(id uint, email string) error
Update(id uint, o *Shop) error
Delete(id uint) error
Create(*Shop) error
}
// ShopStore contains all `Shop`
// related persistence logic
type ShopStore interface {
DB() sqlbuilder.Database
FindByID(tx Tx, id uint, relations bool) (*Shop, error)
FindAll(tx Tx) ([]Shop, error)
Save(tx Tx, s *Shop) error
Update(tx Tx, id uint, s *Shop) error
Delete(tx Tx, id uint) error
}
// ShopOwnersStore currently contains some "shop_owners table"
// related persistence logic
type ShopOwnersStore interface {
Save(tx Tx, sID uint, uID string) error
Delete(tx Tx, sID uint, uID string) error
DeleteByUser(tx Tx, uID string) error
}