/
example.go
87 lines (79 loc) · 2.26 KB
/
example.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package cart
/*
func ExampleCart() *[]Cart {
e := Cart{
ItemId: "f6d655da-6fff-11ee-b3bc-e86a6465f38b",
Quantity: 1,
ItemProperties: CartItemPreviewProperties{
Name: "クラウディ・エンチャント",
Price: 2000,
Details: CartItemPreviewDetails{
Status: CartItemStatusAvailable,
},
},
}
re := new([]Cart)
cart := append(*re, e)
return &cart
}
type ExapleCartRequest struct {
}
func (p ExapleCartRequest) Get(ctx *gin.Context, i IcartRepository, UserId string) (*[]Cart, error) {
Cart := ExampleCart()
return Cart, nil
}
func (c ExapleCartRequest) Register(p CartRequestPayload, i IcartRepository, ctx *gin.Context) error {
log.Print("CartRequestPayload: ", p)
if p.Quantity <= 0 {
return &utils.InternalError{Message: utils.InternalErrorInvalidQuantity}
}
return nil
}
func (c ExapleCartRequest) Delete(itemId string, ctx *gin.Context) error {
log.Print("itemId: ", itemId)
return nil
}
func (c ExapleCartRequest) GetItem(itemid string) (*itemStatus, error) {
return nil, nil
}
*/
/* type ExamplecartRepository struct {
ItemStatus *itemStatus
InternalCarts *[]InternalCart
ItemSelectError error
SelectError error
UpdateError error
RegisterError error
DeleteError error
}
func (c ExamplecartRepository) GetItem(itemId string) (*itemStatus, error) {
if c.ItemSelectError != nil {
return nil, &utils.InternalError{Message: utils.InternalErrorNotFound}
}
return c.ItemStatus, nil
}
func (c ExamplecartRepository) GetCart(UserId string) (*[]InternalCart, error) {
if c.SelectError != nil {
return nil, &utils.InternalError{Message: utils.InternalErrorMessage(c.SelectError.Error())}
}
return c.InternalCarts, nil
}
func (c ExamplecartRepository) RegisterCart(UserId string, CartRequestPayload CartRequestPayload) error {
if c.RegisterError != nil {
return c.RegisterError
}
return nil
}
func (c ExamplecartRepository) UpdateCart(UserId string, CartRequestPayload CartRequestPayload) error {
if c.UpdateError != nil {
return &utils.InternalError{Message: utils.InternalErrorDB}
}
return nil
}
func (c ExamplecartRepository) DeleteCart(UserId string, itemId string) error {
if c.DeleteError != nil {
return &utils.InternalError{Message: utils.InternalErrorDB}
}
return nil
}
*/