This commit is contained in:
2026-07-24 12:05:52 +08:00
parent 9756cf6ba8
commit b935c557b9
5 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
package jrzq
import (
"context"
"encoding/json"
"errors"
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/haiyuapi"
)
// ProcessJRZQ0OO1Request JRZQ0OO1 API处理方法 - 戎行贷后信息 Info360转发海宇 JRZQ0OO1
func ProcessJRZQ0OO1Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.JRZQ0OO1Req
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err)
}
if deps.HaiyuapiService == nil {
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
}
reqParams := map[string]interface{}{
"name": paramsDto.Name,
"id_card": paramsDto.IDCard,
"mobile_no": paramsDto.MobileNo,
}
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, "JRZQ0OO1", reqParams)
if err != nil {
if errors.Is(err, haiyuapi.ErrNotFound) {
return nil, errors.Join(processors.ErrNotFound, err)
}
if errors.Is(err, haiyuapi.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
}
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}