mirror of
https://shylinux.com/x/community
synced 2025-04-26 01:54:05 +08:00
62 lines
2.2 KiB
Go
62 lines
2.2 KiB
Go
package gonganxitong
|
|
|
|
import (
|
|
"time"
|
|
|
|
"shylinux.com/x/ice"
|
|
"shylinux.com/x/icebergs/base/aaa"
|
|
"shylinux.com/x/icebergs/base/nfs"
|
|
"shylinux.com/x/icebergs/base/web"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/gonganxitong/model"
|
|
)
|
|
|
|
type user struct {
|
|
Table
|
|
community string `data:"20240724-community"`
|
|
template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"`
|
|
create string `name:"create open_id* name usernick"`
|
|
email string `name:"email email*"`
|
|
}
|
|
|
|
func (s user) Create(m *ice.Message, arg ...string) {
|
|
if s.Table.Select(m, m.OptionSimple(model.OPEN_ID)...).Length() == 0 {
|
|
s.Table.Create(m, kit.Simple(m.OptionSimple(model.OPEN_ID, model.AVATAR), model.NAME, m.Option(aaa.USERNICK))...)
|
|
m.Option(model.USER_UID, m.Result())
|
|
} else {
|
|
s.Table.Update(m, kit.Dict(m.OptionSimple(model.AVATAR), model.NAME, m.Option(aaa.USERNICK)), m.AppendSimple(model.UID)...)
|
|
m.Option(model.USER_UID, m.Append(model.UID))
|
|
}
|
|
}
|
|
func (s user) List(m *ice.Message, arg ...string) {
|
|
if m.IsTech() {
|
|
s.Table.List(m, arg...).Table(func(value ice.Maps) {
|
|
if value[model.UID] != m.Option(model.USER_UID) {
|
|
m.PushButton(s.SetCookie)
|
|
} else {
|
|
m.PushButton()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
func (s user) SetCookie(m *ice.Message, arg ...string) {
|
|
m.ProcessCookie(model.USER_UID, m.Option(model.UID))
|
|
}
|
|
func (s user) Email(m *ice.Message, arg ...string) {
|
|
s.Table.Update(m, kit.Dict(m.OptionSimple(model.EMAIL)), model.UID, m.Option(model.USER_UID))
|
|
}
|
|
func (s user) SendTemplate(m *ice.Message, arg ...string) { // from uid url type name hash
|
|
if ice.Info.NodeName != m.Config("community") {
|
|
m.AdminCmd(web.SPACE, m.Config("community"), m.PrefixKey(), m.ActionKey(), arg, kit.Dict(ice.MSG_USERROLE, aaa.TECH))
|
|
return
|
|
}
|
|
msg := s.Select(m, model.UID, kit.Select(m.Option(model.USER_UID), arg, 1))
|
|
m.Cmdy("web.chat.wx.template", "", m.Config(nfs.TEMPLATE), msg.Append(model.OPEN_ID), kit.Select("", arg, 2),
|
|
"thing7", kit.Select("", arg, 3), "thing12", kit.Select("", arg, 4), "character_string2", kit.Cut(kit.Select("", arg, 5), 6),
|
|
"time11", time.Now().Format("2006年01月02日 15:04"), "thing18", kit.Select(kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK)), arg, 0),
|
|
)
|
|
}
|
|
|
|
func init() { ice.TeamCtxCmd(user{}) }
|