permission.go
2.8 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package routers
import (
"encoding/json"
)
//PermissionBase 路由对应的权限
type PermissionBase struct {
CodeName string //模块标识
ActionName string
// MethodMap map[string]func()
}
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"},
}
var permissionObject = map[string]interface{}{
"": 0,
}
//模块编号
const (
MENU_DEPARTMENT string = "OPPMG_DEPARTMENT" //公司部门管理模块
MENU_POSITION string = "OPPMG_POSITION" //公司职务管理
MENU_RBAC string = "OPPMG_RBAC" //员工角色/权限设置
MENU_USER string = "OPPMG_USER" //公司员工管理
MENU_ENTERPRISE_BASIC string = "OPPMG_ENTERPRISE_BASIC" //企业基础设置(大节点)
MENU_SYSTEM_FUNCTION string = "OPPMG_SYSTEM_FUNCTION" //系统功能(大节点)
MENU_CONMPANY string = "OPPMG_CONMPANY" //企业信息维护
MENU_CHANCE_TEMP string = "OPPMG_CHANCE_TEMP" //机会模板管理
MENU_SORCE string = "OPPMG_SORCE" //评分模式
MENU_CHANCE string = "OPPMG_CHANCE" //机会管理
)
type PermissionContentObject interface {
StringUnmarshal(string) error
ObjectMarshal() (string, error)
}
type PermissionContentBase struct {
Check int8 `json:"check"`
}
func NewPermissionContentBase() PermissionContentObject {
return &PermissionContentBase{}
}
func (p *PermissionContentBase) StringUnmarshal(s string) error {
err := json.Unmarshal([]byte(s), p)
return err
}
func (p *PermissionContentBase) ObjectMarshal() (string, error) {
bt, err := json.Marshal(p)
if err != nil {
return "", err
}
return string(bt), err
}
type CodeToObject func() PermissionContentObject
var CodePermissionObject = map[string]CodeToObject{
MENU_DEPARTMENT: NewPermissionContentBase, //公司部门管理模块
MENU_POSITION: NewPermissionContentBase, //公司职务管理
MENU_RBAC: NewPermissionContentBase, //员工角色/权限设置
MENU_USER: NewPermissionContentBase, //公司员工管理
MENU_ENTERPRISE_BASIC: NewPermissionContentBase, //企业基础设置(大节点)
MENU_SYSTEM_FUNCTION: NewPermissionContentBase, //系统功能(大节点)
MENU_CONMPANY: NewPermissionContentBase, //企业信息维护
MENU_CHANCE_TEMP: NewPermissionContentBase, //机会模板管理
MENU_SORCE: NewPermissionContentBase, //评分模式
MENU_CHANCE: NewPermissionContentBase, //机会管理
}