|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
common "git.mashibing.com/msb_47094/shopping-comm"
|
|
|
|
"trade-order/domain/service"
|
|
|
|
"trade-order/proto"
|
|
|
|
)
|
|
|
|
|
|
|
|
type TradeOrderHandler struct {
|
|
|
|
TradeOrderService service.ITradeOrderService
|
|
|
|
}
|
|
|
|
|
|
|
|
// 新增购物车
|
|
|
|
func (u *TradeOrderHandler) AddTradeOrder(ctx context.Context, req *proto.AddTradeOrderReq, resp *proto.AddTradeOrderResp) error {
|
|
|
|
obj, err := u.TradeOrderService.AddTradeOrder(req)
|
|
|
|
if err != nil {
|
|
|
|
println(" AddTradeOrder err :", err)
|
|
|
|
} else {
|
|
|
|
fmt.Println(obj.UpdateTime)
|
|
|
|
fmt.Println(" AddTradeOrder handler >>>>>> ", resp)
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
//修改购物车
|
|
|
|
|
|
|
|
func (u *TradeOrderHandler) UpdateTradeOrder(ctx context.Context, req *proto.AddTradeOrderReq, resp *proto.AddTradeOrderResp) error {
|
|
|
|
obj, err := u.TradeOrderService.UpdateTradeOrder(req)
|
|
|
|
if err != nil {
|
|
|
|
println(" UpdateTradeOrder err :", err)
|
|
|
|
} else {
|
|
|
|
fmt.Println(obj.UpdateTime)
|
|
|
|
fmt.Println(" UpdateTradeOrder handler >>>>>> ", resp)
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
func (u *TradeOrderHandler) FindOrder(ctx context.Context, req *proto.FindOrderReq, resp *proto.FindOrderResp) error {
|
|
|
|
obj, err := u.TradeOrderService.FindOrder(req)
|
|
|
|
if err != nil {
|
|
|
|
println(" FindTradeOrder err :", err)
|
|
|
|
} else {
|
|
|
|
order := &proto.TradeOrder{}
|
|
|
|
err := common.SwapToStruct(obj, order)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("转换失败 ", err)
|
|
|
|
}
|
|
|
|
resp.TradeOrder = order
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|