mirror of
https://shylinux.com/x/community
synced 2025-05-09 07:08:11 +08:00
68 lines
2.2 KiB
Go
68 lines
2.2 KiB
Go
package gonganxitong
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/gonganxitong/model"
|
|
)
|
|
|
|
type photo struct {
|
|
Table
|
|
order string `data:"96"`
|
|
auth string `data:"issued"`
|
|
role string `data:"leader,worker"`
|
|
fields string `data:"space_id,access_token,expire_time,vendor"`
|
|
upload string `name:"upload" role:"worker"`
|
|
rename string `name:"rename newname" role:"worker"`
|
|
trash string `name:"trash" role:"worker"`
|
|
}
|
|
|
|
func (s photo) Config(m *ice.Message, arg ...string) {
|
|
s.InsertOrUpdate(m, arg, m.OptionSimple(model.PLACE_UID)...)
|
|
}
|
|
func (s photo) List(m *ice.Message, arg ...string) {
|
|
s.cmdy(m, PhotoVendor.Folder, kit.Slice(arg, 1)...)
|
|
m.PushAction(s.Rename, s.Trash).Display("")
|
|
if len(arg) == 1 {
|
|
s.Button(m, "请上传文件", s.Upload)
|
|
s.SpendlistCheck(m, 0)
|
|
}
|
|
}
|
|
func (s photo) Upload(m *ice.Message, arg ...string) {
|
|
if up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); s.SpendlistCheck(m, kit.Int(up[2])) {
|
|
s.cmdy(m, "")
|
|
s.SpendlistUpdate(m, m.Append(model.SIZE))
|
|
}
|
|
}
|
|
func (s photo) Rename(m *ice.Message, arg ...string) {
|
|
s.cmdy(m, "")
|
|
}
|
|
func (s photo) Trash(m *ice.Message, arg ...string) {
|
|
s.cmdy(m, "")
|
|
s.SpendlistUpdate(m, m.Append(model.SIZE))
|
|
}
|
|
|
|
func init() { ice.TeamCtxCmd(photo{Table: newTable()}) }
|
|
|
|
func (s photo) cmdy(m *ice.Message, action ice.Any, arg ...string) {
|
|
if m.Option(model.AUTH_UID, s.StreetAuthUID(m, m.Option(model.PLACE_UID))) == "" {
|
|
return
|
|
}
|
|
if msg := s.Select(m.Spawn(), m.OptionSimple(model.PLACE_UID)...); msg.Append(model.SPACE_ID) == "" {
|
|
m.Echo("本服务暂未配置,请联系公司管理员配置")
|
|
} else {
|
|
kit.If(action == "", func() { action = m.ActionKey() })
|
|
_msg := m.Cmd(msg.Append(model.VENDOR), PhotoVendor.Token, msg.Append(model.SPACE_ID), msg.Append(model.ACCESS_TOKEN), msg.Append(model.EXPIRE_TIME))
|
|
m.Cmdy(msg.Append(model.VENDOR), action, m.Option(model.AUTH_UID), msg.Append(model.SPACE_ID), _msg.Append(model.ACCESS_TOKEN), arg)
|
|
}
|
|
}
|
|
|
|
var PhotoVendor interface {
|
|
Folder(m *ice.Message, arg ...string)
|
|
Upload(m *ice.Message, arg ...string)
|
|
Rename(m *ice.Message, arg ...string)
|
|
Trash(m *ice.Message, arg ...string)
|
|
Token(m *ice.Message, arg ...string)
|
|
}
|