From 36c8e4e36eaad8a3edab6daac9f2843ff8947d8b Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 2 Dec 2024 09:39:15 +0800 Subject: [PATCH] add some --- go.mod | 3 +- go.sum | 4 + src/gonganxitong/document.go | 15 +++- src/gonganxitong/portal.go | 8 +- src/option.go | 2 + .../tencentcloud/realname/realname.shy | 5 ++ .../external/tencentcloud/smh/model/model.go | 22 ++++++ .../external/tencentcloud/smh/smh.go | 73 +++++++++++++++++++ .../external/tencentcloud/smh/smh.js | 8 ++ .../external/tencentcloud/smh/smh.json | 10 +++ .../external/tencentcloud/tencentcloud.go | 2 +- .../external/tencentcloud/tencentcloud.shy | 4 + .../external/tencentdocument/model/model.go | 13 ++++ .../tencentdocument/tencentdocument.go | 24 +++++- .../tencentdocument/tencentdocument.js | 7 ++ .../tencentdocument/tencentdocument.json | 10 +++ 16 files changed, 198 insertions(+), 12 deletions(-) create mode 100644 src/renzhengshouquan/external/tencentcloud/smh/model/model.go create mode 100644 src/renzhengshouquan/external/tencentcloud/smh/smh.go create mode 100644 src/renzhengshouquan/external/tencentcloud/smh/smh.js create mode 100644 src/renzhengshouquan/external/tencentcloud/smh/smh.json create mode 100644 src/renzhengshouquan/external/tencentcloud/tencentcloud.shy create mode 100644 src/renzhengshouquan/external/tencentdocument/model/model.go create mode 100644 src/renzhengshouquan/external/tencentdocument/tencentdocument.js create mode 100644 src/renzhengshouquan/external/tencentdocument/tencentdocument.json diff --git a/go.mod b/go.mod index 18385cc..36348d4 100644 --- a/go.mod +++ b/go.mod @@ -25,8 +25,9 @@ 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.1047 // indirect + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1051 // indirect github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.1046 // indirect + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/smh v1.0.1051 // indirect github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.1047 // indirect github.com/wechatpay-apiv3/wechatpay-go v0.2.20 // indirect golang.org/x/text v0.16.0 // indirect diff --git a/go.sum b/go.sum index bb463db..ae29e60 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,12 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046 h1:0Fv github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1046/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1047 h1:eLEUnmSd82NBMNwergC/5RGqJqNDbsvprPtnG1UhxDI= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1047/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1051 h1:3mg0L9vv9eO8UN4Oa7vNawe6yUIuXf9D0Q79rUmnblo= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1051/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/tencentcloud/tencentcloud-sdk-go/tencentcloud/smh v1.0.1051 h1:P7q/ROrOi/M/VzM4ADMeALj94zJaW/zIGvJ6xe5BBkw= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/smh v1.0.1051/go.mod h1:dVFt5mYSzAtQ2uLOBavl9G4KHrjJJOCLqtrzvW+h0tg= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.1047 h1:FF8uERgTL9NKxgUHrKHbVefETVL3J6DeL9t6qvIT5yI= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.1047/go.mod h1:3tgFFSlybx6XyhvLWpnSjWYFMedTyQC9oyh8CH1Ak28= github.com/tinygo-org/cbgo v0.0.4/go.mod h1:7+HgWIHd4nbAz0ESjGlJ1/v9LDU1Ox8MGzP9mah/fLk= diff --git a/src/gonganxitong/document.go b/src/gonganxitong/document.go index 382dd4f..91b43e0 100644 --- a/src/gonganxitong/document.go +++ b/src/gonganxitong/document.go @@ -9,7 +9,20 @@ type document struct { } func (s document) List(m *ice.Message, arg ...string) { - m.Echo("功能正在开发中,敬请等待。") + m.Action(s.Auth) +} +func (s document) Auth(m *ice.Message, arg ...string) { + if m.Option("code") == "" { + m.Cmdy(DocumentVendor, DocumentVendor.AuthLink, m.PrefixKey()+"/action/auth", m.Option(s.PLACE_UID)) + } else { + m.Cmdy(DocumentVendor, DocumentVendor.GetToken) + } } func init() { ice.TeamCtxCmd(document{Table: newTable()}) } + +var DocumentVendor interface { + AuthLink(m *ice.Message, arg ...string) + GetToken(m *ice.Message, arg ...string) + GetList(m *ice.Message, arg ...string) +} diff --git a/src/gonganxitong/portal.go b/src/gonganxitong/portal.go index e100308..ec65619 100644 --- a/src/gonganxitong/portal.go +++ b/src/gonganxitong/portal.go @@ -104,15 +104,11 @@ func (s Portal) Run(m *ice.Message, arg ...string) { if !m.WarnNotRight(!s.IsWorker(m)) { m.Cmdy(arg) } - return - } - if role == "leader" { + } else if role == "leader" { if !m.WarnNotRight(!s.IsLeader(m)) { m.Cmdy(arg) } - return - } - if !m.Cmdy(s.Place, s.CheckRole, kit.Split(role)).IsErr() { + } else if !m.Cmdy(s.Place, s.CheckRole, kit.Split(role)).IsErr() { m.Cmdy(arg) } } diff --git a/src/option.go b/src/option.go index 495f03c..a43e746 100644 --- a/src/option.go +++ b/src/option.go @@ -9,9 +9,11 @@ import ( _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/ocr" _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/realname" _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/realname/model" + _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/smh" _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/sms" _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/sms/model" _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentdocument" + _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentdocument/model" _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentmeeting" _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentmeeting/model" _ "shylinux.com/x/community/src/renzhengshouquan/external/tencentqian" diff --git a/src/renzhengshouquan/external/tencentcloud/realname/realname.shy b/src/renzhengshouquan/external/tencentcloud/realname/realname.shy index 6562bec..8d5ee8b 100644 --- a/src/renzhengshouquan/external/tencentcloud/realname/realname.shy +++ b/src/renzhengshouquan/external/tencentcloud/realname/realname.shy @@ -6,4 +6,9 @@ refer ` refer ` 后台 https://console.cloud.tencent.com/servicemarket/services/market-dw3yg5tm8 文档 https://market.cloud.tencent.com/products/17673 +` +refer ` +实名 https://market.cloud.tencent.com/products/30034 +要素 https://console.cloud.tencent.com/servicemarket/services/market-2qkoxdj5i +要素 https://market.cloud.tencent.com/products/30034?keyword=%E6%89%8B%E6%9C%BA%E4%B8%89%E8%A6%81%E7%B4%A0%E5%AE%9E%E5%90%8D%E8%AE%A4%E8%AF%81 ` \ No newline at end of file diff --git a/src/renzhengshouquan/external/tencentcloud/smh/model/model.go b/src/renzhengshouquan/external/tencentcloud/smh/model/model.go new file mode 100644 index 0000000..b35ce55 --- /dev/null +++ b/src/renzhengshouquan/external/tencentcloud/smh/model/model.go @@ -0,0 +1,22 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +const ( + NAME = "name" + INFO = "info" + LIBRARY_ID = "library_id" + LIBRARY_SECRET = "library_secret" +) + +type Smh struct { + db.ModelWithUID + AuthUID string `gorm:"type:char(32);index"` + UserUID string `gorm:"type:char(32);index"` + Name string `gorm:"type:varchar(32)"` + Info string `gorm:"type:varchar(64)"` + LibraryID string `gorm:"type:varchar(32)"` + LibrarySecret string `gorm:"type:varchar(64)"` +} + +func init() { db.CmdModels("", &Smh{}) } diff --git a/src/renzhengshouquan/external/tencentcloud/smh/smh.go b/src/renzhengshouquan/external/tencentcloud/smh/smh.go new file mode 100644 index 0000000..dd10f1b --- /dev/null +++ b/src/renzhengshouquan/external/tencentcloud/smh/smh.go @@ -0,0 +1,73 @@ +package smh + +import ( + "net/http" + + "shylinux.com/x/ice" + "shylinux.com/x/icebergs/base/web" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/community/src/renzhengshouquan" + "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud" + "shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/smh/model" + + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" + sdk "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/smh/v20210712" +) + +type smh struct { + renzhengshouquan.Table + tencentcloud.Tencentcloud + order string `data:"18"` + fields string `data:"name,info,user_uid"` + create string `name:"create name* info*" role:"leader"` + remove string `name:"remove" role:"leader"` +} + +func (s smh) Create(m *ice.Message, arg ...string) { + request := sdk.NewCreateLibraryRequest() + request.Name = common.StringPtr(m.Option(model.NAME)) + request.Remark = common.StringPtr(m.Option(model.INFO)) + request.LibraryExtension = &sdk.LibraryExtension{ + IsFileLibrary: common.BoolPtr(false), + IsMultiSpace: common.BoolPtr(true), + IsMultiAlbum: common.BoolPtr(true), + } + response, err := s.newClient(m).CreateLibrary(request) + if m.Warn(err) { + return + } + req := sdk.NewDescribeLibrarySecretRequest() + req.LibraryId = response.Response.LibraryId + res, err := s.newClient(m).DescribeLibrarySecret(req) + if m.Warn(err) { + return + } + s.Table.Create(m, kit.Simple(m.OptionSimple(model.NAME, model.INFO), model.LIBRARY_ID, *res.Response.LibraryId, model.LIBRARY_SECRET, *res.Response.LibrarySecret)...) +} +func (s smh) List(m *ice.Message, arg ...string) { + s.ValueList(m, arg).Display("") + return + + req := sdk.NewDescribeLibrariesRequest() + res, err := s.newClient(m).DescribeLibraries(req) + m.Warn(err) + kit.For(kit.Value(kit.UnMarshal(res.ToJsonString()), "Response.List"), func(value ice.Map) { + m.PushRecord(value, "Name", "Remark", "LibraryId", "DirNum", "FileNum") + }) + m.PushAction(s.Token) + m.Display("") +} +func (s smh) Token(m *ice.Message, arg ...string) { + m.Cmdy(web.SPIDE, ice.DEV, http.MethodGet, "https://api.tencentsmh.cn/api/v1/token", + "library_id", "smh2xn3qy4qixh16", + "library_secret", "42611fef1061b3f24e693d887ad5c904c9875b0199197b576015525c3317f2c0", + ) +} + +func init() { ice.TeamCtxCmd(smh{}) } + +func (s smh) newClient(m *ice.Message, arg ...string) *sdk.Client { + c, _ := sdk.NewClient(s.NewCredential(m), "", s.NewProfile(m)) + return c +} diff --git a/src/renzhengshouquan/external/tencentcloud/smh/smh.js b/src/renzhengshouquan/external/tencentcloud/smh/smh.js new file mode 100644 index 0000000..b0fa7cb --- /dev/null +++ b/src/renzhengshouquan/external/tencentcloud/smh/smh.js @@ -0,0 +1,8 @@ +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { + can.onimport.myView(can, msg, function(value) { return [ + {view: html.TITLE, list: [value.name]}, + {view: html.OUTPUT, list: [value.info]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/renzhengshouquan/external/tencentcloud/smh/smh.json b/src/renzhengshouquan/external/tencentcloud/smh/smh.json new file mode 100644 index 0000000..eabc09b --- /dev/null +++ b/src/renzhengshouquan/external/tencentcloud/smh/smh.json @@ -0,0 +1,10 @@ +{ + "smh": "智能媒资托管", + "icons": { + "smh": "https://img.icons8.com/officel/80/stack-of-photos.png" + }, + "input": { + "secret_id": "SecretID", + "secret_key": "SecretKey" + } +} \ No newline at end of file diff --git a/src/renzhengshouquan/external/tencentcloud/tencentcloud.go b/src/renzhengshouquan/external/tencentcloud/tencentcloud.go index 68e2b23..93a83f2 100644 --- a/src/renzhengshouquan/external/tencentcloud/tencentcloud.go +++ b/src/renzhengshouquan/external/tencentcloud/tencentcloud.go @@ -43,7 +43,7 @@ func (s Tencentcloud) NewProfile(m *ice.Message, arg ...string) *profile.ClientP func (s Tencentcloud) ImageData(m *ice.Message, arg ...string) string { return base64.StdEncoding.EncodeToString([]byte(m.Cmdx(nfs.CAT, arg[0]))) } -func (s Tencentcloud) ParseResponse(m *ice.Message, res interface{ ToJsonString() string }, err error) { +func (s Tencentcloud) ParseResponse(m *ice.Message, res interface{ ToJsonString() string }, err error, arg ...string) { if !m.Warn(err) { m.PushDetail(kit.Value(kit.UnMarshal(res.ToJsonString()), "Response")) } diff --git a/src/renzhengshouquan/external/tencentcloud/tencentcloud.shy b/src/renzhengshouquan/external/tencentcloud/tencentcloud.shy new file mode 100644 index 0000000..da84509 --- /dev/null +++ b/src/renzhengshouquan/external/tencentcloud/tencentcloud.shy @@ -0,0 +1,4 @@ +chapter "腾讯云" +refer ` +后台 https://console.cloud.tencent.com/ +` \ No newline at end of file diff --git a/src/renzhengshouquan/external/tencentdocument/model/model.go b/src/renzhengshouquan/external/tencentdocument/model/model.go new file mode 100644 index 0000000..9069b01 --- /dev/null +++ b/src/renzhengshouquan/external/tencentdocument/model/model.go @@ -0,0 +1,13 @@ +package model + +import "shylinux.com/x/mysql-story/src/db" + +type Tencentdocument 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("", &Tencentdocument{}) } diff --git a/src/renzhengshouquan/external/tencentdocument/tencentdocument.go b/src/renzhengshouquan/external/tencentdocument/tencentdocument.go index f94b054..388547e 100644 --- a/src/renzhengshouquan/external/tencentdocument/tencentdocument.go +++ b/src/renzhengshouquan/external/tencentdocument/tencentdocument.go @@ -2,18 +2,36 @@ package tencentdocument import ( "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + "shylinux.com/x/community/src/gonganxitong" "shylinux.com/x/community/src/renzhengshouquan" + "shylinux.com/x/community/src/renzhengshouquan/model" ) type tencentdocument 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 tencentdocument) List(m *ice.Message, arg ...string) { + s.ValueList(m, arg).Display("") + kit.If(m.Length() > 0, func() { m.Action() }) +} +func (s tencentdocument) AuthLink(m *ice.Message, arg ...string) { + s.Select(m, model.AUTH_UID, s.GetAuthUID(m)) + m.Echo(kit.MergeURL("https://docs.qq.com/oauth/v2/authorize", + "client_id", m.Append("secret_id"), + "redirect_uri", m.MergePodCmd("", m.PrefixKey()), + "response_type", "code", + "scope", "all", + "state", m.Option(model.PLACE_UID), + )) } func init() { ice.TeamCtxCmd(tencentdocument{}) } + +func init() { gonganxitong.DocumentVendor = tencentdocument{} } diff --git a/src/renzhengshouquan/external/tencentdocument/tencentdocument.js b/src/renzhengshouquan/external/tencentdocument/tencentdocument.js new file mode 100644 index 0000000..9c05c0b --- /dev/null +++ b/src/renzhengshouquan/external/tencentdocument/tencentdocument.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/tencentdocument/tencentdocument.json b/src/renzhengshouquan/external/tencentdocument/tencentdocument.json new file mode 100644 index 0000000..99c3a72 --- /dev/null +++ b/src/renzhengshouquan/external/tencentdocument/tencentdocument.json @@ -0,0 +1,10 @@ +{ + "tencentdocument": "腾讯文档", + "icons": { + "tencentdocument": "https://img.icons8.com/officel/80/documents.png" + }, + "input": { + "secret_id": "SecretID", + "secret_key": "SecretKey" + } +} \ No newline at end of file