This commit is contained in:
Mrx
2026-06-01 13:15:37 +08:00
parent 21217f4da1
commit 5d2d49f0e8
16 changed files with 1536 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
package qygl
import (
"context"
"encoding/json"
"errors"
"hyapi-server/internal/domains/api/dto"
"hyapi-server/internal/domains/api/services/processors"
"hyapi-server/internal/infrastructure/external/huibo"
)
// ProcessQYGLBH7YRequest QYGLBH7Y API处理方法 - 企业案件查询汇博
func ProcessQYGLBH7YRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.QYGLBH7YReq
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)
}
reqdata := map[string]interface{}{
"companyName": paramsDto.EntName,
}
respBytes, err := deps.HuiboService.CallAPI2(ctx, "E_004_0261", reqdata)
if err != nil {
return nil, errors.Join(processors.ErrDatasource, err)
}
// 解析响应
var response huibo.CallAPI2Response
if err := json.Unmarshal(respBytes, &response); err != nil {
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))
}
}