mirror of
https://shylinux.com/x/education
synced 2025-04-25 10:08:05 +08:00
64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
package jiaowuxitong
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"shylinux.com/x/ice"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/gonganxitong"
|
|
"shylinux.com/x/education/src/jiaowuxitong/model"
|
|
)
|
|
|
|
type Table struct {
|
|
gonganxitong.Table
|
|
list string `name:"list class_uid uid auto" role:"void"`
|
|
}
|
|
|
|
func (s Table) Inputs(m *ice.Message, arg ...string) {
|
|
switch arg[0] {
|
|
case model.USER_CLASS_ROLE:
|
|
s.InputsListRole(m, UserClassRoleList, arg...)
|
|
case model.CLASS_TYPE:
|
|
s.InputsList(m, ClassTypeList, arg...)
|
|
case model.SCHOOL_UID:
|
|
m.Cmdy(school{}, s.Select).Cut(model.UID, model.NAME).RenameAppend(model.UID, arg[0])
|
|
m.DisplayInputKeyNameIconTitle()
|
|
case model.SCHOOL_NAME, model.CITY_NAME:
|
|
m.Cmdy(Portal{}, Portal{}.PlaceList, m.Option(model.USER_UID)).Cut(arg[0])
|
|
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 {
|
|
if _, e := strconv.ParseInt(value, 10, 64); e != nil {
|
|
return value
|
|
}
|
|
switch key {
|
|
case model.USER_CLASS_ROLE:
|
|
value = UserClassRole(kit.Int(value)).String()
|
|
case model.CLASS_TYPE:
|
|
value = ClassType(kit.Int(value)).String()
|
|
}
|
|
return value
|
|
})
|
|
return s.Table.RewriteAppend(m)
|
|
}
|
|
func (s Table) SelectJoinSchool(m *ice.Message) *ice.Message {
|
|
return s.SelectJoin(m, school{}, model.NAME, model.CITY_UID)
|
|
}
|
|
func (s Table) CheckRole(m *ice.Message, arg ...string) {
|
|
role := UserClassRole(s.UserPlaceRole(m))
|
|
m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserClassCreator.String())...), role.String())
|
|
m.Option(model.USER_ROLE, kit.Format(role))
|
|
}
|
|
|
|
type Tables struct{ Table }
|
|
|
|
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
|
|
|
|
func NewPortal(userPlace gonganxitong.UserPlacer, place gonganxitong.Placer) Portal {
|
|
return Portal{Portal: gonganxitong.NewPortal(userPlace, place, school{})}
|
|
}
|