This commit is contained in:
2026-07-07 17:48:49 +08:00
parent 29bb73b1e8
commit bc42c7f24a
9 changed files with 283 additions and 43 deletions

View File

@@ -0,0 +1,44 @@
package qcxg
import (
"context"
"encoding/json"
"errors"
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/haiyuapi"
)
// ProcessQCXGCP77Request QCXGCP77 全国车辆配置查验车辆详情API 处理方法海宇API
func ProcessQCXGCP77Request(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) {
var paramsDto dto.QCXGCP77Req
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)
}
if deps.HaiyuapiService == nil {
return nil, errors.Join(processors.ErrSystem, errors.New("海宇API服务未初始化"))
}
reqParams := map[string]interface{}{
"vin_code": paramsDto.VinCode,
}
respBytes, err := deps.HaiyuapiService.CallAPI(ctx, "QCXGCP77", reqParams)
if 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)
}
return respBytes, nil
}