This commit is contained in:
2024-10-13 20:52:47 +08:00
parent 534500eb32
commit c35864c47b
39 changed files with 2243 additions and 291 deletions

View File

@@ -25,7 +25,89 @@ func NewIVYZ0B03Logic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZ0B03
}
func (l *IVYZ0B03Logic) IVYZ0B03(req *types.Request) (resp *types.Response, err *errs.AppError) {
// todo: add your logic here and delete this line
return
//var status string
//var charges bool
//var remark = ""
//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
//}
//userId, userIdOk := l.ctx.Value("userId").(int64)
//if !userIdOk {
// return &types.Response{}, errs.ErrSystem
//}
//productCode, productCodeOk := l.ctx.Value("productCode").(string)
//if !productCodeOk || productCode == "" {
// return &types.Response{}, errs.ErrSystem
//}
//defer func() {
// if err != nil {
// status = "failed"
// charges = false
// } else {
// status = "success"
// charges = true
// }
// sendApiRequestMessageErr := l.svcCtx.ApiRequestMqsService.SendApiRequestMessage(l.ctx, transactionID, userId, productCode, status, charges, remark)
// if sendApiRequestMessageErr != nil {
// logx.Errorf("发送 API 请求消息失败: %v", err)
// }
//}()
//// 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
//}
//
//// 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
}

View File

@@ -24,8 +24,91 @@ func NewIVYZ2125Logic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZ2125
}
}
// IVYZ2125 活体+人像核验组件
func (l *IVYZ2125Logic) IVYZ2125(req *types.Request) (resp *types.Response, err *errs.AppError) {
// todo: add your logic here and delete this line
return
//var status string
//var charges bool
//var remark = ""
//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
//}
//userId, userIdOk := l.ctx.Value("userId").(int64)
//if !userIdOk {
// return &types.Response{}, errs.ErrSystem
//}
//productCode, productCodeOk := l.ctx.Value("productCode").(string)
//if !productCodeOk || productCode == "" {
// return &types.Response{}, errs.ErrSystem
//}
//defer func() {
// if err != nil {
// status = "failed"
// charges = false
// } else {
// status = "success"
// charges = true
// }
// sendApiRequestMessageErr := l.svcCtx.ApiRequestMqsService.SendApiRequestMessage(l.ctx, transactionID, userId, productCode, status, charges, remark)
// if sendApiRequestMessageErr != nil {
// logx.Errorf("发送 API 请求消息失败: %v", err)
// }
//}()
//// 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
//}
//
//// 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
}

View File

@@ -2,6 +2,11 @@ package IVYZ
import (
"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/apps/api/internal/svc"
@@ -25,7 +30,88 @@ func NewIVYZ385ELogic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZ385E
}
func (l *IVYZ385ELogic) IVYZ385E(req *types.Request) (resp *types.Response, err *errs.AppError) {
// todo: add your logic here and delete this line
var status string
var charges bool
var remark = ""
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
}
userId, userIdOk := l.ctx.Value("userId").(int64)
if !userIdOk {
return &types.Response{}, errs.ErrSystem
}
productCode, productCodeOk := l.ctx.Value("productCode").(string)
if !productCodeOk || productCode == "" {
return &types.Response{}, errs.ErrSystem
}
defer func() {
if err != nil {
status = "failed"
charges = false
} else {
status = "success"
charges = true
}
sendApiRequestMessageErr := l.svcCtx.ApiRequestMqsService.SendApiRequestMessage(l.ctx, transactionID, userId, productCode, status, charges, remark)
if sendApiRequestMessageErr != nil {
logx.Errorf("发送 API 请求消息失败: %v", err)
}
}()
// 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.IVYZ385ERequest
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.IVYZ385EFieldMapping, "")
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("WEST00020", 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
}

View File

