internal

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIsRootUser

func CheckIsRootUser(ctx context.Context, userID string) bool

CheckIsRootUser 检查是否是root用户

func ExecTrans

func ExecTrans(ctx context.Context, transModel model.ITrans, fn TransFunc) error

ExecTrans 执行事务

func ExecTransWithLock

func ExecTransWithLock(ctx context.Context, transModel model.ITrans, fn TransFunc) error

ExecTransWithLock 执行事务(加锁)

func GetRootUser

func GetRootUser() *schema.User

GetRootUser 获取root用户

Types

type Demo

type Demo struct {
	DemoModel model.IDemo
}

Demo 示例程序

func NewDemo

func NewDemo(mDemo model.IDemo) *Demo

NewDemo 创建demo

func (*Demo) Create

func (a *Demo) Create(ctx context.Context, item schema.Demo) (*schema.Demo, error)

Create 创建数据

func (*Demo) Delete

func (a *Demo) Delete(ctx context.Context, recordID string) error

Delete 删除数据

func (*Demo) Get

func (a *Demo) Get(ctx context.Context, recordID string, opts ...schema.DemoQueryOptions) (*schema.Demo, error)

Get 查询指定数据

func (*Demo) Query

Query 查询数据

func (*Demo) Update

func (a *Demo) Update(ctx context.Context, recordID string, item schema.Demo) (*schema.Demo, error)

Update 更新数据

func (*Demo) UpdateStatus

func (a *Demo) UpdateStatus(ctx context.Context, recordID string, status int) error

UpdateStatus 更新状态

type Login

type Login struct {
	UserModel model.IUser
	RoleModel model.IRole
	MenuModel model.IMenu
	Auth      auth.Auther
}

Login 登录管理

func NewLogin

func NewLogin(
	a auth.Auther,
	mUser model.IUser,
	mRole model.IRole,
	mMenu model.IMenu,
) *Login

NewLogin 创建登录管理实例

func (*Login) DestroyToken

func (a *Login) DestroyToken(ctx context.Context, tokenString string) error

DestroyToken 销毁令牌

func (*Login) GenerateToken

func (a *Login) GenerateToken(ctx context.Context, userID string) (*schema.LoginTokenInfo, error)

GenerateToken 生成令牌

func (*Login) GetCaptcha

func (a *Login) GetCaptcha(ctx context.Context, length int) (*schema.LoginCaptcha, error)

GetCaptcha 获取图形验证码信息

func (*Login) GetLoginInfo

func (a *Login) GetLoginInfo(ctx context.Context, userID string) (*schema.UserLoginInfo, error)

GetLoginInfo 获取当前用户登录信息

func (*Login) QueryUserMenuTree

func (a *Login) QueryUserMenuTree(ctx context.Context, userID string) ([]*schema.MenuTree, error)

QueryUserMenuTree 查询当前用户的权限菜单树

func (*Login) ResCaptcha

func (a *Login) ResCaptcha(ctx context.Context, w http.ResponseWriter, captchaID string, width, height int) error

ResCaptcha 生成并响应图形验证码

func (*Login) UpdatePassword

func (a *Login) UpdatePassword(ctx context.Context, userID string, params schema.UpdatePasswordParam) error

UpdatePassword 更新当前用户登录密码

func (*Login) Verify

func (a *Login) Verify(ctx context.Context, userName, password string) (*schema.User, error)

Verify 登录验证

type Menu struct {
	TransModel model.ITrans
	MenuModel  model.IMenu
}

Menu 菜单管理

func NewMenu

func NewMenu(
	trans model.ITrans,
	mMenu model.IMenu,
) *Menu

NewMenu 创建菜单管理实例

func (a *Menu) Create(ctx context.Context, item schema.Menu) (*schema.Menu, error)

Create 创建数据

func (a *Menu) Delete(ctx context.Context, recordID string) error

Delete 删除数据

func (a *Menu) Get(ctx context.Context, recordID string, opts ...schema.MenuQueryOptions) (*schema.Menu, error)

Get 查询指定数据

Query 查询数据

func (a *Menu) Update(ctx context.Context, recordID string, item schema.Menu) (*schema.Menu, error)

Update 更新数据

type Role

type Role struct {
	Enforcer   *casbin.SyncedEnforcer
	RoleModel  model.IRole
	MenuModel  model.IMenu
	UserModel  model.IUser
	DeleteHook func(context.Context, *Role, string) error
	SaveHook   func(context.Context, *Role, *schema.Role) error
}

Role 角色管理

func NewRole

func NewRole(
	e *casbin.SyncedEnforcer,
	mRole model.IRole,
	mMenu model.IMenu,
	mUser model.IUser,
) *Role

NewRole 创建角色管理实例

func (*Role) Create

func (a *Role) Create(ctx context.Context, item schema.Role) (*schema.Role, error)

Create 创建数据

func (*Role) Delete

func (a *Role) Delete(ctx context.Context, recordID string) error

Delete 删除数据

func (*Role) Get

func (a *Role) Get(ctx context.Context, recordID string, opts ...schema.RoleQueryOptions) (*schema.Role, error)

Get 查询指定数据

func (*Role) GetMenuResources

func (a *Role) GetMenuResources(ctx context.Context, item *schema.Role) (schema.MenuResources, error)

GetMenuResources 获取资源权限

func (*Role) LoadPolicy

func (a *Role) LoadPolicy(ctx context.Context, item *schema.Role) error

LoadPolicy 加载角色权限策略

func (*Role) Query

Query 查询数据

func (*Role) Update

func (a *Role) Update(ctx context.Context, recordID string, item schema.Role) (*schema.Role, error)

Update 更新数据

type Trans

type Trans struct {
	TransModel model.ITrans
}

Trans 事务管理

func NewTrans

func NewTrans(trans model.ITrans) *Trans

NewTrans 创建角色管理实例

func (*Trans) Exec

func (a *Trans) Exec(ctx context.Context, fn func(context.Context) error) error

Exec 执行事务

type TransFunc

type TransFunc func(context.Context) error

TransFunc 定义事务执行函数

type User

type User struct {
	Enforcer   *casbin.SyncedEnforcer
	UserModel  model.IUser
	RoleModel  model.IRole
	DeleteHook func(context.Context, *User, string) error
	SaveHook   func(context.Context, *User, *schema.User) error
}

User 用户管理

func NewUser

func NewUser(
	e *casbin.SyncedEnforcer,
	mUser model.IUser,
	mRole model.IRole,
) *User

NewUser 创建菜单管理实例

func (*User) Create

func (a *User) Create(ctx context.Context, item schema.User) (*schema.User, error)

Create 创建数据

func (*User) Delete

func (a *User) Delete(ctx context.Context, recordID string) error

Delete 删除数据

func (*User) Get

func (a *User) Get(ctx context.Context, recordID string, opts ...schema.UserQueryOptions) (*schema.User, error)

Get 查询指定数据

func (*User) LoadPolicy

func (a *User) LoadPolicy(ctx context.Context, item *schema.User) error

LoadPolicy 加载用户权限策略

func (*User) Query

Query 查询数据

func (*User) QueryShow

QueryShow 查询显示项数据

func (*User) Update

func (a *User) Update(ctx context.Context, recordID string, item schema.User) (*schema.User, error)

Update 更新数据

func (*User) UpdateStatus

func (a *User) UpdateStatus(ctx context.Context, recordID string, status int) error

UpdateStatus 更新状态

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL