mirror of
https://shylinux.com/x/community
synced 2025-05-05 13:37:02 +08:00
65 lines
2.3 KiB
Go
65 lines
2.3 KiB
Go
package renzhengshouquan
|
|
|
|
import (
|
|
"shylinux.com/x/ice"
|
|
"shylinux.com/x/icebergs/base/aaa"
|
|
kit "shylinux.com/x/toolkits"
|
|
|
|
"shylinux.com/x/community/src/gonganxitong"
|
|
"shylinux.com/x/community/src/renzhengshouquan/model"
|
|
"shylinux.com/x/enterprise/src/guanlixitong"
|
|
)
|
|
|
|
type Portal struct {
|
|
guanlixitong.Portal
|
|
placeCreate string `name:"placeCreate auth_name* auth_info auth_type*:select from_uid*:select" role:"void"`
|
|
}
|
|
|
|
func (s Portal) List(m *ice.Message, arg ...string) {
|
|
s.Portal.List(m, arg...)
|
|
kit.If(len(arg) == 0 && m.Length() > 0, func() { m.PushAction(s.PlaceRemove) })
|
|
}
|
|
func (s Portal) PlaceCreate(m *ice.Message, arg ...string) {
|
|
switch AuthType(kit.Int(m.Option(model.AUTH_TYPE))) {
|
|
case AuthRoot:
|
|
if m.WarnNotRight(!m.IsTech()) {
|
|
return
|
|
}
|
|
arg = append(arg, model.FROM_UID, aaa.ROOT, model.STATUS, kit.Format(AuthIssued))
|
|
case AuthCity:
|
|
arg = append(arg, model.FROM_UID, s.findAuthFrom(m, AuthRoot))
|
|
case AuthPersonal:
|
|
arg = append(arg, model.USER_UID, m.Option(model.USER_UID))
|
|
}
|
|
arg = kit.TransArgKeys(arg, model.AUTH_NAME, model.NAME, model.AUTH_INFO, model.INFO, model.AUTH_TYPE, model.TYPE)
|
|
if m.Options(arg).Cmdy(s.Place, s.Insert, arg).IsErr() {
|
|
return
|
|
}
|
|
m.Cmd(s.UserPlace, s.Insert, kit.Simple(model.AUTH_UID, m.Result(), m.OptionSimple(model.USER_UID), model.ROLE, 1))
|
|
s.RecordEventWithName(m.Options(model.AUTH_UID, m.Result()), "")
|
|
}
|
|
func (s Portal) PlaceList(m *ice.Message, arg ...string) *ice.Message {
|
|
s.Tables(m, s.Place).FieldsWithCreatedAT(m, s.UserPlace,
|
|
model.AUTH_UID, model.AUTH_NAME, model.AUTH_INFO, model.AUTH_TYPE, model.USER_AUTH_ROLE, model.AUTH_STATUS,
|
|
model.AUTH_AVATAR,
|
|
)
|
|
if len(arg) == 1 {
|
|
m.Cmdy(s.UserPlace, s.Table.Select, s.Key(s.UserPlace, model.USER_UID), arg[0])
|
|
} else if len(arg) == 2 {
|
|
m.FieldsSetDetail().Cmdy(s.UserPlace, s.Table.Select, s.Key(s.UserPlace, model.USER_UID), arg[0], s.Key(s.Place, model.UID), arg[1])
|
|
} else {
|
|
return m
|
|
}
|
|
return m
|
|
}
|
|
|
|
func init() { gonganxitong.PortalCmd(Portal{Portal: guanlixitong.NewPortal(userAuth{}, Auth{})}) }
|
|
|
|
func (s Portal) findAuthFrom(m *ice.Message, authType AuthType, arg ...string) string {
|
|
msg := m.Cmd(Auth{}, s.Table.Select, model.TYPE, authType, arg)
|
|
if m.WarnNotFound(msg.Length() == 0, authType.String()) {
|
|
return ""
|
|
}
|
|
return msg.Append(model.UID)
|
|
}
|