mirror of
https://shylinux.com/x/community
synced 2025-05-06 22:16:54 +08:00
64 lines
2.2 KiB
Go
64 lines
2.2 KiB
Go
package gonganxitong
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
"shylinux.com/x/icebergs/base/ctx"
|
|
"shylinux.com/x/icebergs/base/web"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/gonganxitong/model"
|
|
)
|
|
|
|
type recent struct {
|
|
Table
|
|
service service
|
|
order string `data:"903"`
|
|
create string `name:"create place_uid service_uid"`
|
|
remove string `name:"remove" role:"void"`
|
|
open string `name:"open" role:"void"`
|
|
sticky string `name:"sticky" role:"void"`
|
|
unSticky string `name:"unSticky" role:"void"`
|
|
}
|
|
|
|
func (s recent) Create(m *ice.Message, arg ...string) {
|
|
if args := m.OptionSimple(model.USER_UID, model.PLACE_UID); s.Select(m, args...).Length() == 0 {
|
|
s.Insert(m, kit.Simple(arg, model.UPDATED_AT, m.Time(), m.OptionSimple(model.USER_UID))...)
|
|
} else {
|
|
s.Update(m, kit.Dict(arg), args...)
|
|
}
|
|
}
|
|
func (s recent) Remove(m *ice.Message, arg ...string) {
|
|
s.Delete(m, m.OptionSimple(model.USER_UID, model.UID)...)
|
|
}
|
|
func (s recent) List(m *ice.Message, arg ...string) {
|
|
if len(arg) < 2 {
|
|
s.Tables(m, s.service).Fields(m, s.Key(s, model.UID), s.Key(s, model.UPDATED_AT),
|
|
model.SERVICE_ICON, model.SERVICE_NAME, s.Key(s, model.AUTH_STATUS), model.SCORE,
|
|
s.Key(s, model.CITY_NAME), s.Key(s, model.STREET_NAME), s.Key(s, model.PLACE_NAME),
|
|
s.AS(model.NODENAME, model.SPACE), model.INDEX, model.PLACE_UID,
|
|
).Orders(m, s.Desc(model.SCORE), s.Desc(model.UPDATED_AT))
|
|
s.Select(m, model.USER_UID, m.Option(model.USER_UID)).Action()
|
|
} else if len(arg) == 2 {
|
|
s.SelectDetail(m, model.USER_UID, m.Option(model.USER_UID), model.UID, arg[1])
|
|
}
|
|
m.Table(func(value ice.Maps) {
|
|
if value[model.SCORE] == "0" {
|
|
m.PushButton(s.Sticky, s.Remove)
|
|
} else {
|
|
m.PushButton(s.UnSticky, s.Remove)
|
|
}
|
|
})
|
|
s.DisplayBase(m, "")
|
|
}
|
|
func (s recent) Open(m *ice.Message, arg ...string) {
|
|
m.ProcessOpen(web.S(m.Option(web.SPACE)) + web.C(m.Option(ctx.INDEX)) + "#" + kit.Join(kit.Split(m.Option(ctx.ARGS)), ":"))
|
|
}
|
|
func (s recent) Sticky(m *ice.Message, arg ...string) {
|
|
s.Update(m, ice.Map{model.SCORE: 100}, m.OptionSimple(model.USER_UID, model.UID)...)
|
|
}
|
|
func (s recent) UnSticky(m *ice.Message, arg ...string) {
|
|
s.Update(m, ice.Map{model.SCORE: 0}, m.OptionSimple(model.USER_UID, model.UID)...)
|
|
}
|
|
|
|
func init() { ice.TeamCtxCmd(recent{Table: newTable()}) }
|