Documentation ¶
Index ¶
- type IPermissionRepository
- type IRoleRepository
- type IUserRepository
- type PermissionRepository
- func (u *PermissionRepository) CreatePermission(permission *model.Permission) (int64, error)
- func (u *PermissionRepository) DeletePermissionByID(permissionID int64) error
- func (u *PermissionRepository) FindAll() (permissionAll []model.Permission, err error)
- func (u *PermissionRepository) FindAllPermissionById(id []int64) (permissionAll []*model.Permission, err error)
- func (u *PermissionRepository) FindPermissionByID(permissionID int64) (permission *model.Permission, err error)
- func (u *PermissionRepository) UpdatePermission(permission *model.Permission) error
- type RoleRepository
- func (u *RoleRepository) AddPermission(role *model.Role, permission []*model.Permission) error
- func (u *RoleRepository) CreateRole(role *model.Role) (int64, error)
- func (u *RoleRepository) DeletePermission(role *model.Role, permission []*model.Permission) error
- func (u *RoleRepository) DeleteRoleByID(roleID int64) error
- func (u *RoleRepository) FindAll() (roleAll []model.Role, err error)
- func (u *RoleRepository) FindAllRoleById(id []int64) (roleAll []*model.Role, err error)
- func (u *RoleRepository) FindRoleByID(roleID int64) (role *model.Role, err error)
- func (u *RoleRepository) UpdatePermission(role *model.Role, permission []*model.Permission) error
- func (u *RoleRepository) UpdateRole(role *model.Role) error
- type UserRepository
- func (u *UserRepository) AddRole(user *model.User, roles []*model.Role) error
- func (u *UserRepository) CreateUser(user *model.User) (int64, error)
- func (u *UserRepository) DeleteRole(user *model.User, roles []*model.Role) error
- func (u *UserRepository) DeleteUserByID(userID int64) error
- func (u *UserRepository) FindAll() (userAll []model.User, err error)
- func (u *UserRepository) FindUserByID(userID int64) (user *model.User, err error)
- func (u *UserRepository) InitTable() error
- func (u *UserRepository) IsRight(action string, userID int64) bool
- func (u *UserRepository) UpdateRole(user *model.User, roles []*model.Role) error
- func (u *UserRepository) UpdateUser(user *model.User) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPermissionRepository ¶
type IPermissionRepository interface { //根据ID查处找数据 FindPermissionByID(int64) (*model.Permission, error) //创建一条 permission 数据 CreatePermission(*model.Permission) (int64, error) //根据ID删除一条 permission 数据 DeletePermissionByID(int64) error //修改更新数据 UpdatePermission(*model.Permission) error //查找permission所有数据 FindAll() ([]model.Permission, error) //根据ID查找所有权限 FindAllPermissionById([]int64) ([]*model.Permission, error) }
创建需要实现的接口
func NewPermissionRepository ¶
func NewPermissionRepository(db *gorm.DB) IPermissionRepository
创建PermissionRepository
type IRoleRepository ¶
type IRoleRepository interface { //根据ID查处找数据 FindRoleByID(int64) (*model.Role, error) //创建一条 role 数据 CreateRole(*model.Role) (int64, error) //根据ID删除一条 role 数据 DeleteRoleByID(int64) error //修改更新数据 UpdateRole(*model.Role) error //查找role所有数据 FindAll() ([]model.Role, error) //根据ID查找所有角色 FindAllRoleById([]int64) ([]*model.Role, error) //添加角色权限 AddPermission(*model.Role, []*model.Permission) error //更新角色权限 UpdatePermission(*model.Role, []*model.Permission) error //删除角色权限 DeletePermission(*model.Role, []*model.Permission) error }
创建需要实现的接口
type IUserRepository ¶
type IUserRepository interface { //初始化表 InitTable() error //根据ID查处找数据 FindUserByID(int64) (*model.User, error) //创建一条 user 数据 CreateUser(*model.User) (int64, error) //根据ID删除一条 user 数据 DeleteUserByID(int64) error //修改更新数据 UpdateUser(*model.User) error //查找user所有数据 FindAll() ([]model.User, error) //分配角色 AddRole(*model.User, []*model.Role) error //更新用户角色 UpdateRole(*model.User, []*model.Role) error //删除用户的角色 DeleteRole(*model.User, []*model.Role) error //判断用户是否有对应的权限 IsRight(string, int64) bool }
创建需要实现的接口
type PermissionRepository ¶
type PermissionRepository struct {
// contains filtered or unexported fields
}
func (*PermissionRepository) CreatePermission ¶
func (u *PermissionRepository) CreatePermission(permission *model.Permission) (int64, error)
创建Permission信息
func (*PermissionRepository) DeletePermissionByID ¶
func (u *PermissionRepository) DeletePermissionByID(permissionID int64) error
根据ID删除Permission信息
func (*PermissionRepository) FindAll ¶
func (u *PermissionRepository) FindAll() (permissionAll []model.Permission, err error)
获取结果集
func (*PermissionRepository) FindAllPermissionById ¶
func (u *PermissionRepository) FindAllPermissionById(id []int64) (permissionAll []*model.Permission, err error)
func (*PermissionRepository) FindPermissionByID ¶
func (u *PermissionRepository) FindPermissionByID(permissionID int64) (permission *model.Permission, err error)
根据ID查找Permission信息
func (*PermissionRepository) UpdatePermission ¶
func (u *PermissionRepository) UpdatePermission(permission *model.Permission) error
更新Permission信息
type RoleRepository ¶
type RoleRepository struct {
// contains filtered or unexported fields
}
func (*RoleRepository) AddPermission ¶
func (u *RoleRepository) AddPermission(role *model.Role, permission []*model.Permission) error
为角色添加权限
func (*RoleRepository) CreateRole ¶
func (u *RoleRepository) CreateRole(role *model.Role) (int64, error)
创建Role信息
func (*RoleRepository) DeletePermission ¶
func (u *RoleRepository) DeletePermission(role *model.Role, permission []*model.Permission) error
删除角色权限
func (*RoleRepository) DeleteRoleByID ¶
func (u *RoleRepository) DeleteRoleByID(roleID int64) error
根据ID删除Role信息
func (*RoleRepository) FindAll ¶
func (u *RoleRepository) FindAll() (roleAll []model.Role, err error)
获取结果集
func (*RoleRepository) FindAllRoleById ¶
func (u *RoleRepository) FindAllRoleById(id []int64) (roleAll []*model.Role, err error)
根据ID获取素有角色
func (*RoleRepository) FindRoleByID ¶
func (u *RoleRepository) FindRoleByID(roleID int64) (role *model.Role, err error)
根据ID查找Role信息
func (*RoleRepository) UpdatePermission ¶
func (u *RoleRepository) UpdatePermission(role *model.Role, permission []*model.Permission) error
为角更新加权限
func (*RoleRepository) UpdateRole ¶
func (u *RoleRepository) UpdateRole(role *model.Role) error
更新Role信息
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
func (*UserRepository) CreateUser ¶
func (u *UserRepository) CreateUser(user *model.User) (int64, error)
创建User信息
func (*UserRepository) DeleteRole ¶
删除用户的角色
func (*UserRepository) DeleteUserByID ¶
func (u *UserRepository) DeleteUserByID(userID int64) error
根据ID删除User信息
func (*UserRepository) FindAll ¶
func (u *UserRepository) FindAll() (userAll []model.User, err error)
获取结果集
func (*UserRepository) FindUserByID ¶
func (u *UserRepository) FindUserByID(userID int64) (user *model.User, err error)
根据ID查找User信息
func (*UserRepository) IsRight ¶
func (u *UserRepository) IsRight(action string, userID int64) bool
检测当前用户是否具备权限
func (*UserRepository) UpdateRole ¶
更新用户角色
func (*UserRepository) UpdateUser ¶
func (u *UserRepository) UpdateUser(user *model.User) error
更新User信息
Click to show internal directories.
Click to hide internal directories.