mysql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Common

type Common struct {
	User *User
	Role *Role
	Demo *Demo
	Menu *Menu
}

Common mysql存储模块

func (*Common) Init

func (a *Common) Init(g *inject.Graph, db *mysql.DB) *Common

Init 初始化

func (*Common) TableName

func (a *Common) TableName(name string) string

TableName 获取表名

func (*Common) TablePrefix

func (a *Common) TablePrefix() string

TablePrefix 获取表名前缀

type Demo

type Demo struct {
	DB     *mysql.DB
	Common *Common
}

Demo 示例程序

func (*Demo) Check

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

Check 检查数据是否存在

func (*Demo) Create

func (a *Demo) Create(ctx context.Context, item *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) (*schema.Demo, error)

Get 查询指定数据

func (*Demo) Init

func (a *Demo) Init(g *inject.Graph, db *mysql.DB, c *Common) *Demo

Init 初始化

func (*Demo) QueryPage

func (a *Demo) QueryPage(ctx context.Context, params schema.DemoQueryParam, pageIndex, pageSize uint) (int64, []*schema.DemoQueryResult, error)

QueryPage 查询分页数据

func (*Demo) TableName

func (a *Demo) TableName() string

TableName 表名

func (*Demo) Update

func (a *Demo) Update(ctx context.Context, recordID string, info map[string]interface{}) error

Update 更新数据

type Menu struct {
	DB     *mysql.DB
	Common *Common
}

Menu 菜单管理

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

Check 检查数据是否存在

func (a *Menu) CheckChild(ctx context.Context, parentID string) (bool, error)

CheckChild 检查子级是否存在

func (a *Menu) CheckCode(ctx context.Context, code string, parentID string) (bool, error)

CheckCode 检查编号是否存在

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

Create 创建数据

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

Delete 删除数据

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

Get 查询指定数据

func (a *Menu) GetByCodeAndType(ctx context.Context, code string, typ int) (*schema.Menu, error)

GetByCodeAndType 根据编号和类型查询指定数据

func (a *Menu) Init(g *inject.Graph, db *mysql.DB, c *Common) *Menu

Init 初始化

func (a *Menu) QueryLevelCodesByParentID(parentID string) ([]string, error)

QueryLevelCodesByParentID 根据父级查询分级码

func (a *Menu) QueryLevelCodesByUserID(userID string) ([]string, error)

QueryLevelCodesByUserID 查询用户所拥有的菜单权限

func (a *Menu) QueryPage(ctx context.Context, params schema.MenuQueryParam, pageIndex, pageSize uint) (int64, []*schema.MenuQueryResult, error)

QueryPage 查询分页数据

QuerySelect 查询选择数据

func (a *Menu) TableName() string

TableName 表名

func (a *Menu) Update(ctx context.Context, recordID string, info map[string]interface{}) error

Update 更新数据

func (a *Menu) UpdateWithLevelCode(ctx context.Context, recordID string, info map[string]interface{}, oldLevelCode, newLevelCode string) error

UpdateWithLevelCode 更新数据

type Role

type Role struct {
	DB     *mysql.DB
	Common *Common
}

Role 角色管理

func (*Role) Check

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

Check 检查数据是否存在

func (*Role) CheckName

func (a *Role) CheckName(ctx context.Context, name string) (bool, error)

CheckName 检查名称

func (*Role) Create

func (a *Role) Create(ctx context.Context, item *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, includeMenuIDs bool) (*schema.Role, error)

Get 查询指定数据

func (*Role) Init

func (a *Role) Init(g *inject.Graph, db *mysql.DB, c *Common) *Role

Init 初始化

func (*Role) QueryMenuIDs

func (a *Role) QueryMenuIDs(ctx context.Context, roleID string) ([]string, error)

QueryMenuIDs 查询角色菜单

func (*Role) QueryPage

func (a *Role) QueryPage(ctx context.Context, params schema.RoleQueryParam, pageIndex, pageSize uint) (int64, []*schema.RoleQueryResult, error)

QueryPage 查询分页数据

func (*Role) QuerySelect

QuerySelect 查询选择数据

func (*Role) RoleMenuTableName

func (a *Role) RoleMenuTableName() string

RoleMenuTableName 角色菜单表名

func (*Role) TableName

func (a *Role) TableName() string

TableName 角色表名

func (*Role) Update

func (a *Role) Update(ctx context.Context, recordID string, info map[string]interface{}) error

Update 更新数据

func (*Role) UpdateWithMenuIDs

func (a *Role) UpdateWithMenuIDs(ctx context.Context, recordID string, info map[string]interface{}, menuIDs []string) error

UpdateWithMenuIDs 更新数据

type User

type User struct {
	DB     *mysql.DB
	Common *Common
}

User 用户管理

func (*User) Check

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

Check 检查数据是否存在

func (*User) CheckByRoleID

func (a *User) CheckByRoleID(ctx context.Context, roleID string) (bool, error)

CheckByRoleID 检查角色下是否存在用户

func (*User) CheckUserName

func (a *User) CheckUserName(ctx context.Context, userName string) (bool, error)

CheckUserName 检查用户名

func (*User) Create

func (a *User) Create(ctx context.Context, item *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, includeRoleIDs bool) (*schema.User, error)

Get 查询指定数据

func (*User) GetByUserName

func (a *User) GetByUserName(ctx context.Context, userName string, includeRoleIDs bool) (*schema.User, error)

GetByUserName 根据用户名查询指定数据

func (*User) Init

func (a *User) Init(g *inject.Graph, db *mysql.DB, c *Common) *User

Init 初始化

func (*User) QueryPage

func (a *User) QueryPage(ctx context.Context, params schema.UserQueryParam, pageIndex, pageSize uint) (int64, []*schema.UserQueryResult, error)

QueryPage 查询分页数据

func (*User) QueryRoleIDs

func (a *User) QueryRoleIDs(ctx context.Context, userID string) ([]string, error)

QueryRoleIDs 查询用户角色

func (*User) QueryUserRoles added in v1.1.0

func (a *User) QueryUserRoles(ctx context.Context, params schema.UserRoleQueryParam) ([]*schema.UserRole, error)

QueryUserRoles 查询用户角色

func (*User) TableName

func (a *User) TableName() string

TableName 表名

func (*User) Update

func (a *User) Update(ctx context.Context, recordID string, info map[string]interface{}) error

Update 更新数据

func (*User) UpdateWithRoleIDs

func (a *User) UpdateWithRoleIDs(ctx context.Context, recordID string, info map[string]interface{}, roleIDs []string) error

UpdateWithRoleIDs 更新数据

func (*User) UserRoleTableName

func (a *User) UserRoleTableName() string

UserRoleTableName 用户角色表名

Jump to

Keyboard shortcuts

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