This commit is contained in:
Mrx
2026-01-31 12:15:42 +08:00
parent a6f858dbd3
commit ff86cb6fb9
13 changed files with 47 additions and 10 deletions

View File

@@ -533,9 +533,9 @@ func (s *FormConfigServiceImpl) generateExampleValue(fieldType reflect.Type, jso
"token": "0fc79b80371f45e2ac1c693ef9136b24", "token": "0fc79b80371f45e2ac1c693ef9136b24",
"vehicle_name": "车型名称,示例:凌派 2020款 锐·混动 1.5L 锐·舒适版", "vehicle_name": "车型名称,示例:凌派 2020款 锐·混动 1.5L 锐·舒适版",
"vehicle_location": "车辆所在地,示例:北京市", "vehicle_location": "车辆所在地,示例:北京市",
"first_registrationdate": "首次登记日期示例2020-01-01", "first_registrationdate": "初登日期示例2020-05",
"color": "颜色,示例:白色", "color": "示例:白色",
"plate_color": "车牌颜色,示例:蓝", "plate_color": "车牌颜色0蓝色1黄色2黑色3白色4渐变绿色5黄绿双拼色6蓝白渐变色7临时牌照11绿色12红色默认标准车牌查蓝色新能源车牌查绿色",
} }
if example, exists := exampleMap[jsonTag]; exists { if example, exists := exampleMap[jsonTag]; exists {
@@ -604,7 +604,7 @@ func (s *FormConfigServiceImpl) generatePlaceholder(jsonTag string, fieldType st
"token": "请输入token", "token": "请输入token",
"vehicle_name": "请输入车型名称", "vehicle_name": "请输入车型名称",
"vehicle_location": "请输入车辆所在地", "vehicle_location": "请输入车辆所在地",
"first_registrationdate": "请输入首次登记日期", "first_registrationdate": "请输入首次登记日期格式YYYY-MM",
"color": "请输入颜色", "color": "请输入颜色",
"plate_color": "请输入车牌颜色", "plate_color": "请输入车牌颜色",
} }
@@ -675,9 +675,9 @@ func (s *FormConfigServiceImpl) generateDescription(jsonTag string, validation s
"image_url": "行驶证图片地址必填请提供行驶证的图片URL地址", "image_url": "行驶证图片地址必填请提供行驶证的图片URL地址",
"reg_url": "车辆登记证图片地址非必填请提供车辆登记证的图片URL地址", "reg_url": "车辆登记证图片地址非必填请提供车辆登记证的图片URL地址",
"token": "token采集及获取结果时所使用的凭证有效期2个小时在此时效内应用侧可以发起采集请求重复的采集所触发的结果会被忽略和结果查询", "token": "token采集及获取结果时所使用的凭证有效期2个小时在此时效内应用侧可以发起采集请求重复的采集所触发的结果会被忽略和结果查询",
"vehicle_name": "车型名称", "vehicle_name": "车型名称,示例:凌派 2020款 锐·混动 1.5L 锐·舒适版",
"vehicle_location": "车辆所在地", "vehicle_location": "车辆所在地",
"first_registrationdate": "首次登记日期", "first_registrationdate": "首次登记日期格式YYYY-MM",
"color": "颜色", "color": "颜色",
"plate_color": "车牌颜色", "plate_color": "车牌颜色",
} }

View File

