From 096798dabfd445ded2446f3d2fbc2223450e14c5 Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 26 Nov 2024 09:11:01 +0800 Subject: [PATCH] add some --- go.mod | 2 ++ go.sum | 4 +++ src/gonganxitong/common.go | 5 +++- src/main.go | 4 ++- src/renzhengshouquan/cert.go | 26 +++++++++++++++++++ .../external/tencentcloud/model/model.go | 13 ++++++++++ .../external/tencentcloud/tencentcloud.go | 10 ++++--- .../external/tencentcloud/tencentcloud.js | 7 +++++ .../external/tencentcloud/tencentcloud.json | 10 +++++++ .../external/tencentmeeting/tencentmeeting.go | 2 +- 10 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 src/renzhengshouquan/external/tencentcloud/model/model.go create mode 100644 src/renzhengshouquan/external/tencentcloud/tencentcloud.js create mode 100644 src/renzhengshouquan/external/tencentcloud/tencentcloud.json diff --git a/go.mod b/go.mod index 111e3ae..ddad786 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,8 @@ require ( github.com/go-sql-driver/mysql v1.7.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046 // indirect + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.1046 // indirect github.com/wechatpay-apiv3/wechatpay-go v0.2.20 // indirect golang.org/x/text v0.16.0 // indirect gorm.io/driver/mysql v1.5.7 // indirect diff --git a/go.sum b/go.sum index 8b4bcec..56ecda3 100644 --- a/go.sum +++ b/go.sum @@ -65,6 +65,10 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tdakkota/win32metadata v0.1.0/go.mod h1:77e6YvX0LIVW+O81fhWLnXAxxcyu/wdZdG7iwed7Fyk= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046 h1:0FvA5Rw9dGqK5CTbWlgyE1HbiND1hLsoIfne4jzWuRI= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.1046 h1:P8TrTPEWu4GjnEMyNgdYmV5jXigGtDMn+sVTLJJvW0c= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.1046/go.mod h1:ifVagKrjnvy/ibrvLZjsELEh5WdRtchM8xyUlF88BNg= github.com/tinygo-org/cbgo v0.0.4/go.mod h1:7+HgWIHd4nbAz0ESjGlJ1/v9LDU1Ox8MGzP9mah/fLk= github.com/tinygo-org/pio v0.0.0-20231216154340-cd888eb58899/go.mod h1:LU7Dw00NJ+N86QkeTGjMLNkYcEYMor6wTDpTCu0EaH8= github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= diff --git a/src/gonganxitong/common.go b/src/gonganxitong/common.go index 74af50c..40094d2 100644 --- a/src/gonganxitong/common.go +++ b/src/gonganxitong/common.go @@ -285,7 +285,7 @@ func (s Table) UploadCreate(m *ice.Message, field, uid string, arg ...string) { return } p := m.UploadSave(path.Join(nfs.USR, kit.Select(field, m.Option(model.FIELD)), uid) + nfs.PS) - s.Create(m, kit.Select(m.Option(model.FIELD), field), p, model.UID, uid) + s.Create(m, kit.Select(m.Option(model.FIELD), field), p, model.UID, uid, model.USER_UID, m.Option(model.USER_UID)) } func (s Table) ChangeStatus(m *ice.Message, place_uid, uid string, from, to int, arg ...string) *ice.Message { msg := s.ValueList(m.Spawn(), []string{place_uid, uid}, model.STATUS) @@ -531,6 +531,9 @@ func PortalCmd(portal ice.Any) { tables := Tables{Table: table} cmd := func(name string, data ice.Any) { _, cmd := ice.Cmd(kit.Keys(p, name), data) + if cmd == nil { + return + } cmd.RawHand = path.Join(path.Dir(h), name+".go") cmd.Actions[ice.CTX_INIT].Hand = icebergs.MergeHand(func(m *icebergs.Message, arg ...string) { m.Design(mdb.LIST, "", kit.JoinWord(table.Keys(table.Place, model.UID), model.UID, ice.AUTO)) diff --git a/src/main.go b/src/main.go index cfa4b57..047b38d 100644 --- a/src/main.go +++ b/src/main.go @@ -7,6 +7,8 @@ import ( _ "shylinux.com/x/community/src/huodongzuzhi" _ "shylinux.com/x/community/src/renzhengshouquan" _ "shylinux.com/x/community/src/yuehaoxitong" + + _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/model" ) func main() { print(ice.Run()) } @@ -14,4 +16,4 @@ func main() { print(ice.Run()) } func init() { ice.Info.CodeMain = "src/gonganxitong/portal.go" ice.Info.NodeMain = "web.team.gonganxitong.portal" -} +} \ No newline at end of file diff --git a/src/renzhengshouquan/cert.go b/src/renzhengshouquan/cert.go index a3dcdad..e8a3351 100644 --- a/src/renzhengshouquan/cert.go +++ b/src/renzhengshouquan/cert.go @@ -1,10 +1,17 @@ package renzhengshouquan import ( + "encoding/base64" + "shylinux.com/x/ice" "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/nfs" + // "shylinux.com/x/icebergs/base/web" "shylinux.com/x/toolkits" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" + cloudprofile "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" + ocr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr/v20181119" "shylinux.com/x/community/src/renzhengshouquan/model" ) @@ -25,6 +32,25 @@ func (s cert) List(m *ice.Message, arg ...string) { s.Select(m, model.AUTH_UID, arg[0]).PushAction(s.Remove).Action(s.Upload).Display("").DisplayCSS("") s.Button(m, "", s.Upload) } + + // _msg := m.Cmd(web.CHAT_WX_OCR, "", m.Append(model.PATH), "bizlicense") + // m.Echo(kit.Formats(_msg)) + s.BizLicenseOCR(m) +} +func (s cert) newClient(m *ice.Message, arg ...string) *ocr.Client { + msg := m.Cmd("web.team.renzhengshouquan.external.tencentcloud.tencentcloud", "4c6a8ccf186816b332ad9dc5655255dd") + credential := common.NewCredential(msg.Append("secret_id"), msg.Append("secret_key")) + client, _ := ocr.NewClient(credential, "", cloudprofile.NewClientProfile()) + return client +} +func (s cert) BizLicenseOCR(m *ice.Message, arg ...string) *ice.Message { + request := ocr.NewBizLicenseOCRRequest() + request.ImageBase64 = common.StringPtr(base64.StdEncoding.EncodeToString([]byte(m.Cmdx(nfs.CAT, m.Append(model.PATH))))) + response, err := s.newClient(m).BizLicenseOCR(request) + m.Warn(err) + m.SetAppend() + m.PushDetail(kit.Value(kit.UnMarshal(response.ToJsonString()), "Response")) + return m } func init() { ice.TeamCtxCmd(cert{}) } diff --git a/src/renzhengshouquan/external/tencentcloud/model/model.go b/src/renzhengshouquan/external/tencentcloud/model/model.go new file mode 100644 index 0000000..14dcc00 --- /dev/null +++ b/src/renzhengshouquan/external/tencentcloud/model/model.go @@ -0,0 +1,13 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +type Tencentcloud struct { + db.ModelWithUID + AuthUID string `gorm:"type:char(32);index"` + UserUID string `gorm:"type:char(32)"` + SecretID string `gorm:"type:varchar(64)"` + SecretKey string `gorm:"type:varchar(64)"` +} + +func init() { db.CmdModels("", &Tencentcloud{}) } diff --git a/src/renzhengshouquan/external/tencentcloud/tencentcloud.go b/src/renzhengshouquan/external/tencentcloud/tencentcloud.go index 9ab8279..b35cd7e 100644 --- a/src/renzhengshouquan/external/tencentcloud/tencentcloud.go +++ b/src/renzhengshouquan/external/tencentcloud/tencentcloud.go @@ -2,18 +2,22 @@ package tencentcloud import ( "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" "shylinux.com/x/community/src/renzhengshouquan" ) type tencentcloud struct { - renzhengshouquan.Tables - fields string `data:"title,content,user_uid"` - create string `name:"create title* content*" role:"leader"` + renzhengshouquan.Table + order string `data:"13"` + fields string `data:"secret_id,secret_key,user_uid"` + create string `name:"create secret_id* secret_key*" role:"leader"` remove string `name:"remove" role:"leader"` } func (s tencentcloud) List(m *ice.Message, arg ...string) { + s.ValueList(m, arg).Display("") + kit.If(m.Length() > 0, func() { m.Action() }) } func init() { ice.TeamCtxCmd(tencentcloud{}) } diff --git a/src/renzhengshouquan/external/tencentcloud/tencentcloud.js b/src/renzhengshouquan/external/tencentcloud/tencentcloud.js new file mode 100644 index 0000000..9c05c0b --- /dev/null +++ b/src/renzhengshouquan/external/tencentcloud/tencentcloud.js @@ -0,0 +1,7 @@ +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { + can.onimport.myView(can, msg, function(value) { return [ + {view: html.TITLE, list: [value.secret_id]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/renzhengshouquan/external/tencentcloud/tencentcloud.json b/src/renzhengshouquan/external/tencentcloud/tencentcloud.json new file mode 100644 index 0000000..660a6d8 --- /dev/null +++ b/src/renzhengshouquan/external/tencentcloud/tencentcloud.json @@ -0,0 +1,10 @@ +{ + "tencentcloud": "腾讯云", + "icons": { + "tencentcloud": "https://img.icons8.com/officel/80/cloud.png" + }, + "input": { + "secret_id": "SecretID", + "secret_key": "SecretKey" + } +} \ No newline at end of file diff --git a/src/renzhengshouquan/external/tencentmeeting/tencentmeeting.go b/src/renzhengshouquan/external/tencentmeeting/tencentmeeting.go index 7aa608e..d50f242 100644 --- a/src/renzhengshouquan/external/tencentmeeting/tencentmeeting.go +++ b/src/renzhengshouquan/external/tencentmeeting/tencentmeeting.go @@ -23,7 +23,7 @@ import ( type tencentmeeting struct { renzhengshouquan.Table - order string `data:"10"` + order string `data:"12"` role string `data:"leader"` fields string `data:"auth_uid,user_uid,app_id,sdk_id,secret_id,secret_key,user_id"` create string `name:"create app_id* sdk_id* secret_id* secret_key* user_id*" role:"leader"`