add COMBHZY2
This commit is contained in:
@@ -213,6 +213,13 @@ type COMB298YReq struct {
|
||||
TimeRange string `json:"time_range" validate:"omitempty,validTimeRange"` // 非必填字段
|
||||
}
|
||||
|
||||
type COMBHZY2Req struct {
|
||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||
Name string `json:"name" validate:"required,min=1,validName"`
|
||||
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`
|
||||
AuthorizationURL string `json:"authorization_url" validate:"required,authorization_url"`
|
||||
}
|
||||
|
||||
type COMB86PMReq struct {
|
||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||
Name string `json:"name" validate:"required,min=1,validName"`
|
||||
|
||||
@@ -185,6 +185,7 @@ func registerAllProcessors(combService *comb.CombService) {
|
||||
|
||||
// COMB系列处理器 - 只注册有自定义逻辑的组合包
|
||||
"COMB86PM": comb.ProcessCOMB86PMRequest, // 有自定义逻辑:重命名ApiCode
|
||||
"COMBHZY2": comb.ProcessCOMBHZY2Request, // 自定义处理:生成合规报告
|
||||
|
||||
// QCXG系列处理器
|
||||
"QCXG7A2B": qcxg.ProcessQCXG7A2BRequest,
|
||||
|
||||
@@ -171,6 +171,7 @@ func (s *FormConfigServiceImpl) getDTOStruct(ctx context.Context, apiCode string
|
||||
"IVYZ6G7H": &dto.IVYZ6G7HReq{},
|
||||
"IVYZ8I9J": &dto.IVYZ8I9JReq{},
|
||||
"JRZQ0L85": &dto.JRZQ0L85Req{},
|
||||
"COMBHZY2": &dto.COMBHZY2Req{},
|
||||
}
|
||||
|
||||
// 优先返回已配置的DTO
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package comb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"tyapi-server/internal/domains/api/dto"
|
||||
"tyapi-server/internal/domains/api/services/processors"
|
||||
)
|
||||
|
||||
// ProcessCOMBHZY2Request 处理 COMBHZY2 组合包请求
|
||||
func ProcessCOMBHZY2Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||
var req dto.COMBHZY2Req
|
||||
if err := json.Unmarshal(params, &req); err != nil {
|
||||
return nil, errors.Join(processors.ErrSystem, err)
|
||||
}
|
||||
|
||||
if err := deps.Validator.ValidateStruct(req); err != nil {
|
||||
return nil, errors.Join(processors.ErrInvalidParam, err)
|
||||
}
|
||||
|
||||
combinedResult, err := deps.CombService.ProcessCombRequest(ctx, params, deps, "COMBHZY2")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sourceCtx, err := buildSourceContextFromCombined(combinedResult)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
report := buildTargetReport(sourceCtx)
|
||||
return json.Marshal(report)
|
||||
}
|
||||
|
||||
func buildSourceContextFromCombined(result *processors.CombinedResult) (*sourceContext, error) {
|
||||
if result == nil {
|
||||
return nil, errors.New("组合包响应为空")
|
||||
}
|
||||
|
||||
src := sourceFile{Responses: make([]sourceResponse, 0, len(result.Responses))}
|
||||
for _, resp := range result.Responses {
|
||||
if !resp.Success {
|
||||
continue
|
||||
}
|
||||
raw, err := json.Marshal(resp.Data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("序列化子产品(%s)数据失败: %w", resp.ApiCode, err)
|
||||
}
|
||||
src.Responses = append(src.Responses, sourceResponse{
|
||||
ApiCode: resp.ApiCode,
|
||||
Data: raw,
|
||||
Success: resp.Success,
|
||||
})
|
||||
}
|
||||
|
||||
if len(src.Responses) == 0 {
|
||||
return nil, errors.New("组合包子产品全部调用失败")
|
||||
}
|
||||
|
||||
return buildSourceContext(src)
|
||||
}
|
||||
1783
internal/domains/api/services/processors/comb/combhzy2_transform.go
Normal file
1783
internal/domains/api/services/processors/comb/combhzy2_transform.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user