This commit is contained in:
Mrx
2026-01-28 16:21:57 +08:00
parent b2f0b47896
commit 482644a914
5 changed files with 84 additions and 2 deletions

View File

@@ -0,0 +1,56 @@
package qygl
import (
"context"
"encoding/json"
"errors"
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/zhicha"
)
// ProcessQYGL5S1Request QYGL5S1 API处理方法 - 企业司法涉诉V2
func ProcessQYGL5S1Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.QYGL5S1Req
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)
}
encryptedEntCode, err := deps.ZhichaService.Encrypt(paramsDto.EntCode)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
encryptedEntName, err := deps.ZhichaService.Encrypt(paramsDto.EntName)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
reqData := map[string]interface{}{
"enterpriseNo": encryptedEntCode,
"enterpriseName": encryptedEntName,
}
respData, err := deps.ZhichaService.CallAPI(ctx, "ZCI088", reqData)
if err != nil {
if errors.Is(err, zhicha.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err)
} else {
return nil, errors.Join(processors.ErrSystem, err)
}
}
// 将响应数据转换为JSON字节
respBytes, err := json.Marshal(respData)
if err != nil {
return nil, errors.Join(processors.ErrSystem, err)
}
return respBytes, nil
}