package gonganxitong import ( "shylinux.com/x/ice" kit "shylinux.com/x/toolkits" "shylinux.com/x/community/src/gonganxitong/model" ) type notice struct { Table order string `data:"505"` role string `data:"leader"` fields string `data:"title,content,user_uid"` create string `name:"create title* content*" role:"void"` remove string `name:"remove" role:"void"` } func (s notice) Create(m *ice.Message, arg ...string) { if m.WarnNotRight(!s.IsLeader(m)) { return } m.Option(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID))) s.Insert(m, kit.Simple(arg, m.OptionSimple(model.PLACE_UID, model.USER_UID))...) s.RecordEventWithName(m, "") } func (s notice) Remove(m *ice.Message, arg ...string) { if m.WarnNotRight(!s.IsLeader(m)) { return } m.Option(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID))) s.Delete(m, m.OptionSimple(model.PLACE_UID, model.UID)...) s.RecordEventWithName(m, "") } func (s notice) List(m *ice.Message, arg ...string) { if len(arg) == 1 { s.Select(m, model.PLACE_UID, arg[0]) } else if len(arg) == 2 { s.SelectDetail(m, model.PLACE_UID, arg[0], model.UID, arg[1]) } else { return } kit.If(s.IsLeader(m), func() { m.PushAction(s.Remove) s.Button(m, "") }, func() { m.Action() }) s.SelectJoinUser(m) } func init() { ice.TeamCtxCmd(notice{Table: newTable()}) }