This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-11-21 23:12:28 +08:00
parent 7f012927ca
commit fe9ffe1fdc
11 changed files with 167 additions and 143 deletions

View File

@ -31,15 +31,17 @@ type Placer interface {
TransValue(m *ice.Message, key string, arg ...string) string
}
type Container interface {
Keys(target ice.Any, k string) string
FindOrCreateByName(m *ice.Message, arg ...string)
}
type Table struct {
db.Table
PLACE_UID string
UserPlace UserPlacer
Place Placer
Street Container
STREET_UID string
PLACE_UID string
checkRole string `name:"checkRole role"`
inputs string `name:"inputs" role:"void"`
list string `name:"list place_uid uid auto" role:"void"`
@ -180,6 +182,13 @@ func (s Table) Select(m *ice.Message, arg ...string) *ice.Message {
kit.If(m.Length() > 0, func() { s.UserPlaceInit(m) })
return m
}
func (s Table) InsertOrUpdate(m *ice.Message, arg []string, args ...string) {
if s.Select(m, args...).Length() > 0 {
s.Update(m, arg, args...)
} else {
s.Insert(m, arg...)
}
}
func (s Table) SelectDetail(m *ice.Message, arg ...string) *ice.Message {
return s.FieldsDefault(m).Table.SelectDetail(m, arg...)
}
@ -503,7 +512,7 @@ func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
func newTables() Tables { return Tables{Table: newTable()} }
func newTable() Table { return NewTable(userPlace{}, place{}, street{}) }
func NewTable(userPlace UserPlacer, place Placer, street Container) Table {
return Table{PLACE_UID: place.Keys(place, model.UID), UserPlace: userPlace, Place: place, Street: street}
return Table{UserPlace: userPlace, Place: place, Street: street, STREET_UID: street.Keys(street, model.UID), PLACE_UID: place.Keys(place, model.UID)}
}
func NewTables(userPlace UserPlacer, place Placer, street Container) Tables {
return Tables{Table: NewTable(userPlace, place, street)}

View File

@ -1,5 +1,4 @@
$fieldset.detail { margin-top:0 !important; height:100%; }
$output.detail { background-color:#2c2e2f !important; text-align:center; height:100% !important; }
$output.detail { background-color:#646566 !important; text-align:center; height:100% !important; }
$output.detail div.detail { border-radius:10px; background-color:var(--output-bg-color); padding:10px 10px 40px; margin:80px auto 10px; max-width:360px; position:relative; }
$output.detail div.title { font-size:20px; }
@ -9,8 +8,9 @@ $output.detail div.time { border-bottom:dashed 1px gray; font-size:24px; white-s
$output.detail div.span_time { color:gray; font-size:12px; }
$output.detail div.span_time div.zone { margin-top:5px; }
$output.detail div.date { color:gray; font-size:12px; margin-top:5px; }
$output.detail img.qrcode { width:200px !important; }
$output.detail div.logo { background-color:white; position:absolute; padding:3px 3px 0; bottom:calc(170px - 23px); left: calc(50% - 23px); }
$output.detail div.logo img { height:40px; }
$output.detail div.action input { border:var(--box-notice); background-color:var(--notice-bg-color); color:var(--notice-fg-color); font-size:18px; height:40px; width:100%; max-width:360px; }
$output.detail img.qrcode { width:200px !important; }
body.width1 $output.detail img.qrcode { border:solid 1px lightgray; border-radius:5px; margin:40px; margin-bottom:10px; }
body.dark $output.detail { background-color:#33363a !important; }
body.width1 $output.detail img.qrcode { border:var(--box-border); border-radius:5px; margin:40px; margin-bottom:10px; }

View File

@ -11,50 +11,46 @@ import (
type meeting struct {
Table
order string `data:"91"`
fields string `data:"vendor,user_id"`
join string `name:"join" help:"入会" style:"notice" role:"void"`
config string `name:"config place_uid user_id vendor"`
}
func (s meeting) Init(m *ice.Message, arg ...string) {
m.Design(s.List, "", kit.JoinWord(s.PLACE_UID, "meeting_code", ice.AUTO))
s.Table.Init(m, arg...)
}
func (s meeting) List(m *ice.Message, arg ...string) {
if !m.WarnNotRight(!s.IsWorker(m)) {
m.Option(s.PLACE_UID, arg[0])
if s.cmdy(m, s.MeetingList, s.authUID(m, arg...), arg[1:]); m.Length() > 0 {
if len(arg) == 1 {
m.PushAction(s.Join).Display("")
} else if m.IsMobileUA() {
m.Options(ice.MSG_BG, "white").EchoQRCode(m.Append(model.LINK)).Action().Display("").DisplayCSS("")
} else {
m.EchoIFrame(m.Append(model.LINK)).SetAppend().Action()
}
}
}
fields string `data:"user_id,vendor"`
config string `name:"config place_uid* user_uid* user_id* vendor*"`
create string `name:"create subject* start_time*:select@date end_time*:select@date" role:"worker"`
modify string `name:"modify subject* start_time*:select@date end_time*:select@date" role:"worker"`
cancel string `name:"cancel" role:"worker"`
enter string `name:"enter" help:"入会" style:"notice" role:"worker"`
}
func (s meeting) Config(m *ice.Message, arg ...string) {
if s.Select(m, model.PLACE_UID, m.Option(model.PLACE_UID)).Length() == 0 {
s.Insert(m, arg...)
} else {
s.Update(m, arg, model.PLACE_UID, m.Option(model.PLACE_UID))
}
}
func (s meeting) MeetingList(m *ice.Message, arg ...string) {
}
func (s meeting) Join(m *ice.Message, arg ...string) {
if !m.WarnNotRight(!s.IsWorker(m)) {
m.ProcessOpen(m.Option(model.LINK))
s.InsertOrUpdate(m, arg, m.OptionSimple(model.PLACE_UID)...)
}
func (s meeting) Create(m *ice.Message, arg ...string) { s.cmdy(m, s.MeetingPost, arg...) }
func (s meeting) Modify(m *ice.Message, arg ...string) { s.cmdy(m, s.MeetingPut, arg...) }
func (s meeting) Cancel(m *ice.Message, arg ...string) { s.cmdy(m, s.MeetingCancel, arg...) }
func (s meeting) Enter(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(model.LINK)) }
func (s meeting) List(m *ice.Message, arg ...string) {
if s.cmdy(m.Options(s.PLACE_UID, arg[0]), s.MeetingList, arg[1:]...); m.Length() > 0 {
if len(arg) == 1 {
m.PushAction(s.Enter, s.Modify, s.Cancel).Action(s.Create).Display("")
} else if m.IsMobileUA() {
m.EchoQRCode(m.Append(model.LINK)).Display("").DisplayCSS("")
} else {
m.EchoQRCode(m.Append(model.LINK)).Display("").DisplayCSS("")
// m.EchoIFrame(m.Append(model.LINK)).SetAppend()
}
}
}
func (s meeting) MeetingList(m *ice.Message, arg ...string) {}
func (s meeting) MeetingPost(m *ice.Message, arg ...string) {}
func (s meeting) MeetingPut(m *ice.Message, arg ...string) {}
func (s meeting) MeetingCancel(m *ice.Message, arg ...string) {}
func init() { ice.TeamCtxCmd(meeting{Table: newTable()}) }
type MeetingVendor interface {
MeetingList(m *ice.Message, arg ...string)
UserList(m *ice.Message, arg ...string) *ice.Message
MeetingList(m *ice.Message, arg ...string) *ice.Message
MeetingPost(m *ice.Message, arg ...string) *ice.Message
MeetingPut(m *ice.Message, arg ...string) *ice.Message
MeetingCancel(m *ice.Message, arg ...string) *ice.Message
}
var meetingVendorKey string
@ -64,17 +60,20 @@ func MeetingVendorAdd(key string, vendor MeetingVendor) {
meetingVendorKey, meetingVendorList[key] = key, vendor
}
func (s meeting) cmdy(m *ice.Message, arg ...ice.Any) *ice.Message {
func (s meeting) cmdy(m *ice.Message, action ice.Any, arg ...string) {
if m.Option(model.AUTH_UID, s.authUID(m, m.Option(s.PLACE_UID))) == "" {
return
}
msg := s.Select(m.Spawn(), model.PLACE_UID, m.Option(s.PLACE_UID))
return m.Options("user_id", msg.Append("user_id")).Cmdy(append([]ice.Any{kit.Select(meetingVendorKey, msg.Append("vendor"))}, arg...)...)
m.Options(model.USER_ID, msg.Append(model.USER_ID)).Cmdy(kit.Select(meetingVendorKey, msg.Append(model.VENDOR)), action, arg)
}
func (s meeting) authUID(m *ice.Message, arg ...string) string {
if msg := m.Cmd(s.Place, s.Select, model.UID, arg[0]); msg.Append(model.AUTH_UID) == "" {
m.Echo("本服务暂未申请认证,请到<用户名片>申请认证")
} else if _msg := m.Cmd(api.RENZHENGSHOUQUAN_AUTH, s.Select, model.UID, msg.Append(model.AUTH_UID)); _msg.Append(model.AUTH_STATUS) != "2" {
} else if m.Cmd(api.RENZHENGSHOUQUAN_AUTH, s.Select, model.UID, msg.Append(model.AUTH_UID)).Append(model.AUTH_STATUS) != "2" {
m.Echo("本服务认证申请中,请等待审批")
} else {
return m.Cmd(s.Street, s.Select, model.UID, msg.Append(s.Keys(s.Street, model.UID))).Append(model.AUTH_UID)
return m.Cmd(s.Street, s.Select, model.UID, msg.Append(s.STREET_UID)).Append(model.AUTH_UID)
}
return ""
}

View File

@ -1,15 +1,15 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { can.page.ClassList.del(can, can._fields, "detail"), can.page.ClassList.del(can, can._output, "detail")
if (can.Option("meeting_code")) { can.page.ClassList.add(can, can._fields, "detail"), can.page.ClassList.add(can, can._target, "detail")
if (can.Option(UID)) { can.page.ClassList.add(can, can._fields, "detail"), can.page.ClassList.add(can, can._target, "detail")
var start_time = msg.Append("start_time").split(" "), end_time = msg.Append("end_time").split(" ")
can.ui = can.page.Append(can, can._output, [
{view: "detail", list: [
{view: ["title", "", msg.Append("subject")]},
{view: ["meeting_code", "", msg.Append("meeting_code")]},
{view: ["meeting_code", "", msg.Append(UID)]},
{view: ["status", "", "待开始"]},
{view: "time", list: [
{view: "start_time", list: [{view: ["hour", "", start_time[1]]}, {view: ["date", "", start_time[0]]}]},
{view: ["span_time"], list: [{view: ["span", "", "1 小时"]}, {view: ["zone", "", "(GMT+08:00)"]}]},
{view: ["span_time"], list: [{view: ["span", "", msg.Append("span_time")]}, {view: ["zone", "", "(GMT+08:00)"]}]},
{view: "end_time", list: [{view: ["hour", "", end_time[1]]}, {view: ["date", "", end_time[0]]}]},
]},
{view: ["qrcode", "", msg.Result()]},
@ -22,6 +22,8 @@ Volcanos(chat.ONIMPORT, {
}},
]},
])
msg.Option("_share_title", msg.Append("subject"))
msg.Option("_share_content", [msg.Append(UID), msg.Append("start_time")].join("\n"))
} else {
can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.subject, can.onimport.titleAction(can, value)]},

View File

@ -85,6 +85,9 @@ const (
BEGIN_TIME = "begin_time"
END_TIME = "end_time"
OPEN_ID = "open_id"
USER_ID = "user_id"
VENDOR = "vendor"
PHONE = "phone"
EMAIL = "email"
ADDRESS = "address"
PORTAL = "portal"

View File

@ -148,7 +148,7 @@ body:not(.mobile) $output>fieldset.story>div.output div.item.card:not(:hover) {
body:not(.width1) $output div.item.card div.title div.action { display:none; }
body.en $output>fieldset table.content td:first-child { max-width:180px; width:unset;}
$fieldset { box-shadow:none; }
$output div.output>div.code { padding:0; }
$output>div.output>div.code { padding:10px; }
body.mobile {
// overflow:auto !important;
}

View File

@ -100,6 +100,18 @@ func (s Portal) Run(m *ice.Message, arg ...string) {
if s.UserPlaceRole(m); kit.IsIn(role, "", aaa.VOID, aaa.TECH, aaa.ROOT) {
kit.If(!ctx.PodCmd(m.Message, arg) && aaa.Right(m.Message, arg), func() { m.Cmdy(arg) })
} else {
if role == "worker" {
if !m.WarnNotRight(!s.IsWorker(m)) {
m.Cmdy(arg)
}
return
}
if role == "leader" {
if !m.WarnNotRight(!s.IsLeader(m)) {
m.Cmdy(arg)
}
return
}
if !m.Cmdy(s.Place, s.CheckRole, kit.Split(role)).IsErr() {
m.Cmdy(arg)
}

View File

@ -74,6 +74,7 @@
"service_name": "服务名称",
"begin_time": "起始时间",
"end_time": "结束时间",
"start_time": "开始时间",
"cancel_time": "取消时间",
"finish_time": "完成时间",
"created_at": "创建时间",

View File

@ -3,10 +3,15 @@ package model
import "shylinux.com/x/mysql-story/src/db"
const (
UID = "uid"
AUTH_UID = "auth_uid"
PLACE_UID = "place_uid"
AVATAR = "avatar"
UID = "uid"
USER_UID = "user_uid"
AUTH_UID = "auth_uid"
AUTH_STATUS = "auth_status"
PLACE_UID = "place_uid"
AVATAR = "avatar"
LINK = "link"
VENDOR = "vendor"
USER_ID = "user_id"
)
type Tencentmeeting struct {

View File

@ -8,21 +8,17 @@ import (
"fmt"
"math/rand"
"net/http"
"strconv"
"strings"
"time"
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/api"
"shylinux.com/x/community/src/gonganxitong"
"shylinux.com/x/community/src/renzhengshouquan"
"shylinux.com/x/community/src/renzhengshouquan/external/tencentmeeting/model"
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
wemeet "github.com/TencentCloud/wemeet-openapi-sdk-go/wemeet_openapi"
wemeetcore "github.com/TencentCloud/wemeet-openapi-sdk-go/wemeet_openapi/core"
meetings "github.com/TencentCloud/wemeet-openapi-sdk-go/wemeet_openapi/service/meetings"
)
type tencentmeeting struct {
@ -32,7 +28,7 @@ type tencentmeeting struct {
create string `name:"create app_id* sdk_id* secret_id* secret_key* user_id*" role:"leader"`
remove string `name:"remove" role:"leader"`
list string `name:"list auth_uid uid auto" role:"leader"`
config string `name:"config user_id" style:"notice" role:"leader"`
config string `name:"config user_id:select" style:"notice" role:"leader"`
}
func (s tencentmeeting) Init(m *ice.Message, arg ...string) {
@ -41,21 +37,17 @@ func (s tencentmeeting) Init(m *ice.Message, arg ...string) {
}
func (s tencentmeeting) Inputs(m *ice.Message, arg ...string) {
switch arg[0] {
case "user_id":
s.UserList(m, m.Option("auth_uid"))
m.Cut("userid", "username")
case model.USER_ID:
s.UserList(m, m.Option(model.AUTH_UID)).Cut(arg[0], "username")
}
}
func (s tencentmeeting) List(m *ice.Message, arg ...string) {
if len(arg) == 1 {
s.ValueList(m, arg[:1]).Display("")
s.ValueList(m, arg).Display("")
kit.If(m.Length() > 0, func() { m.Action() })
} else {
// s.UserList(m, arg[0])
// return
m.Cmdy(api.RENZHENGSHOUQUAN_AUTH, arg[0])
m.Table(func(value ice.Maps) {
if renzhengshouquan.AuthStatus(kit.Int(value["auth_status"])) == renzhengshouquan.AuthIssued {
m.Cmdy(api.RENZHENGSHOUQUAN_AUTH, arg[0]).Table(func(value ice.Maps) {
if renzhengshouquan.AuthStatus(kit.Int(value[model.AUTH_STATUS])) == renzhengshouquan.AuthIssued {
m.PushButton(s.Config)
} else {
m.PushButton()
@ -64,43 +56,82 @@ func (s tencentmeeting) List(m *ice.Message, arg ...string) {
}
}
func (s tencentmeeting) Config(m *ice.Message, arg ...string) {
m.Cmdy(api.GONGANXITONG_MEETING, s.Config, m.OptionSimple(model.PLACE_UID, "user_id"), "vendor", m.PrefixKey())
m.Cmdy(api.GONGANXITONG_MEETING, s.Config, m.OptionSimple(model.PLACE_UID, model.USER_UID, model.USER_ID), model.VENDOR, m.PrefixKey())
}
func (s tencentmeeting) UserList(m *ice.Message, arg ...string) {
s.spide(m, arg[0], "", "users/list", "page", "1", "page_size", "10")
s.parseList(m, "users", "role_code", "role_name", "userid", "username", "avatar_url", "status", "account_version", "user_account_type").RenameAppend("avatar_url", model.AVATAR)
func (s tencentmeeting) UserList(m *ice.Message, arg ...string) *ice.Message {
s.spide(m, "", "users/list", "operator_id", "$user_id", "operator_id_type", "1", "page", "1", "page_size", "10")
s.parseList(m, "users", "role_code", "role_name", "userid", "username", "avatar_url", "status", "account_version", "user_account_type")
m.RenameAppend("userid", model.USER_ID, "avatar_url", model.AVATAR)
return m
}
func (s tencentmeeting) MeetingList(m *ice.Message, arg ...string) {
s.spide(m, arg[0], "", "meetings", "userid", "$user_id", "instanceid", "1")
s.parseList(m, "meeting_info_list", "subject", "meeting_code", "start_time", "end_time", "join_url").RenameAppend("join_url", "link")
func (s tencentmeeting) MeetingList(m *ice.Message, arg ...string) *ice.Message {
s.spide(m, "", "meetings", "userid", "$user_id", "instanceid", "1", "meeting_code", kit.Select("", arg, 0))
s.parseList(m, "meeting_info_list", "subject", "meeting_code", "start_time", "end_time", "join_url", "meeting_id")
m.RenameAppend("meeting_code", model.UID, "join_url", model.LINK)
m.Table(func(value ice.Maps) {
d := (kit.Time(value["end_time"]) - kit.Time(value["start_time"])) / int64(time.Second)
m.Push("span_time", kit.Format(d/3600)+"小时")
})
return m
}
func (s tencentmeeting) MeetingPost(m *ice.Message, arg ...string) *ice.Message {
quick := true
for i := 0; i < len(arg); i += 2 {
kit.If(strings.HasSuffix(arg[i], "_time"), func() {
arg[i+1] = kit.Format(kit.Time(arg[i+1]) / int64(time.Second))
quick = false
})
}
arg = append(arg, "type", kit.Select("0", "1", quick))
return s.spide(m, http.MethodPost, "meetings", "userid", "$user_id", "instanceid", "1", arg)
}
func (s tencentmeeting) MeetingPut(m *ice.Message, arg ...string) *ice.Message {
quick := true
for i := 0; i < len(arg); i += 2 {
kit.If(strings.HasSuffix(arg[i], "_time"), func() {
arg[i+1] = kit.Format(kit.Time(arg[i+1]) / int64(time.Second))
quick = false
})
}
arg = append(arg, "type", kit.Select("0", "1", quick))
return s.spide(m, http.MethodPut, kit.Format("meetings/%s", m.Option("meeting_id")), "userid", "$user_id", "instanceid", 1, arg)
}
func (s tencentmeeting) MeetingCancel(m *ice.Message, arg ...string) *ice.Message {
return s.spide(m, http.MethodPost, kit.Format("meetings/%s/cancel", m.Option("meeting_id")), "userid", "$user_id", "instanceid", 1, "reason_code", 1)
}
func init() { ice.TeamCtxCmd(tencentmeeting{}) }
func (s tencentmeeting) spide(m *ice.Message, auth_uid, method, api string, arg ...ice.Any) {
arg = append(arg, "operator_id", "$user_id", "operator_id_type", "1")
msg := s.Select(m.Spawn(), model.AUTH_UID, auth_uid)
for i := 0; i < len(arg); i += 2 {
kit.If(arg[i+1] == "$user_id", func() { arg[i+1] = kit.Select(msg.Append("user_id"), m.Option("user_id")) })
}
method = kit.Select(http.MethodGet, method)
uri := kit.MergeURL("/v1/"+api, arg...)
now := kit.Format(time.Now().Unix())
nonce := kit.Format(uint64(100000 + rand.New(rand.NewSource(time.Now().UnixNano())).Intn(900000)))
m.Options(web.SPIDE_HEADER, map[string]string{
"AppId": msg.Append("app_id"),
"SdkId": msg.Append("sdk_id"),
"X-TC-Key": msg.Append("secret_id"),
"X-TC-Nonce": nonce,
"X-TC-Timestamp": now,
"X-TC-Registered": "1",
"X-TC-Signature": doSignature(msg.Append("secret_id"), msg.Append("secret_key"), "GET", nonce, now, uri, ""),
}).Cmdy(web.SPIDE, "dev", web.SPIDE_RAW, http.MethodGet, "https://api.meeting.qq.com"+uri)
}
func (s tencentmeeting) parseList(m *ice.Message, key string, arg ...string) *ice.Message {
if m.IsErr() {
func (s tencentmeeting) spide(m *ice.Message, method, api string, arg ...ice.Any) *ice.Message {
msg := s.Select(m.Spawn(), m.OptionSimple(model.AUTH_UID)...)
if msg.Length() == 0 {
m.Echo("请联系公司管理员,配置腾讯会议的账号")
return m
}
kit.For(kit.Value(kit.UnMarshal(m.Result()), key), func(value ice.Map) {
for i := 0; i < len(arg)-1; i += 2 {
kit.If(arg[i+1] == "$user_id", func() { arg[i+1] = kit.Select(msg.Append(model.USER_ID), m.Option(model.USER_ID)) })
}
method = kit.Select(http.MethodGet, method)
uri, body, args := kit.MergeURL("/v1/"+api, arg...), "", []string{}
nonce := kit.Format(uint64(100000 + rand.New(rand.NewSource(time.Now().UnixNano())).Intn(900000)))
now := kit.Format(time.Now().Unix())
kit.If(kit.IsIn(method, http.MethodPost, http.MethodPut), func() {
uri, body = kit.MergeURL("/v1/"+api), kit.Format(kit.Dict(arg...))
args = []string{web.SPIDE_DATA, body}
})
m.Options(web.SPIDE_HEADER, map[string]string{
"AppId": msg.Append("app_id"), "SdkId": msg.Append("sdk_id"), "X-TC-Key": msg.Append("secret_id"),
"X-TC-Nonce": nonce, "X-TC-Timestamp": now, "X-TC-Registered": "1",
"X-TC-Signature": doSignature(msg.Append("secret_id"), msg.Append("secret_key"), method, nonce, now, uri, body),
}).Cmdy(web.SPIDE, ice.DEV, web.SPIDE_RAW, method, "https://api.meeting.qq.com"+uri, args)
kit.If(kit.IsIn(method, http.MethodPost, http.MethodPut), func() { kit.If(!m.IsErr(), func() { m.ProcessRefresh() }) })
return m
}
func (s tencentmeeting) parseList(m *ice.Message, key string, arg ...string) *ice.Message {
data := kit.UnMarshal(m.Result())
if m.Warn(kit.Value(data, "error_info.error_code") != nil, kit.Value(data, "error_info.message")) {
return m
}
kit.For(kit.Value(data, key), func(value ice.Map) {
kit.For(arg, func(key string) {
if strings.HasSuffix(key, "_time") {
m.Push(key, strings.TrimSuffix(time.Unix(kit.Int64(value[key]), 0).Format(ice.MOD_TIME), ":00.000"))
@ -109,49 +140,10 @@ func (s tencentmeeting) parseList(m *ice.Message, key string, arg ...string) *ic
}
})
})
m.SetResult()
// m.Display("/plugin/story/json.js")
return m
return m.SetResult()
}
func doSignature(secretId string, secretKey string, httpMethod string, headerNonce string, headerTimestamp string, requestUri string, requestBody string) string {
headSignStr := fmt.Sprintf("X-TC-Key=%s&X-TC-Nonce=%s&X-TC-Timestamp=%s", secretId, headerNonce, headerTimestamp)
signStr := fmt.Sprintf("%s\n%s\n%s\n%s", httpMethod, headSignStr, requestUri, requestBody)
func doSignature(secretId string, secretKey string, method string, nonce string, now string, uri string, body string) string {
h := hmac.New(sha256.New, []byte(secretKey))
h.Write([]byte(signStr))
sha := hex.EncodeToString(h.Sum([]byte{}))
signBase64 := base64.StdEncoding.EncodeToString([]byte(sha))
return signBase64
}
func (s tencentmeeting) meetingList(m *ice.Message, arg ...string) {
if client, auth, user_id := s.newClient(m, arg[0]); client != nil {
args := []string{user_id, "1", kit.Select("", arg, 1)}
response, err := client.MeetingsApi.V1MeetingsGet(m, &meetings.ApiV1MeetingsGetRequest{Userid: &args[0], Instanceid: &args[1], MeetingCode: &args[2]}, auth)
s.resTable(m, response.Data, err, "meeting_info_list", "subject", "meeting_code", "start_time", "end_time", "join_url").RenameAppend("join_url", "link")
}
}
func (s tencentmeeting) newClient(m *ice.Message, arg ...string) (*wemeet.Client, wemeetcore.RequestOptionFunc, string) {
msg := s.Select(m.Spawn(), model.AUTH_UID, arg[0])
if msg.Length() == 0 {
m.Echo("请联系公司管理员,配置腾讯会议的账号").Action()
return nil, nil, ""
}
client := wemeet.NewClient(wemeet.WithAppId(msg.Append("app_id")), wemeet.WithSdkId(msg.Append("sdk_id")), wemeet.WithSecret(msg.Append("secret_id"), msg.Append("secret_key")))
authenticator := &wemeetcore.JWTAuthenticator{Nonce: uint64(100000 + rand.New(rand.NewSource(time.Now().UnixNano())).Intn(900000)), Timestamp: strconv.Itoa(int(time.Now().Unix()))}
return client, wemeetcore.WithJWTAuth(authenticator), kit.Select(msg.Append("user_id"), m.Option("user_id"))
}
func (s tencentmeeting) resTable(m *ice.Message, data ice.Any, err error, key string, arg ...string) *ice.Message {
if m.SetAppend().SetResult(); err != nil {
return m.Echo(kit.Formats(err))
}
kit.For(kit.Value(kit.UnMarshal(kit.Formats(data)), key), func(value ice.Map) {
kit.For(arg, func(key string) {
if strings.HasSuffix(key, "_time") {
m.Push(key, strings.TrimSuffix(time.Unix(kit.Int64(value[key]), 0).Format(ice.MOD_TIME), ":00.000"))
} else {
m.Push(key, value[key])
}
})
})
return m
h.Write([]byte(fmt.Sprintf("%s\n%s\n%s\n%s", method, fmt.Sprintf("X-TC-Key=%s&X-TC-Nonce=%s&X-TC-Timestamp=%s", secretId, nonce, now), uri, body)))
return base64.StdEncoding.EncodeToString([]byte(hex.EncodeToString(h.Sum([]byte{}))))
}

View File

@ -18,6 +18,7 @@ type Portal struct {
func (s Portal) List(m *ice.Message, arg ...string) {
s.Portal.List(m, arg...)
kit.If(len(arg) == 0 && m.Length() > 0, func() { m.PushAction(s.PlaceRemove) })
m.Sort("auth_status,auth_type,created_at", []string{"2"}, []string{"root", "city", "street", "school", "company", "service", "personal"}, "str_r")
}
func (s Portal) PlaceCreate(m *ice.Message, arg ...string) {
switch AuthType(kit.Int(m.Option(model.AUTH_TYPE))) {