优化整体

This commit is contained in:
hoteas
2022-03-13 01:48:54 +08:00
parent e49164fa81
commit 5c64580378
22 changed files with 312 additions and 289 deletions
+26 -10
View File
@@ -8,16 +8,32 @@ import (
ocr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr/v20181119"
)
var credential = common.NewCredential(
"AKIDOgT8cKCQksnY7yKATaYO7j9ORJzSYohP",
"GNXgjdN4czA9ya0FNMApVJzTmsmU0KSN",
)
type tencent struct {
secretId string
secretKey string
credential *common.Credential
}
func OCRCOMPANY(base64Str string) string {
var Tencent = tencent{}
func (that *tencent) Init(secretId, secretKey string) {
// 云市场分配的密钥Id
//secretId := "xxxx"
//// 云市场分配的密钥Key
//secretKey := "xxxx"
that.secretId = secretId
that.secretKey = secretKey
that.credential = common.NewCredential(
"AKIDOgT8cKCQksnY7yKATaYO7j9ORJzSYohP",
"GNXgjdN4czA9ya0FNMApVJzTmsmU0KSN",
)
}
func (that *tencent) OCRCOMPANY(base64Str string) string {
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
client, _ := ocr.NewClient(credential, "ap-guangzhou", cpf)
client, _ := ocr.NewClient(that.credential, "ap-guangzhou", cpf)
request := ocr.NewBizLicenseOCRRequest()
@@ -38,11 +54,11 @@ func OCRCOMPANY(base64Str string) string {
return response.ToJsonString()
}
func OCR(base64Str string) string {
func (that *tencent) OCR(base64Str string) string {
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
client, _ := ocr.NewClient(credential, "ap-guangzhou", cpf)
client, _ := ocr.NewClient(that.credential, "ap-guangzhou", cpf)
request := ocr.NewGeneralAccurateOCRRequest()
@@ -63,11 +79,11 @@ func OCR(base64Str string) string {
return response.ToJsonString()
}
func Qrcode(base64Str string) string {
func (that *tencent) Qrcode(base64Str string) string {
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "ocr.tencentcloudapi.com"
client, _ := ocr.NewClient(credential, "ap-guangzhou", cpf)
client, _ := ocr.NewClient(that.credential, "ap-guangzhou", cpf)
request := ocr.NewQrcodeOCRRequest()