mirror of
https://shylinux.com/x/community
synced 2025-05-09 07:08:11 +08:00
57 lines
1.9 KiB
Go
57 lines
1.9 KiB
Go
package gonganxitong
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/gonganxitong/model"
|
|
)
|
|
|
|
type setting struct {
|
|
Table
|
|
recent recent
|
|
service service
|
|
order string `data:"103"`
|
|
role string `data:"leader,worker,server"`
|
|
short string `data:"name"`
|
|
field string `data:"name,type,help"`
|
|
fields string `data:"name,value"`
|
|
create string `name:"create name* type* help" role:"tech"`
|
|
update string `name:"update" role:"void"`
|
|
placeTrash string `name:"placeTrash" help:"删除数据" style:"danger" role:"leader"`
|
|
}
|
|
|
|
func (s setting) Init(m *ice.Message, arg ...string) {
|
|
s.Table.Init(m, arg...)
|
|
s.Create(m, model.NAME, SETTING_PROFILE, model.TYPE, SETTING_RADIO)
|
|
}
|
|
func (s setting) Create(m *ice.Message, arg ...string) {
|
|
s.Hash.Create(m, arg...)
|
|
}
|
|
func (s setting) Update(m *ice.Message, arg ...string) {
|
|
m.OptionDefault(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)))
|
|
if s.Table.Select(m.Spawn(), m.OptionSimple(model.PLACE_UID, model.USER_UID, model.NAME)...).Length() == 0 {
|
|
s.Table.Insert(m, m.OptionSimple(model.PLACE_UID, model.USER_UID, model.NAME, model.VALUE)...)
|
|
} else {
|
|
s.Table.Update(m, kit.Dict(m.OptionSimple(model.VALUE)), m.OptionSimple(model.PLACE_UID, model.USER_UID, model.NAME)...)
|
|
}
|
|
}
|
|
func (s setting) List(m *ice.Message, arg ...string) {
|
|
if len(arg) == 1 {
|
|
data := ice.Maps{}
|
|
msg := s.Select(m.Spawn(), model.PLACE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID))
|
|
msg.Table(func(value ice.Maps) { data[value[model.NAME]] = value[model.VALUE] })
|
|
s.Hash.List(m).Table(func(value ice.Maps) { m.Push(model.VALUE, data[value[model.NAME]]) }).Action()
|
|
} else if len(arg) == 2 {
|
|
s.SelectDetail(m, model.PLACE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID), model.NAME, arg[1])
|
|
}
|
|
s.DisplayBase(m, "").DisplayCSS("")
|
|
}
|
|
|
|
func init() { ice.TeamCtxCmd(setting{Table: newTable()}) }
|
|
|
|
const (
|
|
SETTING_RADIO = "radio"
|
|
SETTING_PROFILE = "profile"
|
|
)
|