mirror of
https://shylinux.com/x/community
synced 2025-04-25 09:38:06 +08:00
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package {{.Option "name"}}
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/enterprise/src/guanlixitong"
|
|
"{{.Option "module"}}/model"
|
|
)
|
|
|
|
type Table struct {
|
|
guanlixitong.Table
|
|
list string `name:"list {{.Option "class"}}_uid uid auto" role:"void"`
|
|
}
|
|
|
|
func (s Table) Inputs(m *ice.Message, arg ...string) {
|
|
switch arg[0] {
|
|
case model.USER_{{.Option "CLASS"}}_ROLE:
|
|
s.InputsListRole(m, User{{.Option "Class"}}RoleList, arg...)
|
|
case model.{{.Option "CLASS"}}_TYPE:
|
|
s.InputsList(m, {{.Option "Class"}}TypeList, arg...)
|
|
default:
|
|
s.Table.Inputs(m, arg...)
|
|
}
|
|
}
|
|
func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
|
|
m.RewriteAppend(func(value, key string, index int) string {
|
|
switch key {
|
|
case model.USER_{{.Option "CLASS"}}_ROLE:
|
|
value = User{{.Option "Class"}}Role(kit.Int(value)).String()
|
|
case model.{{.Option "CLASS"}}_TYPE:
|
|
value = {{.Option "Class"}}Type(kit.Int(value)).String()
|
|
}
|
|
return value
|
|
})
|
|
return s.Table.RewriteAppend(m)
|
|
}
|
|
func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message {
|
|
role := User{{.Option "Class"}}Role(kit.Int(m.Cmd(user{{.Option "Class"}}{}, s.Select, m.OptionSimple(model.{{.Option "CLASS"}}_UID, model.USER_UID)).Append(model.ROLE)))
|
|
m.WarnNotRight(!kit.IsIn(role.String(), append(arg, User{{.Option "Class"}}Creator.String())...), role.String())
|
|
return m
|
|
}
|
|
|
|
type Tables struct { Table }
|
|
|
|
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
|