add coment01
This commit is contained in:
@@ -219,3 +219,8 @@ type COMB86PMReq struct {
|
|||||||
type QCXG7A2BReq struct {
|
type QCXG7A2BReq struct {
|
||||||
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
IDCard string `json:"id_card" validate:"required,validIDCard"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type COMENT01Req struct {
|
||||||
|
EntName string `json:"ent_name" validate:"required,min=1,validName"`
|
||||||
|
EntCode string `json:"ent_code" validate:"required,validUSCI"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ func registerAllProcessors(combService *comb.CombService) {
|
|||||||
"QYGL8271": qygl.ProcessQYGL8271Request,
|
"QYGL8271": qygl.ProcessQYGL8271Request,
|
||||||
"QYGLB4C0": qygl.ProcessQYGLB4C0Request,
|
"QYGLB4C0": qygl.ProcessQYGLB4C0Request,
|
||||||
"QYGL23T7": qygl.ProcessQYGL23T7Request, // 企业三要素验证
|
"QYGL23T7": qygl.ProcessQYGL23T7Request, // 企业三要素验证
|
||||||
|
"COMENT01": qygl.ProcessCOMENT01Request, // 企业风险报告
|
||||||
|
|
||||||
// YYSY系列处理器
|
// YYSY系列处理器
|
||||||
"YYSYD50F": yysy.ProcessYYSYD50FRequest,
|
"YYSYD50F": yysy.ProcessYYSYD50FRequest,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"tyapi-server/internal/domains/api/dto"
|
"tyapi-server/internal/domains/api/dto"
|
||||||
"tyapi-server/internal/domains/api/services/processors"
|
"tyapi-server/internal/domains/api/services/processors"
|
||||||
@@ -48,6 +49,7 @@ func ProcessFLXG0V4BRequest(ctx context.Context, params []byte, deps *processors
|
|||||||
"inquired_auth": fmt.Sprintf("authed:%s", paramsDto.AuthDate),
|
"inquired_auth": fmt.Sprintf("authed:%s", paramsDto.AuthDate),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
log.Println("reqData", reqData)
|
||||||
respBytes, err := deps.WestDexService.CallAPI("G22SC01", reqData)
|
respBytes, err := deps.WestDexService.CallAPI("G22SC01", reqData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 数据源错误
|
// 数据源错误
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package qygl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"tyapi-server/internal/domains/api/dto"
|
||||||
|
"tyapi-server/internal/domains/api/services/processors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProcessCOMENT01Request COMENT01 API处理方法 - 企业风险报告
|
||||||
|
func ProcessCOMENT01Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
|
||||||
|
var paramsDto dto.COMENT01Req
|
||||||
|
if err := json.Unmarshal(params, ¶msDto); err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrInvalidParam, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建请求体
|
||||||
|
requestBody := map[string]string{
|
||||||
|
"company_name": paramsDto.EntName,
|
||||||
|
"credit_code": paramsDto.EntCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
requestBodyBytes, err := json.Marshal(requestBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建HTTP请求
|
||||||
|
url := "https://api.v1.tybigdata.com/api/v1/enterprise/risk-report"
|
||||||
|
req, err := http.NewRequestWithContext(ctx, "POST", url, strings.NewReader(string(requestBodyBytes)))
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置请求头
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("apikey", "1000000$BUsWYV5DQ3CSvPWYYegkr3$TZmMl7WZ29Zj5gcRmgieoqVs1oBjOt3BPWGq7iTSF5o")
|
||||||
|
|
||||||
|
// 发送请求
|
||||||
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrDatasource, err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// 检查HTTP状态码
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, fmt.Errorf("%s: HTTP状态码异常: %d", processors.ErrDatasource, resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取响应
|
||||||
|
respBody, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("%s: %w", processors.ErrSystem, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return respBody, nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user