fix comb298y
This commit is contained in:
parent
59d07a4c71
commit
766a972af1
@ -107,17 +107,13 @@ func (l *COMB298YLogic) COMB298Y(req *types.Request) (resp string, err *errs.App
|
|||||||
return "", errs.ErrParamValidation
|
return "", errs.ErrParamValidation
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3、西部加密
|
var encryptedFields map[string]interface{}
|
||||||
westConfig := l.svcCtx.Config.WestConfig
|
unmarshalErr := json.Unmarshal(decryptData, &encryptedFields)
|
||||||
encryptedFields, encryptStructFieldsErr := common.EncryptStructFields(data, westConfig.Key)
|
if unmarshalErr != nil {
|
||||||
if encryptStructFieldsErr != nil {
|
logx.Errorf("解密数据转换为map失败:%v", err)
|
||||||
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
|
|
||||||
return "", errs.ErrSystem
|
return "", errs.ErrSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4、发送请求到西部
|
|
||||||
logx.Infof("交易号:%s", transactionID)
|
|
||||||
|
|
||||||
// 准备并发请求
|
// 准备并发请求
|
||||||
apiRequests := []APIRequest{
|
apiRequests := []APIRequest{
|
||||||
{SourceId: "G16BJ02", ServiceId: "YYSY09CD", Mapping: westmodel.YYSY09CDFieldMapping, Wrap: "data", Service: "west"},
|
{SourceId: "G16BJ02", ServiceId: "YYSY09CD", Mapping: westmodel.YYSY09CDFieldMapping, Wrap: "data", Service: "west"},
|
||||||
@ -137,7 +133,18 @@ func (l *COMB298YLogic) COMB298Y(req *types.Request) (resp string, err *errs.App
|
|||||||
|
|
||||||
// 为每个请求构建对应的请求参数
|
// 为每个请求构建对应的请求参数
|
||||||
for i := range apiRequests {
|
for i := range apiRequests {
|
||||||
apiRequests[i].Request = common.MapStructToAPIRequest(encryptedFields, apiRequests[i].Mapping, apiRequests[i].Wrap)
|
request := encryptedFields
|
||||||
|
if apiRequests[i].Service == "west" {
|
||||||
|
// 3、西部加密
|
||||||
|
westConfig := l.svcCtx.Config.WestConfig
|
||||||
|
encryptedRequest, encryptStructFieldsErr := common.EncryptStructFields(request, westConfig.Key)
|
||||||
|
if encryptStructFieldsErr != nil {
|
||||||
|
logx.Errorf("西部加密错误:%v", encryptStructFieldsErr)
|
||||||
|
}
|
||||||
|
request = encryptedRequest
|
||||||
|
}
|
||||||
|
logx.Infof("sourceId:%s,请求参数:%v", apiRequests[i].SourceId, request)
|
||||||
|
apiRequests[i].Request = common.MapStructToAPIRequest(request, apiRequests[i].Mapping, apiRequests[i].Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建响应通道
|
// 创建响应通道
|
||||||
@ -156,8 +163,13 @@ func (l *COMB298YLogic) COMB298Y(req *types.Request) (resp string, err *errs.App
|
|||||||
// 根据服务类型选择不同的调用方式
|
// 根据服务类型选择不同的调用方式
|
||||||
switch req.Service {
|
switch req.Service {
|
||||||
case "west":
|
case "west":
|
||||||
|
|
||||||
|
// 4、发送请求到西部
|
||||||
|
logx.Infof("交易号:%s", transactionID)
|
||||||
|
|
||||||
respData, err := l.svcCtx.WestDexService.CallAPI(req.SourceId, req.Request, l.svcCtx.Config.WestConfig.SecretId)
|
respData, err := l.svcCtx.WestDexService.CallAPI(req.SourceId, req.Request, l.svcCtx.Config.WestConfig.SecretId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logx.Errorf("西部请求失败:sourceId:%s,err:%v", req.SourceId, err)
|
||||||
callAPIErr = err
|
callAPIErr = err
|
||||||
westResp = "{}" // 发生错误时返回空对象
|
westResp = "{}" // 发生错误时返回空对象
|
||||||
} else {
|
} else {
|
||||||
@ -177,6 +189,7 @@ func (l *COMB298YLogic) COMB298Y(req *types.Request) (resp string, err *errs.App
|
|||||||
case "yushan":
|
case "yushan":
|
||||||
respData, err := l.svcCtx.YushanService.Request(req.SourceId, req.Request)
|
respData, err := l.svcCtx.YushanService.Request(req.SourceId, req.Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logx.Errorf("羽山请求失败:sourceId:%s,err:%v", req.SourceId, err)
|
||||||
if appErr, ok := err.(*errs.AppError); ok {
|
if appErr, ok := err.(*errs.AppError); ok {
|
||||||
callAPIErr = appErr
|
callAPIErr = appErr
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user