temp
This commit is contained in:
parent
3d3ab79e20
commit
d520deacb3
@ -2,6 +2,11 @@ package FLXG
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
|
"tianyuan-api/apps/api/internal/common"
|
||||||
|
"tianyuan-api/apps/api/internal/validator"
|
||||||
|
"tianyuan-api/apps/api/internal/westmodel"
|
||||||
|
"tianyuan-api/pkg/crypto"
|
||||||
"tianyuan-api/pkg/errs"
|
"tianyuan-api/pkg/errs"
|
||||||
|
|
||||||
"tianyuan-api/apps/api/internal/svc"
|
"tianyuan-api/apps/api/internal/svc"
|
||||||
@ -25,7 +30,64 @@ func NewFLXG9687Logic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXG9687
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *FLXG9687Logic) FLXG9687(req *types.Request) (resp *types.Response, err *errs.AppError) {
|
func (l *FLXG9687Logic) FLXG9687(req *types.Request) (resp *types.Response, err *errs.AppError) {
|
||||||
// todo: add your logic here and delete this line
|
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||||
|
if !ok {
|
||||||
|
return &types.Response{}, errs.ErrSystem
|
||||||
|
}
|
||||||
|
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||||
|
if !ok {
|
||||||
|
return &types.Response{}, errs.ErrSystem
|
||||||
|
}
|
||||||
|
// 1、解密
|
||||||
|
key, decodeErr := hex.DecodeString(secretKey)
|
||||||
|
if decodeErr != nil {
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||||
|
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||||
|
return nil, errs.ErrParamDecryption
|
||||||
|
}
|
||||||
|
|
||||||
return
|
// 2、校验
|
||||||
|
var data validator.FLXG9687Request
|
||||||
|
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||||
|
return nil, errs.ErrParamValidation
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3、西部加密
|
||||||
|
westConfig := l.svcCtx.Config.WestConfig
|
||||||
|
encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
|
||||||
|
if encryptStructFieldsErr != nil {
|
||||||
|
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4、发送请求到西部
|
||||||
|
logx.Infof("交易号:%s", transactionID)
|
||||||
|
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXG9687FieldMapping, "data")
|
||||||
|
|
||||||
|
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G31BJ05", apiRequest)
|
||||||
|
if callAPIErr != nil {
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5、响应解析
|
||||||
|
//var respData westmodel.G32BJ05Response
|
||||||
|
//unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||||
|
//if unmarshalErr != nil {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||||
|
// l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||||
|
//} else {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
//encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||||
|
//if aesEncrypt != nil {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
return &types.Response{
|
||||||
|
Data: string(westResp),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,11 @@ package FLXG
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
|
"tianyuan-api/apps/api/internal/common"
|
||||||
|
"tianyuan-api/apps/api/internal/validator"
|
||||||
|
"tianyuan-api/apps/api/internal/westmodel"
|
||||||
|
"tianyuan-api/pkg/crypto"
|
||||||
"tianyuan-api/pkg/errs"
|
"tianyuan-api/pkg/errs"
|
||||||
|
|
||||||
"tianyuan-api/apps/api/internal/svc"
|
"tianyuan-api/apps/api/internal/svc"
|
||||||
@ -25,7 +30,64 @@ func NewFLXGC9D1Logic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXGC9D1
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *FLXGC9D1Logic) FLXGC9D1(req *types.Request) (resp *types.Response, err *errs.AppError) {
|
func (l *FLXGC9D1Logic) FLXGC9D1(req *types.Request) (resp *types.Response, err *errs.AppError) {
|
||||||
// todo: add your logic here and delete this line
|
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||||
|
if !ok {
|
||||||
|
return &types.Response{}, errs.ErrSystem
|
||||||
|
}
|
||||||
|
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||||
|
if !ok {
|
||||||
|
return &types.Response{}, errs.ErrSystem
|
||||||
|
}
|
||||||
|
// 1、解密
|
||||||
|
key, decodeErr := hex.DecodeString(secretKey)
|
||||||
|
if decodeErr != nil {
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||||
|
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||||
|
return nil, errs.ErrParamDecryption
|
||||||
|
}
|
||||||
|
|
||||||
return
|
// 2、校验
|
||||||
|
var data validator.FLXGC9D1Request
|
||||||
|
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||||
|
return nil, errs.ErrParamValidation
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3、西部加密
|
||||||
|
westConfig := l.svcCtx.Config.WestConfig
|
||||||
|
encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
|
||||||
|
if encryptStructFieldsErr != nil {
|
||||||
|
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4、发送请求到西部
|
||||||
|
logx.Infof("交易号:%s", transactionID)
|
||||||
|
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXGC9D1FieldMapping, "data")
|
||||||
|
|
||||||
|
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G31BJ05", apiRequest)
|
||||||
|
if callAPIErr != nil {
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5、响应解析
|
||||||
|
//var respData westmodel.G32BJ05Response
|
||||||
|
//unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||||
|
//if unmarshalErr != nil {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||||
|
// l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||||
|
//} else {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
//encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||||
|
//if aesEncrypt != nil {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
return &types.Response{
|
||||||
|
Data: string(westResp),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,11 @@ package FLXG
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
|
"tianyuan-api/apps/api/internal/common"
|
||||||
|
"tianyuan-api/apps/api/internal/validator"
|
||||||
|
"tianyuan-api/apps/api/internal/westmodel"
|
||||||
|
"tianyuan-api/pkg/crypto"
|
||||||
"tianyuan-api/pkg/errs"
|
"tianyuan-api/pkg/errs"
|
||||||
|
|
||||||
"tianyuan-api/apps/api/internal/svc"
|
"tianyuan-api/apps/api/internal/svc"
|
||||||
@ -25,7 +30,64 @@ func NewFLXGCA3DLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXGCA3D
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *FLXGCA3DLogic) FLXGCA3D(req *types.Request) (resp *types.Response, err *errs.AppError) {
|
func (l *FLXGCA3DLogic) FLXGCA3D(req *types.Request) (resp *types.Response, err *errs.AppError) {
|
||||||
// todo: add your logic here and delete this line
|
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||||
|
if !ok {
|
||||||
|
return &types.Response{}, errs.ErrSystem
|
||||||
|
}
|
||||||
|
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||||
|
if !ok {
|
||||||
|
return &types.Response{}, errs.ErrSystem
|
||||||
|
}
|
||||||
|
// 1、解密
|
||||||
|
key, decodeErr := hex.DecodeString(secretKey)
|
||||||
|
if decodeErr != nil {
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||||
|
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||||
|
return nil, errs.ErrParamDecryption
|
||||||
|
}
|
||||||
|
|
||||||
return
|
// 2、校验
|
||||||
|
var data validator.FLXGCA3DRequest
|
||||||
|
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||||
|
return nil, errs.ErrParamValidation
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3、西部加密
|
||||||
|
westConfig := l.svcCtx.Config.WestConfig
|
||||||
|
encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
|
||||||
|
if encryptStructFieldsErr != nil {
|
||||||
|
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4、发送请求到西部
|
||||||
|
logx.Infof("交易号:%s", transactionID)
|
||||||
|
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXGCA3DFieldMapping, "data")
|
||||||
|
|
||||||
|
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G22BJ03", apiRequest)
|
||||||
|
if callAPIErr != nil {
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5、响应解析
|
||||||
|
//var respData westmodel.G32BJ05Response
|
||||||
|
//unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||||
|
//if unmarshalErr != nil {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||||
|
// l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||||
|
//} else {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
//encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||||
|
//if aesEncrypt != nil {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
return &types.Response{
|
||||||
|
Data: string(westResp),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,11 @@ package FLXG
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
|
"tianyuan-api/apps/api/internal/common"
|
||||||
|
"tianyuan-api/apps/api/internal/validator"
|
||||||
|
"tianyuan-api/apps/api/internal/westmodel"
|
||||||
|
"tianyuan-api/pkg/crypto"
|
||||||
"tianyuan-api/pkg/errs"
|
"tianyuan-api/pkg/errs"
|
||||||
|
|
||||||
"tianyuan-api/apps/api/internal/svc"
|
"tianyuan-api/apps/api/internal/svc"
|
||||||
@ -25,7 +30,64 @@ func NewFLXGDEC7Logic(ctx context.Context, svcCtx *svc.ServiceContext) *FLXGDEC7
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *FLXGDEC7Logic) FLXGDEC7(req *types.Request) (resp *types.Response, err *errs.AppError) {
|
func (l *FLXGDEC7Logic) FLXGDEC7(req *types.Request) (resp *types.Response, err *errs.AppError) {
|
||||||
// todo: add your logic here and delete this line
|
secretKey, ok := l.ctx.Value("secretKey").(string)
|
||||||
|
if !ok {
|
||||||
|
return &types.Response{}, errs.ErrSystem
|
||||||
|
}
|
||||||
|
transactionID, ok := l.ctx.Value("transactionID").(string)
|
||||||
|
if !ok {
|
||||||
|
return &types.Response{}, errs.ErrSystem
|
||||||
|
}
|
||||||
|
// 1、解密
|
||||||
|
key, decodeErr := hex.DecodeString(secretKey)
|
||||||
|
if decodeErr != nil {
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
decryptData, aesDecryptErr := crypto.AesDecrypt(req.Data, key)
|
||||||
|
if aesDecryptErr != nil || len(decryptData) == 0 {
|
||||||
|
return nil, errs.ErrParamDecryption
|
||||||
|
}
|
||||||
|
|
||||||
return
|
// 2、校验
|
||||||
|
var data validator.FLXGDEC7Request
|
||||||
|
if validatorErr := validator.ValidateAndParse(decryptData, &data); validatorErr != nil {
|
||||||
|
return nil, errs.ErrParamValidation
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3、西部加密
|
||||||
|
westConfig := l.svcCtx.Config.WestConfig
|
||||||
|
encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
|
||||||
|
if encryptStructFieldsErr != nil {
|
||||||
|
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4、发送请求到西部
|
||||||
|
logx.Infof("交易号:%s", transactionID)
|
||||||
|
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.FLXGDEC7FieldMapping, "data")
|
||||||
|
|
||||||
|
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G23BJ03", apiRequest)
|
||||||
|
if callAPIErr != nil {
|
||||||
|
return nil, errs.ErrSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5、响应解析
|
||||||
|
//var respData westmodel.G32BJ05Response
|
||||||
|
//unmarshalErr := json.Unmarshal(westResp, &respData)
|
||||||
|
//if unmarshalErr != nil {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//if respData.Data.Code == "00" || respData.Data.Code == "100002" {
|
||||||
|
// l.ctx = context.WithValue(l.ctx, "Charges", true)
|
||||||
|
//} else {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
//encryptData, aesEncrypt := crypto.AesEncrypt(westResp, key)
|
||||||
|
//if aesEncrypt != nil {
|
||||||
|
// return nil, errs.ErrSystem
|
||||||
|
//}
|
||||||
|
return &types.Response{
|
||||||
|
Data: string(westResp),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,24 @@ type FLXG970FRequest struct {
|
|||||||
type FLXG5876Request struct {
|
type FLXG5876Request struct {
|
||||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||||
}
|
}
|
||||||
|
type FLXG9687Request struct {
|
||||||
|
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||||
|
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||||
|
Name string `json:"name" validate:"required,min=1,validName"`
|
||||||
|
}
|
||||||
|
type FLXGC9D1Request struct {
|
||||||
|
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||||
|
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||||
|
Name string `json:"name" validate:"required,min=1,validName"`
|
||||||
|
}
|
||||||
|
type FLXGCA3DRequest struct {
|
||||||
|
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||||
|
Name string `json:"name" validate:"required,min=1,validName"`
|
||||||
|
}
|
||||||
|
type FLXGDEC7Request struct {
|
||||||
|
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||||
|
Name string `json:"name" validate:"required,min=1,validName"`
|
||||||
|
}
|
||||||
type IVYZ5733Request struct {
|
type IVYZ5733Request struct {
|
||||||
Name string `json:"name" validate:"required,min=1,validName"`
|
Name string `json:"name" validate:"required,min=1,validName"`
|
||||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||||
|
@ -3,12 +3,12 @@ package westmodel
|
|||||||
var IVYZ5733FieldMapping = map[string]string{
|
var IVYZ5733FieldMapping = map[string]string{
|
||||||
"IDCard": "id",
|
"IDCard": "id",
|
||||||
"Name": "name",
|
"Name": "name",
|
||||||
"MobileNo": "cell",
|
|
||||||
"TimeRange": "time_range",
|
|
||||||
}
|
}
|
||||||
var FLXG3D56FieldMapping = map[string]string{
|
var FLXG3D56FieldMapping = map[string]string{
|
||||||
"IDCard": "id",
|
"IDCard": "id",
|
||||||
"Name": "name",
|
"Name": "name",
|
||||||
|
"MobileNo": "cell",
|
||||||
|
"TimeRange": "time_range",
|
||||||
}
|
}
|
||||||
var FLXG54F5FieldMapping = map[string]string{
|
var FLXG54F5FieldMapping = map[string]string{
|
||||||
"MobileNo": "mobile",
|
"MobileNo": "mobile",
|
||||||
@ -23,6 +23,24 @@ var FLXG970FFieldMapping = map[string]string{
|
|||||||
"IDCard": "id",
|
"IDCard": "id",
|
||||||
"Name": "name",
|
"Name": "name",
|
||||||
}
|
}
|
||||||
|
var FLXG9687FieldMapping = map[string]string{
|
||||||
|
"IDCard": "id",
|
||||||
|
"Name": "name",
|
||||||
|
"MobileNo": "cell",
|
||||||
|
}
|
||||||
|
var FLXGC9D1FieldMapping = map[string]string{
|
||||||
|
"IDCard": "id",
|
||||||
|
"Name": "name",
|
||||||
|
"MobileNo": "cell",
|
||||||
|
}
|
||||||
|
var FLXGCA3DFieldMapping = map[string]string{
|
||||||
|
"IDCard": "id",
|
||||||
|
"Name": "name",
|
||||||
|
}
|
||||||
|
var FLXGDEC7FieldMapping = map[string]string{
|
||||||
|
"IDCard": "id",
|
||||||
|
"Name": "name",
|
||||||
|
}
|
||||||
var FLXG5876FieldMapping = map[string]string{
|
var FLXG5876FieldMapping = map[string]string{
|
||||||
"MobileNo": "mobile",
|
"MobileNo": "mobile",
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user