permission.go
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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"`
// }