permission.go 1.1 KB
package routers

//PermissionBase 路由对应的权限
type PermissionBase struct {
	CodeName   string //模块标识
	ActionName string
	MethodMap  map[string]func()
}

func (p PermissionBase) ValidMapping(actionName string, fn func()) {
	p.MethodMap[actionName] = fn
}

var routerPermission = map[string]PermissionBase{
	"/v1/department/list":   PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "check"},
	"/v1/department/add":    PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "add"},
	"/v1/department/edit":   PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "edit"},
	"/v1/department/delete": PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "delete"},
}

//PermissionWithPosition 职位管理相关
type PermissionWithPosition struct {
	PermissionBase
}

//GetCode 模块标识
func (c *PermissionWithPosition) GetCodeName() string {
	return "OPPMG_DEPARTMENT"
}

//Valid 权限校验
func (c PermissionWithPosition) Valid(userCompanyID int64) bool {
	return true
}

//PermissionWithDepart 部门管理相关
// type PermissionWithDepart struct {
// 	Check int8 `json:"check"`
// }