mirror of
https://shylinux.com/x/community
synced 2025-07-02 05:31:20 +08:00
132 lines
4.4 KiB
Go
132 lines
4.4 KiB
Go
package gonganxitong
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
"shylinux.com/x/icebergs/base/aaa"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/api"
|
|
"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,role,order,default"`
|
|
fields string `data:"name,value,user_uid"`
|
|
create string `name:"create name* type* help"`
|
|
update string `name:"update" role:"void"`
|
|
}
|
|
|
|
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, model.ORDER, "1")
|
|
s.Create(m, model.NAME, SETTING_WEIXIN_NOTICE, model.TYPE, SETTING_RADIO, model.HELP, "微信接受系统消息通知", model.ORDER, "2", "default", "on")
|
|
}
|
|
func (s setting) Create(m *ice.Message, arg ...string) {
|
|
s.Hash.Create(m, arg...)
|
|
}
|
|
func (s setting) Update(m *ice.Message, arg ...string) {
|
|
msg := s.Hash.Select(m.Spawn(), m.Option(model.NAME))
|
|
args := m.OptionSimple(model.PLACE_UID, model.USER_UID, model.NAME)
|
|
switch msg.Append(model.ROLE) {
|
|
case aaa.TECH:
|
|
if m.IsTech() {
|
|
args = m.OptionSimple(model.PLACE_UID, model.NAME)
|
|
} else {
|
|
return
|
|
}
|
|
case "creator":
|
|
if s.IsCreator(m) {
|
|
args = m.OptionSimple(model.PLACE_UID, model.NAME)
|
|
} else {
|
|
return
|
|
}
|
|
case "leader":
|
|
if s.IsLeader(m) {
|
|
args = m.OptionSimple(model.PLACE_UID, model.NAME)
|
|
} else {
|
|
return
|
|
}
|
|
}
|
|
if s.Table.Select(m.Spawn(), args...).Length() > 0 {
|
|
s.Table.Update(m, kit.Dict(m.OptionSimple(model.VALUE)), args...)
|
|
} else {
|
|
s.Table.Insert(m, kit.Simple(m.OptionSimple(model.VALUE), args)...)
|
|
}
|
|
}
|
|
func (s setting) List(m *ice.Message, arg ...string) {
|
|
if len(arg) == 1 {
|
|
data := ice.Maps{}
|
|
args := kit.Simple("place_uid = ? AND user_uid = ?", arg[0], m.Option(model.USER_UID))
|
|
if s.IsCreator(m) {
|
|
args = kit.Simple("place_uid = ? AND (user_uid = ? OR user_uid IS NULL OR user_uid = '')", arg[0], m.Option(model.USER_UID))
|
|
}
|
|
msg := s.Select(m.Spawn(), args...)
|
|
msg.Table(func(value ice.Maps) { data[value[model.NAME]] = value[model.VALUE] })
|
|
s.Hash.List(m.Spawn()).Table(func(value ice.Maps) {
|
|
if value[model.ROLE] == aaa.TECH && !m.IsTech() {
|
|
|
|
} else if value[model.ROLE] == "creator" && !s.IsCreator(m) {
|
|
|
|
} else if value[model.ROLE] == "leader" && !s.IsLeader(m) {
|
|
|
|
} else {
|
|
m.Push(model.NAME, value[model.NAME])
|
|
m.Push(model.TYPE, value[model.TYPE])
|
|
m.Push(model.HELP, value[model.HELP])
|
|
m.Push(model.ORDER, value[model.ORDER])
|
|
m.Push(model.VALUE, kit.Select(value["default"], data[value[model.NAME]]))
|
|
}
|
|
})
|
|
if msg := m.Cmd(s.Place, s.Select, model.UID, m.Option(model.PLACE_UID)); msg.Append(model.AUTH_UID) != "" {
|
|
m.Push(model.NAME, "authPortal")
|
|
m.Push(model.TYPE, SETTING_STORY)
|
|
m.Push(model.HELP, "进入服务认证的主页")
|
|
m.Push(model.ORDER, "10")
|
|
m.Push(model.VALUE, kit.Fields(api.RENZHENGSHOUQUAN_PORTAL, msg.Append(model.AUTH_UID)))
|
|
}
|
|
if msg := m.Cmd(user{}, s.Select, model.UID, m.Option(ice.MSG_USERUID)); msg.Append(model.AUTH_UID) != "" {
|
|
m.Push(model.NAME, "authPortal")
|
|
m.Push(model.TYPE, SETTING_STORY)
|
|
m.Push(model.HELP, "进入个人认证的主页")
|
|
m.Push(model.ORDER, "11")
|
|
m.Push(model.VALUE, kit.Fields(api.RENZHENGSHOUQUAN_PORTAL, msg.Append(model.AUTH_UID)))
|
|
}
|
|
m.Action().SortInt(model.ORDER)
|
|
} 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()}) }
|
|
|
|
func (s Table) SettingCreate(m *ice.Message, arg ...string) {
|
|
m.Cmdy(s.PrefixSetting(m), s.Create, model.NAME, arg[0],
|
|
model.TYPE, kit.Select(SETTING_RADIO, arg, 1),
|
|
model.HELP, kit.Select("", arg, 2),
|
|
model.ROLE, kit.Select("", arg, 3),
|
|
model.ORDER, kit.Select("1000", arg, 4),
|
|
)
|
|
}
|
|
func (s Table) SettingSelect(m *ice.Message, arg ...string) {
|
|
m.Cmd(s.PrefixSetting(m), s.Select, m.OptionSimple(model.PLACE_UID)).Table(func(value ice.Maps) {
|
|
if value[model.USER_UID] != "" && value[model.USER_UID] != m.Option(model.USER_UID) {
|
|
return
|
|
}
|
|
m.Option(value[model.NAME], value[model.VALUE])
|
|
})
|
|
}
|
|
|
|
const (
|
|
SETTING_PROFILE = "profile"
|
|
SETTING_WEIXIN_NOTICE = "setting_weixin_notice"
|
|
SETTING_RADIO = "radio"
|
|
SETTING_STORY = "story"
|
|
)
|