-
Notifications
You must be signed in to change notification settings - Fork 0
/
repository.go
47 lines (40 loc) · 1.77 KB
/
repository.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
package repository
import (
"context"
"github.com/hoangtk0100/dc-go-23/ex_07/pkg/model"
)
type Repository interface {
Product() ProductRepository
Cart() CartRepository
Payment() PaymentRepository
User() UserRepository
}
type ProductRepository interface {
Create(ctx context.Context, data *model.Product) (*model.Product, error)
Update(ctx context.Context, id int64, data *model.Product) (*model.Product, error)
DeleteByID(ctx context.Context, id int64) error
GetByID(ctx context.Context, id int64) (*model.Product, error)
GetByCode(ctx context.Context, code string) (*model.Product, error)
GetBySlug(ctx context.Context, slug string) (*model.Product, error)
GetAll(ctx context.Context) ([]model.Product, error)
}
type CartRepository interface {
CreateItem(ctx context.Context, data *model.CartItem) (*model.CartItem, error)
UpdateItem(ctx context.Context, data *model.CartItem) (*model.CartItem, error)
DeleteItem(ctx context.Context, cartID int64, prodID int64) error
GetItem(ctx context.Context, cartID int64, prodID int64) (*model.CartItem, error)
GetItems(ctx context.Context, cartID int64) ([]model.CartItem, error)
Create(ctx context.Context, username string, code string) (*model.Cart, error)
Update(ctx context.Context, data *model.Cart) (*model.Cart, error)
Delete(ctx context.Context, id int64) error
GetByID(ctx context.Context, id int64) (*model.Cart, error)
GetByCode(ctx context.Context, code string) (*model.Cart, error)
GetActiveCart(ctx context.Context) (*model.Cart, error)
}
type PaymentRepository interface {
Create(ctx context.Context, data *model.Payment) (*model.Payment, error)
}
type UserRepository interface {
GetByUsername(ctx context.Context, username string) (*model.User, error)
Create(ctx context.Context, data *model.User) (*model.User, error)
}