role

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRole

func CreateRole(c *gin.Context)

CreateRole

func DeleteRole

func DeleteRole(c *gin.Context)

DeleteRole

func GetRoleInfo

func GetRoleInfo(c *gin.Context)

GetRoleInfo

func List

func List(c *gin.Context)

List

func SetPermission

func SetPermission(c *gin.Context)

SetPermission 管理员设置用户权限

func UpdateRole

func UpdateRole(c *gin.Context)

UpdateRole post json

Types

type Role

type Role struct {
	ID          int    `json:"id" gorm:"AUTO_INCREMENT;primary_key"`
	RoleNum     int    `json:"roleNum" gorm:"comment:'超管1,管理员2,开发3'"` //超管1,管理员2,开发3
	Name        string `json:"name"`                                  //说明
	Permissions string `json:"permissions"`                           //该角色拥有的权限
}

func (Role) TableName

func (Role) TableName() string

设置Permission的表名为`permission`

type RolePermission

type RolePermission struct {
	ID           int    `json:"id"`
	RoleID       int    `json:"roleID"`
	PermissionID string `json:"permissionID"`
}

func (RolePermission) TableName

func (RolePermission) TableName() string

设置Permission的表名为`permission`

type RoleService

type RoleService interface {
	GetRoleInfo(search Role) (role Role, err error)
	GetRoleList(page, limit int, search Role) (list []Role, count int, err error)
	RolePermissions(roleID int) (role Role, err error)
	CreateRole(role *Role) (err error)
	UpdateRole(ID int, role *Role) (err error)
	DeleteRole(ID int) (err error)
}

*

面向接口开发:
面向接口开发的好处是要对下面的函数进行测试时,不需要依赖一个全局的db连接,只需要调用NewService传一个db连接参数即可测试

func NewService

func NewService(db *gorm.DB) RoleService

NewService 初始化结构体

Jump to

Keyboard shortcuts

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