Documentation ¶
Overview ¶
Package admin 管理端的相关操作
Index ¶
- Constants
- Variables
- func Install(s *web.Server, mod string, db *orm.DB)
- func SexValidator(v any) bool
- func StateValidator(v any) bool
- type Admin
- func (m *Admin) AddSecurityLog(uid int64, content, ip, ua string) error
- func (m *Admin) AddSecurityLogWithContext(uid int64, ctx *web.Context, content string)
- func (m *Admin) AuthFilter(next web.HandlerFunc) web.HandlerFunc
- func (m *Admin) IsAllowChangeGroup(ctx *web.Context, groups types.SliceOf[int64]) (bool, error)
- func (m *Admin) LoginUser(ctx *web.Context) *ModelAdmin
- func (m *Admin) OnLogin(f func(int64)) (int, error)
- func (m *Admin) OnLogout(f func(int64)) (int, error)
- func (m *Admin) RBACFilter(mod string, res string, next web.HandlerFunc) web.HandlerFunc
- func (m *Admin) RegisterResources(mod string, res map[string]web.LocaleStringer) error
- func (m *Admin) URLPrefix() string
- type ModelAdmin
- type Sex
- type State
Constants ¶
View Source
const (
// SystemID 表示系统的 ID
SystemID = 0
)
Variables ¶
View Source
var SexRule = web.NewRuleFunc(locales.InvalidValue, SexValidator)
View Source
var StateRule = web.NewRuleFunc(locales.InvalidValue, StateValidator)
Functions ¶
func SexValidator ¶
func StateValidator ¶
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
func (*Admin) AddSecurityLog ¶
func (*Admin) AddSecurityLogWithContext ¶
func (*Admin) AuthFilter ¶
func (m *Admin) AuthFilter(next web.HandlerFunc) web.HandlerFunc
AuthFilter 验证是否登录
同时如果在登录状态下,会将当前登录用户的数据写入 ctx.Vars。
func (*Admin) IsAllowChangeGroup ¶
IsAllowChangeGroup 是否允许当前登录用户将角色 groups 赋予其它用户
除超级用户之外,其它任何人只能应用自己当前角色或是子角色给其它用户。
func (*Admin) LoginUser ¶
func (m *Admin) LoginUser(ctx *web.Context) *ModelAdmin
LoginUser 获取当前登录的用户信息
该信息由 AuthFilter 存储在 ctx.Vars 之中。
func (*Admin) RBACFilter ¶
func (m *Admin) RBACFilter(mod string, res string, next web.HandlerFunc) web.HandlerFunc
RBACFilter 验证是否拥有指定的权限
NOTE: 需要 Admin.AuthFilter 作为前置条件,用到了其产生的 "admin" 变量。
func (*Admin) RegisterResources ¶
RegisterResources 注册资源
type ModelAdmin ¶ added in v0.3.0
type ModelAdmin struct { XMLName struct{} `orm:"-" json:"-" xml:"admin"` ID int64 `orm:"name(id);ai" json:"id" xml:"id,attr"` Created time.Time `orm:"name(created)" json:"created" xml:"created,attr"` State State `orm:"name(state)" json:"state" xml:"state,attr"` Sex Sex `orm:"name(sex)" json:"sex" xml:"sex,attr"` Name string `orm:"name(name);len(50)" json:"name,omitempty" xml:"name,omitempty"` // 真实名称 Nickname string `orm:"name(nickname);len(50)" json:"nickname" xml:"nickname"` Username string `orm:"name(username);len(50)" json:"username" xml:"username"` Avatar string `orm:"name(avatar);len(1000)" json:"avatar,omitempty" xml:"avatar,attr,omitempty"` Super bool `orm:"name(super)" json:"super,omitempty" xml:"super,attr,omitempty"` }
func (*ModelAdmin) BeforeInsert ¶ added in v0.3.0
func (a *ModelAdmin) BeforeInsert() error
func (*ModelAdmin) BeforeUpdate ¶ added in v0.3.0
func (a *ModelAdmin) BeforeUpdate() error
BeforeUpdate 更新之前需要执行的操作
func (*ModelAdmin) TableName ¶ added in v0.3.0
func (*ModelAdmin) TableName() string
type Sex ¶
type Sex int8
func (Sex) MarshalText ¶
MarshalText encoding.TextMarshaler
func (*Sex) UnmarshalText ¶
UnmarshalText encoding.TextUnmarshaler
type State ¶
type State int8
State 表示管理员的状态
func (State) MarshalText ¶
MarshalText encoding.TextMarshaler
func (*State) UnmarshalText ¶
UnmarshalText encoding.TextUnmarshaler
Source Files ¶
Click to show internal directories.
Click to hide internal directories.