cmb
This commit is contained in:
parent
d382acfd2d
commit
8ebf0127de
|
|
@ -39,8 +39,8 @@ func NewHTTPServer(
|
||||||
cmb.POST("/v1/orderMock", voucherService.CmbOrderMock)
|
cmb.POST("/v1/orderMock", voucherService.CmbOrderMock)
|
||||||
cmb.POST("/v1/order", voucherService.CmbOrder)
|
cmb.POST("/v1/order", voucherService.CmbOrder)
|
||||||
|
|
||||||
cmb.POST("/v1/queryMock", voucherService.CmbOrderMock)
|
cmb.POST("/v1/queryMock", voucherService.CmbQueryMock)
|
||||||
cmb.POST("/v1/query", voucherService.CmbOrder)
|
cmb.POST("/v1/query", voucherService.CmbQuery)
|
||||||
|
|
||||||
cmb.POST("/v1/product/QueryMock", voucherService.CmbProductQueryMock)
|
cmb.POST("/v1/product/QueryMock", voucherService.CmbProductQueryMock)
|
||||||
cmb.POST("/v1/product/query", voucherService.CmbProductQuery)
|
cmb.POST("/v1/product/query", voucherService.CmbProductQuery)
|
||||||
|
|
|
||||||
|
|
@ -53,13 +53,12 @@ func (s *VoucherService) CmbOrder(ctx http.Context) error {
|
||||||
|
|
||||||
func (s *VoucherService) cmbOrder(ctx http.Context) (string, error) {
|
func (s *VoucherService) cmbOrder(ctx http.Context) (string, error) {
|
||||||
|
|
||||||
var req *v1.CmbRequest
|
|
||||||
|
|
||||||
bodyBytes, err := io.ReadAll(ctx.Request().Body)
|
bodyBytes, err := io.ReadAll(ctx.Request().Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var req *v1.CmbRequest
|
||||||
if err = json.Unmarshal(bodyBytes, &req); err != nil {
|
if err = json.Unmarshal(bodyBytes, &req); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +72,10 @@ func (s *VoucherService) cmbOrder(ctx http.Context) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = bizContent.Validate(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
boReq := &bo.OrderCreateReqBo{
|
boReq := &bo.OrderCreateReqBo{
|
||||||
OutBizNo: bizContent.TransactionId,
|
OutBizNo: bizContent.TransactionId,
|
||||||
ProductNo: bizContent.ActivityId,
|
ProductNo: bizContent.ActivityId,
|
||||||
|
|
@ -139,6 +142,10 @@ func (s *VoucherService) cmbQuery(ctx http.Context) (*v1.CmbQueryReply, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = bizContent.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return s.VoucherBiz.CmbQuery(ctx, bizContent.CodeNo)
|
return s.VoucherBiz.CmbQuery(ctx, bizContent.CodeNo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,6 +203,10 @@ func (s *VoucherService) cmbProductQuery(ctx http.Context) (*v1.CmbQueryProductR
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = bizContent.Validate(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return s.VoucherBiz.CmbProductQuery(ctx, bizContent.ActivityId)
|
return s.VoucherBiz.CmbProductQuery(ctx, bizContent.ActivityId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,20 @@ package service
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/go-kratos/kratos/v2/transport/http"
|
"github.com/go-kratos/kratos/v2/transport/http"
|
||||||
|
"io"
|
||||||
v1 "voucher/api/v1"
|
v1 "voucher/api/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *VoucherService) CmbQueryMock(ctx http.Context) error {
|
func (s *VoucherService) CmbOrderMock(ctx http.Context) error {
|
||||||
|
|
||||||
var req *v1.CmbQueryRequest
|
bodyBytes, err := io.ReadAll(ctx.Request().Body)
|
||||||
if err := ctx.BindForm(&req); err != nil {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var req *v1.CmbOrderRequest
|
||||||
|
|
||||||
|
if err = json.Unmarshal(bodyBytes, &req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,10 +33,15 @@ func (s *VoucherService) CmbQueryMock(ctx http.Context) error {
|
||||||
return ctx.JSON(200, reply)
|
return ctx.JSON(200, reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *VoucherService) CmbOrderMock(ctx http.Context) error {
|
func (s *VoucherService) CmbQueryMock(ctx http.Context) error {
|
||||||
|
|
||||||
var req *v1.CmbOrderRequest
|
bodyBytes, err := io.ReadAll(ctx.Request().Body)
|
||||||
if err := ctx.BindForm(&req); err != nil {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var req *v1.CmbQueryRequest
|
||||||
|
if err = json.Unmarshal(bodyBytes, &req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,8 +60,13 @@ func (s *VoucherService) CmbOrderMock(ctx http.Context) error {
|
||||||
|
|
||||||
func (s *VoucherService) CmbProductQueryMock(ctx http.Context) error {
|
func (s *VoucherService) CmbProductQueryMock(ctx http.Context) error {
|
||||||
|
|
||||||
|
bodyBytes, err := io.ReadAll(ctx.Request().Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
var req *v1.CmbQueryProductRequest
|
var req *v1.CmbQueryProductRequest
|
||||||
if err := ctx.BindForm(&req); err != nil {
|
if err = json.Unmarshal(bodyBytes, &req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue