|
|
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, //机会管理
|
|
|
} |