fadd
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package jrzq
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
"hyapi-server/internal/domains/api/dto"
|
||||
"hyapi-server/internal/domains/api/services/processors"
|
||||
"hyapi-server/internal/infrastructure/external/rongxing"
|
||||
)
|
||||
|
||||
func ProcessJRZQ0OO1Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
var paramsDto dto.JRZQ0OO1Req
|
||||
if err := json.Unmarshal(params, ¶msDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
if deps.RongxingService == nil {
|
||||
return nil, errors.Join(processors.ErrSystem, errors.New("戎行服务未初始化"))
|
||||
}
|
||||
|
||||
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
}
|
||||
|
||||
// 业务入参在处理器侧组装;三要素按接口要求 MD5 大写后入请求体
|
||||
reqdata := map[string]interface{}{
|
||||
"phone": rongxing.MD5Upper(paramsDto.MobileNo),
|
||||
"idCard": rongxing.MD5Upper(paramsDto.IDCard),
|
||||
"name": rongxing.MD5Upper(paramsDto.Name),
|
||||
}
|
||||
|
||||
respBytes, err := deps.RongxingService.CallAPI(ctx, "/third/loan/info360", reqdata)
|
||||
if err != nil {
|
||||
if errors.Is(err, rongxing.ErrNotFound) {
|
||||
return nil, errors.Join(processors.ErrNotFound, err)
|
||||
}
|
||||
if errors.Is(err, rongxing.ErrDatasource) {
|
||||
return nil, errors.Join(processors.ErrDatasource, err)
|
||||
}
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
return respBytes, nil
|
||||
}
|
||||
Reference in New Issue
Block a user