fix upload
This commit is contained in:
parent
6f0b876dfc
commit
c3811cf8d2
@ -7,19 +7,20 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/qiniu/go-sdk/v7/storagev2/credentials"
|
|
||||||
"github.com/qiniu/go-sdk/v7/storagev2/http_client"
|
|
||||||
"github.com/qiniu/go-sdk/v7/storagev2/uploader"
|
|
||||||
"tianyuan-api/apps/gateway/internal/svc"
|
|
||||||
"tianyuan-api/apps/gateway/internal/types"
|
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"tianyuan-api/apps/gateway/internal/svc"
|
||||||
|
"tianyuan-api/apps/gateway/internal/types"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/qiniu/go-sdk/v7/storagev2/credentials"
|
||||||
|
"github.com/qiniu/go-sdk/v7/storagev2/http_client"
|
||||||
|
"github.com/qiniu/go-sdk/v7/storagev2/uploader"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -65,15 +66,15 @@ func (l *UploadBusinessLicenseLogic) UploadBusinessLicense(r *http.Request) (res
|
|||||||
|
|
||||||
// 5. 调用百度智能云进行营业执照识别
|
// 5. 调用百度智能云进行营业执照识别
|
||||||
tempFilePath := tempFile.Name()
|
tempFilePath := tempFile.Name()
|
||||||
fileBytes, err := os.ReadFile(tempFilePath)
|
// fileBytes, err := os.ReadFile(tempFilePath)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, fmt.Errorf("读取临时文件失败: %v", err)
|
// return nil, fmt.Errorf("读取临时文件失败: %v", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
licenseInfo, err := l.RecognizeBusinessLicense(fileBytes)
|
// licenseInfo, err := l.RecognizeBusinessLicense(fileBytes)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, fmt.Errorf("营业执照识别失败: %v", err)
|
// return nil, fmt.Errorf("营业执照识别失败: %v", err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 6. 生成新的文件名
|
// 6. 生成新的文件名
|
||||||
newFileName := l.GenerateFileName("business_license_", handler.Filename)
|
newFileName := l.GenerateFileName("business_license_", handler.Filename)
|
||||||
@ -87,9 +88,12 @@ func (l *UploadBusinessLicenseLogic) UploadBusinessLicense(r *http.Request) (res
|
|||||||
// 8. 返回百度智能云的识别信息和图片URL给前端
|
// 8. 返回百度智能云的识别信息和图片URL给前端
|
||||||
return &types.UploadBusinessLicenseResp{
|
return &types.UploadBusinessLicenseResp{
|
||||||
Url: imageUrl,
|
Url: imageUrl,
|
||||||
EnterpriseName: licenseInfo["company_name"],
|
// EnterpriseName: licenseInfo["company_name"],
|
||||||
CreditCode: licenseInfo["credit_code"],
|
// CreditCode: licenseInfo["credit_code"],
|
||||||
LegalPerson: licenseInfo["legal_person"],
|
// LegalPerson: licenseInfo["legal_person"],
|
||||||
|
EnterpriseName: "",
|
||||||
|
CreditCode: "",
|
||||||
|
LegalPerson: "",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user