From c9bd4612f2508e40ae6c6dd2ba0dec7ec8e7df92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Wed, 12 Mar 2025 14:01:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=BF=85=E5=A1=AB=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v1/cmb_cpn.proto | 16 ++++++++-------- internal/biz/mixrepos/cmb.go | 4 ++-- internal/data/mixrepoimpl/cmb.go | 8 +------- internal/service/cmb.go | 5 ----- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/api/v1/cmb_cpn.proto b/api/v1/cmb_cpn.proto index 834a91a..a617252 100644 --- a/api/v1/cmb_cpn.proto +++ b/api/v1/cmb_cpn.proto @@ -7,21 +7,21 @@ import "validate/validate.proto"; message CmbRequest { // 请求公共参数 // 合作方唯一ID,32位定长 - string mid = 1 [json_name = "mid", (validate.rules).string = {min_len: 1,max_len: 100}]; + string mid = 1 [json_name = "mid"]; // 应用唯一ID,32位定长 - string aid = 2 [json_name = "aid", (validate.rules).string = {min_len: 1,max_len: 100}]; + string aid = 2 [json_name = "aid"]; // 时间戳 yyyyMMddHHmmss - string date = 3 [json_name = "date", (validate.rules).string = {min_len: 14}]; + string date = 3 [json_name = "date"]; // 随机字符串,保证签名不可预测,不长于32位 - string random = 4 [json_name = "random", (validate.rules).string = {min_len: 1,max_len: 50}]; + string random = 4 [json_name = "random"]; // 合作方密钥对别名 - string keyAlias = 5 [json_name = "keyAlias", (validate.rules).string = {min_len: 2,max_len: 50}]; + string keyAlias = 5 [json_name = "keyAlias"]; // 掌上生活密钥对别名 - string cmbKeyAlias = 6 [json_name = "cmbKeyAlias", (validate.rules).string = {min_len: 2,max_len: 50}]; + string cmbKeyAlias = 6 [json_name = "cmbKeyAlias"]; // 加密报文,是否需要加密,请查看各API的说明文档 - string encryptBody = 7 [json_name = "encryptBody", (validate.rules).string = {min_len: 10,max_len: 20000}]; + string encryptBody = 7 [json_name = "encryptBody", (validate.rules).string = {min_len: 2}]; // 签名,具体详见签名规范 - string sign = 8 [json_name = "sign", (validate.rules).string = {min_len: 10,max_len: 5000}]; + string sign = 8 [json_name = "sign", (validate.rules).string = {min_len: 2}]; } message CmbReply { diff --git a/internal/biz/mixrepos/cmb.go b/internal/biz/mixrepos/cmb.go index e1ba2f4..9250aa6 100644 --- a/internal/biz/mixrepos/cmb.go +++ b/internal/biz/mixrepos/cmb.go @@ -16,7 +16,7 @@ type CmbMixRepo interface { // GetMockRequest cmb 券参数mock构建 GetMockRequest(ctx context.Context, bizContent string) (*v1.CmbRequest, error) // GetRequest 我们请求cmb参数构建处理 - GetRequest(_ context.Context, reqBo *bo.CmbRequestBo) (*v1.CmbRequest, error) + GetRequest(ctx context.Context, reqBo *bo.CmbRequestBo) (*v1.CmbRequest, error) // GetResponse cmb 请求我们响应返回结果处理 GetResponse(ctx context.Context, reqBo *bo.CmbResponseBo) (*v1.CmbReply, error) // VerifyResponse cmb 请求响应返回结果验证 @@ -24,5 +24,5 @@ type CmbMixRepo interface { // Request cmb 请求 Request(ctx context.Context, req *v1.CmbRequest, uri string) (*v1.CmbReply, error) // Decrypt cmb 业务参数 解密 - Decrypt(_ context.Context, encryptBody string) (string, error) + Decrypt(ctx context.Context, encryptBody string) (string, error) } diff --git a/internal/data/mixrepoimpl/cmb.go b/internal/data/mixrepoimpl/cmb.go index 1769401..aa5d94c 100644 --- a/internal/data/mixrepoimpl/cmb.go +++ b/internal/data/mixrepoimpl/cmb.go @@ -238,11 +238,5 @@ func (s *CmbMixRepoImpl) Request(ctx context.Context, req *v1.CmbRequest, uri st } func (s *CmbMixRepoImpl) Decrypt(_ context.Context, encryptBody string) (string, error) { - - encryptBody, err := cmb.Decrypt(s.bc.Cmb.Sm2Prk, encryptBody) - if err != nil { - return "", err - } - - return encryptBody, nil + return cmb.Decrypt(s.bc.Cmb.Sm2Prk, encryptBody) } diff --git a/internal/service/cmb.go b/internal/service/cmb.go index d713015..755db84 100644 --- a/internal/service/cmb.go +++ b/internal/service/cmb.go @@ -48,7 +48,6 @@ func (s *VoucherService) CmbOrder(ctx http.Context) error { return ctx.JSON(400, err) } - log.Warnf("orderNo:%s cmbProductQuery replyBizContent:%s GetResponse: %v", orderNo, string(replyBizContent), reply) return ctx.JSON(200, reply) } @@ -120,8 +119,6 @@ func (s *VoucherService) CmbQuery(ctx http.Context) error { return ctx.JSON(400, err) } - log.Warnf("CmbQuery GetResponse: %v", reply) - return ctx.JSON(200, reply) } @@ -183,8 +180,6 @@ func (s *VoucherService) CmbProductQuery(ctx http.Context) error { return ctx.JSON(400, err) } - log.Warnf("cmbProductQuery replyBizContent:%s GetResponse: %v", string(replyBizContent), reply) - return ctx.JSON(200, reply) }