This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-12-02 09:39:15 +08:00
parent 7629063746
commit 36c8e4e36e
16 changed files with 198 additions and 12 deletions

3
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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)
}

View File

@ -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)
}
}

View File

@ -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"

View File

@ -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
`

View File

@ -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{}) }

View File

@ -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
}

View File

@ -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]},
] })
},
})

View File

@ -0,0 +1,10 @@
{
"smh": "智能媒资托管",
"icons": {
"smh": "https://img.icons8.com/officel/80/stack-of-photos.png"
},
"input": {
"secret_id": "SecretID",
"secret_key": "SecretKey"
}
}

View File

@ -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"))
}

View File

@ -0,0 +1,4 @@
chapter "腾讯云"
refer `
后台 https://console.cloud.tencent.com/
`

View File

@ -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{}) }

View File

@ -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{} }

View File

@ -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]},
] })
},
})

View File

@ -0,0 +1,10 @@
{
"tencentdocument": "腾讯文档",
"icons": {
"tencentdocument": "https://img.icons8.com/officel/80/documents.png"
},
"input": {
"secret_id": "SecretID",
"secret_key": "SecretKey"
}
}