This commit is contained in:
Mrx
2026-03-05 10:54:16 +08:00
parent 4ee6e891cd
commit c0898e6829
2 changed files with 11 additions and 2 deletions

View File

@@ -599,6 +599,7 @@ type YYSY6F2BReq struct {
type IVYZOCR1Req struct { type IVYZOCR1Req struct {
PhotoData string `json:"photo_data" validate:"required,validBase64Image"` PhotoData string `json:"photo_data" validate:"required,validBase64Image"`
} }
type YYSY8B1CReq struct { type YYSY8B1CReq struct {
MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"` MobileNo string `json:"mobile_no" validate:"required,min=11,max=11,validMobileNo"`

View File

@@ -20,9 +20,17 @@ func ProcessIVYZOCR2Request(ctx context.Context, params []byte, deps *processors
if err := deps.Validator.ValidateStruct(paramsDto); err != nil { if err := deps.Validator.ValidateStruct(paramsDto); err != nil {
return nil, errors.Join(processors.ErrInvalidParam, err) return nil, errors.Join(processors.ErrInvalidParam, err)
} }
if paramsDto.PhotoData == "" && paramsDto.ImageUrl == "" {
return nil, errors.Join(processors.ErrInvalidParam, errors.New("photo_data or image_url is required"))
}
reqFormData := map[string]interface{}{ // 2选1有值的用对应 key空则用另一个
"photo_data": paramsDto.PhotoData, reqFormData := make(map[string]interface{})
if paramsDto.PhotoData != "" {
reqFormData["image"] = paramsDto.PhotoData
} else {
reqFormData["url"] = paramsDto.ImageUrl
} }
// 以表单方式调用数脉 API参数在 CallAPIForm 内转为 application/x-www-form-urlencoded // 以表单方式调用数脉 API参数在 CallAPIForm 内转为 application/x-www-form-urlencoded