@@ -30,16 +30,38 @@ func NewIVYZ5733Logic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZ5733
}
func (l *IVYZ5733Logic) IVYZ5733(req *types.Request) (resp *types.Response, err *errs.AppError) {
var status string
var charges bool
var remark = ""
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
}
userId, userIdOk := l.ctx.Value("userId").(int64)
if !userIdOk {
return &types.Response{}, errs.ErrSystem
}
productCode, productCodeOk := l.ctx.Value("productCode").(string)
if !productCodeOk || productCode == "" {
return &types.Response{}, errs.ErrSystem
}
defer func() {
if err != nil {
status = "failed"
charges = false
} else {
status = "success"
charges = true
}
sendApiRequestMessageErr := l.svcCtx.ApiRequestMqsService.SendApiRequestMessage(l.ctx, transactionID, userId, productCode, status, charges, remark)
if sendApiRequestMessageErr != nil {
logx.Errorf("发送 API 请求消息失败: %v", err)
}
}()
// 1、解密
key, decodeErr := hex.DecodeString(secretKey)
if decodeErr != nil {
@@ -60,16 +82,19 @@ func (l *IVYZ5733Logic) IVYZ5733(req *types.Request) (resp *types.Response, err
westConfig := l.svcCtx.Config.WestConfig
encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
if encryptStructFieldsErr != nil {
logx.Errorf("西部加密错误:%v", err)
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
return nil, errs.ErrSystem
}
// 4、发送请求到西部
logx.Infof("交易号:%s", transactionID)
apiRequest := common.MapStructToAPIRequest(encryptedFields, westmodel.IVYZ5733FieldMapping, "data")
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G09GX01", apiRequest)
if callAPIErr != nil {
return nil, errs.ErrSystem
}
// 5、响应解析
var respData westmodel.G09GX01Response
unmarshalErr := json.Unmarshal(westResp, &respData)

View File

@@ -2,6 +2,11 @@ package IVYZ
import (
"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/apps/api/internal/svc"
@@ -25,7 +30,88 @@ func NewIVYZ9363Logic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZ9363
}
func (l *IVYZ9363Logic) IVYZ9363(req *types.Request) (resp *types.Response, err *errs.AppError) {
// todo: add your logic here and delete this line
var status string
var charges bool
var remark = ""
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
}
userId, userIdOk := l.ctx.Value("userId").(int64)
if !userIdOk {
return &types.Response{}, errs.ErrSystem
}
productCode, productCodeOk := l.ctx.Value("productCode").(string)
if !productCodeOk || productCode == "" {
return &types.Response{}, errs.ErrSystem
}
defer func() {
if err != nil {
status = "failed"
charges = false
} else {
status = "success"
charges = true
}
sendApiRequestMessageErr := l.svcCtx.ApiRequestMqsService.SendApiRequestMessage(l.ctx, transactionID, userId, productCode, status, charges, remark)
if sendApiRequestMessageErr != nil {
logx.Errorf("发送 API 请求消息失败: %v", err)
}
}()
// 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.IVYZ9363Request
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.IVYZ9363FieldMapping, "data")
westResp, callAPIErr := l.svcCtx.WestDexService.CallAPI("G10GX01", 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
}

View File

@@ -25,7 +25,89 @@ func NewIVYZADEELogic(ctx context.Context, svcCtx *svc.ServiceContext) *IVYZADEE
}
func (l *IVYZADEELogic) IVYZADEE(req *types.Request) (resp *types.Response, err *errs.AppError) {
// todo: add your logic here and delete this line
return
//var status string
//var charges bool
//var remark = ""
//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
//}
//userId, userIdOk := l.ctx.Value("userId").(int64)
//if !userIdOk {
// return &types.Response{}, errs.ErrSystem
//}
//productCode, productCodeOk := l.ctx.Value("productCode").(string)
//if !productCodeOk || productCode == "" {
// return &types.Response{}, errs.ErrSystem
//}
//defer func() {
// if err != nil {
// status = "failed"
// charges = false
// } else {
// status = "success"
// charges = true
// }
// sendApiRequestMessageErr := l.svcCtx.ApiRequestMqsService.SendApiRequestMessage(l.ctx, transactionID, userId, productCode, status, charges, remark)
// if sendApiRequestMessageErr != nil {
// logx.Errorf("发送 API 请求消息失败: %v", err)
// }
//}()
//// 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
//}
//
//// 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("idCardThreeElements", 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
}