@@ -37,6 +37,9 @@ func ProcessJRZQACABERequest(ctx context.Context, params []byte, deps *processor
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -34,6 +34,9 @@ func ProcessQCXG3B8ZRequest(ctx context.Context, params []byte, deps *processors
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -36,6 +36,9 @@ func ProcessQCXG3M7ZRequest(ctx context.Context, params []byte, deps *processors
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -22,8 +22,8 @@ func ProcessQCXG5U0ZRequest(ctx context.Context, params []byte, deps *processors
} }
reqParams := map[string]interface{}{ reqParams := map[string]interface{}{
"key": "7c8122677476dd2621f574976f1a9fde", "key": "7c8122677476dd2621f574976f1a9fde",
"vin": paramsDto.VinCode, "vinList": paramsDto.VinCode,
} }
apiPath := "/communication/personal/10479" apiPath := "/communication/personal/10479"
@@ -32,6 +32,9 @@ func ProcessQCXG5U0ZRequest(ctx context.Context, params []byte, deps *processors
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -34,6 +34,9 @@ func ProcessQCXG9F5CERequest(ctx context.Context, params []byte, deps *processor
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -34,6 +34,9 @@ func ProcessQCXGM7R9Request(ctx context.Context, params []byte, deps *processors
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -34,6 +34,9 @@ func ProcessQCXGP1W3Request(ctx context.Context, params []byte, deps *processors
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -34,6 +34,9 @@ func ProcessQCXGU2K4Request(ctx context.Context, params []byte, deps *processors
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -36,6 +36,9 @@ func ProcessQCXGY7F2Request(ctx context.Context, params []byte, deps *processors
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -36,6 +36,9 @@ func ProcessYYSYK9R4Request(ctx context.Context, params []byte, deps *processors
if errors.Is(err, shujubao.ErrDatasource) { if errors.Is(err, shujubao.ErrDatasource) {
return nil, errors.Join(processors.ErrDatasource, err) return nil, errors.Join(processors.ErrDatasource, err)
} }
if errors.Is(err, shujubao.ErrQueryEmpty) {
return nil, errors.Join(processors.ErrNotFound, err)
}
return nil, errors.Join(processors.ErrSystem, err) return nil, errors.Join(processors.ErrSystem, err)
} }

View File

@@ -31,12 +31,15 @@ func NewShujubaoError(code, message string) *ShujubaoError {
// 数据宝全系统错误码与描述映射Code -> Desc // 数据宝全系统错误码与描述映射Code -> Desc
var systemErrorCodeDesc = map[string]string{ var systemErrorCodeDesc = map[string]string{
"10000": "成功", "10000": "成功",
"10001": "参数传入有误", "10001": "查空",
"10002": "查询失败", "10002": "查询失败",
"10003": "系统处理异常", "10003": "系统处理异常",
"10004": "系统处理超时", "10004": "系统处理超时",
"10005": "服务异常", "10005": "服务异常",
"10006": "查无", "10006": "查无",
"10017": "查询失败",
"10018": "参数错误",
"10019": "系统异常",
"10020": "同一参数请求次数超限", "10020": "同一参数请求次数超限",
"99999": "其他错误", "99999": "其他错误",
"999": "接口处理异常", "999": "接口处理异常",

View File

@@ -20,6 +20,7 @@ import (
var ( var (
ErrDatasource = errors.New("数据源异常") ErrDatasource = errors.New("数据源异常")
ErrSystem = errors.New("系统异常") ErrSystem = errors.New("系统异常")
ErrQueryEmpty = errors.New("查询为空")
) )
// ShujubaoResp 数据宝 API 通用响应(按实际文档调整) // ShujubaoResp 数据宝 API 通用响应(按实际文档调整)
@@ -253,7 +254,10 @@ func (s *ShujubaoService) CallAPI(ctx context.Context, apiPath string, params ma
} }
code := shujubaoResp.Code code := shujubaoResp.Code
if code != "10000" && code != "10006" { if code == "10001" || code == "10006" {
return nil, ErrQueryEmpty
}
if code != "10000" {
shujubaoErr := NewShujubaoErrorFromCode(code, shujubaoResp.Message) shujubaoErr := NewShujubaoErrorFromCode(code, shujubaoResp.Message)
if s.logger != nil { if s.logger != nil {
s.logger.LogError(requestID, transactionID, apiPath, shujubaoErr, params) s.logger.LogError(requestID, transactionID, apiPath, shujubaoErr, params)