order_controller.go
2.4 KB
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
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01-gateway/pkg/application/order/command"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01-gateway/pkg/application/order/query"
"gitlab.fjmaimaimai.com/mmm-go-pp/partner01-gateway/pkg/application/order/service"
)
type OrderController struct {
beego.BaseController
}
func (controller *OrderController) CreateOrder() {
orderService := service.NewOrderService(nil)
createOrderCommand := &command.CreateOrderCommand{}
controller.Unmarshal(createOrderCommand)
data, err := orderService.CreateOrder(createOrderCommand)
controller.Response(data, err)
}
func (controller *OrderController) UpdateOrder() {
orderService := service.NewOrderService(nil)
updateOrderCommand := &command.UpdateOrderCommand{}
_ = controller.Unmarshal(updateOrderCommand)
orderId, _ := controller.GetInt64(":orderId")
updateOrderCommand.OrderId = orderId
data, err := orderService.UpdateOrder(updateOrderCommand)
controller.Response(data, err)
}
func (controller *OrderController) GetOrder() {
orderService := service.NewOrderService(nil)
getOrderQuery := &query.GetOrderQuery{}
orderId, _ := controller.GetInt64(":orderId")
getOrderQuery.OrderId = orderId
data, err := orderService.GetOrder(getOrderQuery)
controller.Response(data, err)
}
func (controller *OrderController) RemoveOrder() {
orderService := service.NewOrderService(nil)
removeOrderCommand := &command.RemoveOrderCommand{}
_ = controller.Unmarshal(removeOrderCommand)
orderId, _ := controller.GetInt64(":orderId")
removeOrderCommand.OrderId = orderId
data, err := orderService.RemoveOrder(removeOrderCommand)
controller.Response(data, err)
}
func (controller *OrderController) ListOrder() {
orderService := service.NewOrderService(nil)
listOrderQuery := &query.ListOrderQuery{}
offset, _ := controller.GetInt("offset")
listOrderQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listOrderQuery.Limit = limit
data, err := orderService.ListOrder(listOrderQuery)
controller.Response(data, err)
}
func (controller *OrderController) Shipping() {
orderService := service.NewOrderService(nil)
shippingCmd := &command.ShippingGoodsCommand{}
_ = controller.Unmarshal(shippingCmd)
orderId, _ := controller.GetInt(":orderId")
shippingCmd.OrderId = orderId
data, err := orderService.ShippingGoods(shippingCmd)
controller.Response(data, err)
}