diff --git a/internal/service/cmb_product.go b/internal/service/cmb_product.go index 3595509..46632a4 100644 --- a/internal/service/cmb_product.go +++ b/internal/service/cmb_product.go @@ -10,6 +10,26 @@ import ( "voucher/internal/biz/vo" ) +func (c *CmbService) QueryProduct(ctx context.Context, request *v1.CmbRequest) (*v1.CmbReply, error) { + + bizReply, err := c.queryProduct(ctx, request) + if err != nil { + return c.QueryProductFail(ctx, err) + } + + return c.QueryProductSuccess(ctx, bizReply) +} + +func (c *CmbService) queryProduct(ctx context.Context, request *v1.CmbRequest) (*v1.CmbQueryProductReply, error) { + + bizContent, err := c.CmbMixRepo.ProductQueryVerify(ctx, request) + if err != nil { + return nil, err + } + + return c.VoucherBiz.CmbProductQuery(ctx, bizContent.ActivityId) +} + func (c *CmbService) QueryProductSuccess(ctx context.Context, bizReply *v1.CmbQueryProductReply) (*v1.CmbReply, error) { replyBizContent, _ := json.Marshal(bizReply) @@ -37,23 +57,3 @@ func (c *CmbService) QueryProductFail(ctx context.Context, err error) (*v1.CmbRe return c.GetResponse(ctx, replyBizContent) } - -func (c *CmbService) QueryProduct(ctx context.Context, request *v1.CmbRequest) (*v1.CmbReply, error) { - - bizReply, err := c.queryProduct(ctx, request) - if err != nil { - return c.QueryProductFail(ctx, err) - } - - return c.QueryProductSuccess(ctx, bizReply) -} - -func (c *CmbService) queryProduct(ctx context.Context, request *v1.CmbRequest) (*v1.CmbQueryProductReply, error) { - - bizContent, err := c.CmbMixRepo.ProductQueryVerify(ctx, request) - if err != nil { - return nil, err - } - - return c.VoucherBiz.CmbProductQuery(ctx, bizContent.ActivityId) -} diff --git a/internal/service/cmb_query.go b/internal/service/cmb_query.go index 88577a9..433d7db 100644 --- a/internal/service/cmb_query.go +++ b/internal/service/cmb_query.go @@ -8,6 +8,27 @@ import ( v1 "voucher/api/v1" ) +func (c *CmbService) Query(ctx context.Context, request *v1.CmbRequest) (*v1.CmbReply, error) { + + orderNo, err := c.query(ctx, request) + + if err != nil { + return c.QueryFail(ctx, err) + } + + return c.QuerySuccess(ctx, orderNo) +} + +func (c *CmbService) query(ctx context.Context, request *v1.CmbRequest) (*v1.CmbQueryReply, error) { + + bizContent, err := c.CmbMixRepo.QueryVerify(ctx, request) + if err != nil { + return nil, err + } + + return c.VoucherBiz.CmbQuery(ctx, bizContent.CodeNo) +} + func (c *CmbService) QuerySuccess(ctx context.Context, bizReply *v1.CmbQueryReply) (*v1.CmbReply, error) { replyBizContent, _ := json.Marshal(bizReply) @@ -29,24 +50,3 @@ func (c *CmbService) QueryFail(ctx context.Context, err error) (*v1.CmbReply, er return c.GetResponse(ctx, replyBizContent) } - -func (c *CmbService) Query(ctx context.Context, request *v1.CmbRequest) (*v1.CmbReply, error) { - - orderNo, err := c.query(ctx, request) - - if err != nil { - return c.QueryFail(ctx, err) - } - - return c.QuerySuccess(ctx, orderNo) -} - -func (c *CmbService) query(ctx context.Context, request *v1.CmbRequest) (*v1.CmbQueryReply, error) { - - bizContent, err := c.CmbMixRepo.QueryVerify(ctx, request) - if err != nil { - return nil, err - } - - return c.VoucherBiz.CmbQuery(ctx, bizContent.CodeNo) -}