This commit is contained in:
Mrx
2026-06-01 14:39:45 +08:00
parent 928ff4d766
commit 8ab2a6d81d
14 changed files with 495 additions and 67 deletions

View File

@@ -12,6 +12,7 @@ import (
"tyapi-server/internal/infrastructure/external/nuoer"
"tyapi-server/internal/infrastructure/external/shujubao"
"tyapi-server/internal/infrastructure/external/shumai"
"tyapi-server/internal/infrastructure/external/haiyuapi"
"tyapi-server/internal/infrastructure/external/tianyancha"
"tyapi-server/internal/infrastructure/external/westdex"
"tyapi-server/internal/infrastructure/external/xingwei"
@@ -44,6 +45,7 @@ type ProcessorDependencies struct {
ShumaiService *shumai.ShumaiService
HuiboService *huibo.HuiboService
NuoerService *nuoer.NuoerService
HaiyuapiService *haiyuapi.HaiyuapiService
Validator interfaces.RequestValidator
CombService CombServiceInterface // Changed to interface to break import cycle
Options *commands.ApiCallOptions // 添加Options支持
@@ -73,6 +75,7 @@ func NewProcessorDependencies(
shumaiService *shumai.ShumaiService,
huiboService *huibo.HuiboService,
nuoerService *nuoer.NuoerService,
haiyuapiService *haiyuapi.HaiyuapiService,
validator interfaces.RequestValidator,
combService CombServiceInterface, // Changed to interface
reportRepo repositories.ReportRepository,
@@ -92,6 +95,7 @@ func NewProcessorDependencies(
ShumaiService: shumaiService,
HuiboService: huiboService,
NuoerService: nuoerService,
HaiyuapiService: haiyuapiService,
Validator: validator,
CombService: combService,
Options: nil, // 初始化为nil在调用时设置

View File

@@ -7,54 +7,40 @@ import (
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/huibo"
"tyapi-server/internal/infrastructure/external/haiyuapi"
)
// ProcessFLXGHB4FRequest FLXGHB4F API处理方法 - 个人涉诉案件查询汇博
// ProcessFLXGHB4FRequest FLXGHB4F API处理方法 - 个人涉诉案件查询海宇API
func ProcessFLXGHB4FRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.FLXGHB4FReq
if err := json.Unmarshal(params, &paramsDto); err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
if deps.HuiboService == 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 加密 name 和 idCard
// encryptedName := "MD5:" + huibo.MD5Encrypt(paramsDto.Name, deps.HuiboService.GetConfig().AppKey)
// encryptedIDCard := "MD5:" + huibo.MD5Encrypt(paramsDto.IDCard, deps.HuiboService.GetConfig().AppKey)
reqdata := map[string]interface{}{
"name": paramsDto.Name,
"idCard": paramsDto.IDCard,
if deps.HaiyuapiService == nil {
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
}
respBytes, err := deps.HuiboService.CallAPI2(ctx, "P_004_0271", reqdata)
reqParams := map[string]interface{}{
"name": paramsDto.Name,
"id_card": paramsDto.IDCard,
}
apiPath := "/api/v1/FLXGHB4F"
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, apiPath, reqParams)
if err != nil {
return nil, errors.Join(processors.ErrDatasource, err)
}
// 解析响应
var response huibo.CallAPI2Response
if err := json.Unmarshal(respBytes, &response); 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)
}
// 处理状态码
switch response.Code {
case huibo.CallAPI2StatusSuccess:
// 查询成功
if response.Data == nil {
return []byte("{}"), nil
}
return respBytes, nil
case huibo.CallAPI2StatusNoData:
// 查询成功,无数据 - 按产品约定按调用成功计费
return []byte("{}"), nil
default:
// 其他错误状态码
message := huibo.GetCallAPI2StatusMessage(response.Code)
return nil, errors.Join(processors.ErrDatasource, errors.New(message))
}
return respBytes, nil
}

View File

@@ -7,7 +7,7 @@ import (
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/huibo"
"tyapi-server/internal/infrastructure/external/haiyuapi"
)
// ProcessQYGLBH7YRequest QYGLBH7Y API处理方法 - 企业案件查询汇博
@@ -17,39 +17,25 @@ func ProcessQYGLBH7YRequest(ctx context.Context, params []byte, deps *processors
return nil, errors.Join(processors.ErrSystem, err)
}
if deps.HuiboService == nil {
return nil, errors.Join(processors.ErrSystem, errors.New("汇博服务未初始化"))
if deps.HaiyuapiService == nil {
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
}
reqdata := map[string]interface{}{
"companyName": paramsDto.EntName,
reqParams := map[string]interface{}{
"ent_name": paramsDto.EntName,
}
respBytes, err := deps.HuiboService.CallAPI2(ctx, "E_004_0261", reqdata)
apiPath := "/api/v1/QYGLBH7Y"
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, apiPath, reqParams)
if err != nil {
return nil, errors.Join(processors.ErrDatasource, err)
}
// 解析响应
var response huibo.CallAPI2Response
if err := json.Unmarshal(respBytes, &response); 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)
}
// 处理状态码
switch response.Code {
case huibo.CallAPI2StatusSuccess:
// 查询成功
if response.Data == nil {
return []byte("{}"), nil
}
return respBytes, nil
case huibo.CallAPI2StatusNoData:
// 查询成功,无数据 - 按产品约定按调用成功计费
return []byte("{}"), nil
default:
// 其他错误状态码
message := huibo.GetCallAPI2StatusMessage(response.Code)
return nil, errors.Join(processors.ErrDatasource, errors.New(message))
}
return respBytes, nil
}