package gonganxitong import ( "time" "shylinux.com/x/ice" "shylinux.com/x/icebergs/base/mdb" kit "shylinux.com/x/toolkits" "shylinux.com/x/community/src/gonganxitong/model" ) type user struct { Table template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"` create string `name:"create openid*"` find string `name:"find uid*"` } func (s user) Create(m *ice.Message, arg ...string) { if s.Table.Select(m, model.OPEN_ID, m.Option(model.OPENID)).Length() == 0 { s.Table.Create(m, model.OPEN_ID, m.Option(model.OPENID), model.AVATAR, m.Option("headimgurl"), model.NAME, m.Option("nickname")) m.Option(model.USER_UID, m.Result()) } else { m.Option(model.USER_UID, m.Append(model.UID)) } } func (s user) Find(m *ice.Message, arg ...string) { s.Select(m, arg...) } func (s user) List(m *ice.Message, arg ...string) { s.Table.List(m, arg...).Action(s.Create, s.Find) } func init() { ice.Cmd(prefixKey(), user{}) } func (s user) UserUID(m *ice.Message) string { msg := m.Cmd(s, s.Select, model.UID, m.Option(ice.MSG_USERNAME)) m.Options(ice.MSG_USERNICK, msg.Append(mdb.NAME), model.OPEN_ID, msg.Append(model.OPEN_ID)) return m.Option(model.USER_UID, msg.Append(model.UID)) } func (s user) SendTemplate(m *ice.Message, arg ...string) { // url type name hash m.Cmd("web.chat.wx.template", "", m.Config("template"), m.Option(model.OPEN_ID), kit.Select("", arg, 0), "thing7", kit.Select("", arg, 1), "thing12", kit.Select("", arg, 2), "character_string2", kit.Select("", arg, 3), "time11", time.Now().Format("2006年01月02日 15:04"), "thing18", m.Option(ice.MSG_USERNICK), ) } type User struct{ user } func init() { ice.Cmd(prefixKey(), User{}) }