作者 唐旭辉

权限调试 修改

@@ -18,19 +18,6 @@ type BaseController struct { @@ -18,19 +18,6 @@ type BaseController struct {
18 beego.Controller 18 beego.Controller
19 } 19 }
20 20
21 -func (this *BaseController) Options() {  
22 - this.AllowCross() //允许跨域  
23 - this.Data["json"] = map[string]interface{}{"status": 204, "message": "ok", "moreinfo": ""}  
24 - this.ServeJSON()  
25 -}  
26 -  
27 -func (this *BaseController) AllowCross() {  
28 - this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")  
29 - this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")  
30 - this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")  
31 - //this.Ctx.WriteString("")  
32 -}  
33 -  
34 //Prepare 实现beego.ControllerInterface 的接口 21 //Prepare 实现beego.ControllerInterface 的接口
35 func (this *BaseController) Prepare() { 22 func (this *BaseController) Prepare() {
36 this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*") 23 this.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
@@ -226,6 +226,17 @@ func (c *RbacController) RoleHasMenu() { @@ -226,6 +226,17 @@ func (c *RbacController) RoleHasMenu() {
226 return 226 return
227 } 227 }
228 228
  229 +func (c *RbacController) GetRoleMenuAll() {
  230 + var msg *protocol.ResponseMessage
  231 + defer func() {
  232 + c.ResposeJson(msg)
  233 + }()
  234 + log.Info("====>")
  235 + list, err := serverbac.GetRoleHasMenuAll(1, 1)
  236 + msg = protocol.NewReturnResponse(list, err)
  237 + return
  238 +}
  239 +
229 func (c *RbacController) RoleMenuEdit() { 240 func (c *RbacController) RoleMenuEdit() {
230 return 241 return
231 } 242 }
@@ -9,6 +9,7 @@ type RoleMenu struct { @@ -9,6 +9,7 @@ type RoleMenu struct {
9 RoleId int64 `orm:"column(role_id);null" description:"role.id"` 9 RoleId int64 `orm:"column(role_id);null" description:"role.id"`
10 MenuId int64 `orm:"column(menu_id);null" description:"menu.id"` 10 MenuId int64 `orm:"column(menu_id);null" description:"menu.id"`
11 Opption string `orm:"column(opption);size(500);null" description:"配置"` 11 Opption string `orm:"column(opption);size(500);null" description:"配置"`
  12 + Code string `orm:"column(code)"`
12 } 13 }
13 14
14 func (t *RoleMenu) TableName() string { 15 func (t *RoleMenu) TableName() string {
@@ -40,7 +40,7 @@ type ResponseDepartmentInfo struct { @@ -40,7 +40,7 @@ type ResponseDepartmentInfo struct {
40 ID int64 `json:"id"` 40 ID int64 `json:"id"`
41 CompanyID int64 `json:"company_id"` //公司 41 CompanyID int64 `json:"company_id"` //公司
42 Name string `json:"name"` //部门名字 42 Name string `json:"name"` //部门名字
43 - ParantID int64 `json:"parant_id"` //父级部门Id 43 + ParantID int64 `json:"parantId"` //父级部门Id
44 Manages []DepartmentManager `json:"manages"` //部门管理员 44 Manages []DepartmentManager `json:"manages"` //部门管理员
45 Members []DepartmentMember `json:"members"` //部门成员 45 Members []DepartmentMember `json:"members"` //部门成员
46 Member int64 `json:"member"` //成员数 46 Member int64 `json:"member"` //成员数
1 package routers 1 package routers
2 2
  3 +import (
  4 + "encoding/json"
  5 +)
  6 +
3 //PermissionBase 路由对应的权限 7 //PermissionBase 路由对应的权限
4 type PermissionBase struct { 8 type PermissionBase struct {
5 CodeName string //模块标识 9 CodeName string //模块标识
6 ActionName string 10 ActionName string
7 - MethodMap map[string]func()  
8 -}  
9 -  
10 -func (p PermissionBase) ValidMapping(actionName string, fn func()) {  
11 - p.MethodMap[actionName] = fn 11 + // MethodMap map[string]func()
12 } 12 }
13 13
14 var routerPermission = map[string]PermissionBase{ 14 var routerPermission = map[string]PermissionBase{
@@ -18,22 +18,61 @@ var routerPermission = map[string]PermissionBase{ @@ -18,22 +18,61 @@ var routerPermission = map[string]PermissionBase{
18 "/v1/department/delete": PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "delete"}, 18 "/v1/department/delete": PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "delete"},
19 } 19 }
20 20
21 -//PermissionWithPosition 职位管理相关  
22 -// type PermissionWithPosition struct {  
23 -// PermissionBase  
24 -// } 21 +var permissionObject = map[string]interface{}{
  22 + "": 0,
  23 +}
  24 +
  25 +//模块编号
  26 +const (
  27 + MENU_DEPARTMENT string = "OPPMG_DEPARTMENT" //公司部门管理模块
  28 + MENU_POSITION string = "OPPMG_POSITION" //公司职务管理
  29 + MENU_RBAC string = "OPPMG_RBAC" //员工角色/权限设置
  30 + MENU_USER string = "OPPMG_USER" //公司员工管理
  31 + MENU_ENTERPRISE_BASIC string = "OPPMG_ENTERPRISE_BASIC" //企业基础设置(大节点)
  32 + MENU_SYSTEM_FUNCTION string = "OPPMG_SYSTEM_FUNCTION" //系统功能(大节点)
  33 + MENU_CONMPANY string = "OPPMG_CONMPANY" //企业信息维护
  34 + MENU_CHANCE_TEMP string = "OPPMG_CHANCE_TEMP" //机会模板管理
  35 + MENU_SORCE string = "OPPMG_SORCE" //评分模式
  36 + MENU_CHANCE string = "OPPMG_CHANCE" //机会管理
  37 +)
25 38
26 -//GetCode 模块标识  
27 -// func (c *PermissionWithPosition) GetCodeName() string {  
28 -// return "OPPMG_DEPARTMENT"  
29 -// } 39 +type PermissionContentObject interface {
  40 + StringUnmarshal(string) error
  41 + ObjectMarshal() (string, error)
  42 +}
30 43
31 -//Valid 权限校验  
32 -// func (c PermissionWithPosition) Valid(userCompanyID int64) bool {  
33 -// return true  
34 -// } 44 +type PermissionContentBase struct {
  45 + Check int8 `json:"check"`
  46 +}
35 47
36 -//PermissionWithDepart 部门管理相关  
37 -// type PermissionWithDepart struct {  
38 -// Check int8 `json:"check"`  
39 -// } 48 +func NewPermissionContentBase() PermissionContentObject {
  49 + return &PermissionContentBase{}
  50 +}
  51 +
  52 +func (p *PermissionContentBase) StringUnmarshal(s string) error {
  53 + err := json.Unmarshal([]byte(s), p)
  54 + return err
  55 +}
  56 +
  57 +func (p *PermissionContentBase) ObjectMarshal() (string, error) {
  58 + bt, err := json.Marshal(p)
  59 + if err != nil {
  60 + return "", err
  61 + }
  62 + return string(bt), err
  63 +}
  64 +
  65 +type CodeToObject func() PermissionContentObject
  66 +
  67 +var CodePermissionObject = map[string]CodeToObject{
  68 + MENU_DEPARTMENT: NewPermissionContentBase, //公司部门管理模块
  69 + MENU_POSITION: NewPermissionContentBase, //公司职务管理
  70 + MENU_RBAC: NewPermissionContentBase, //员工角色/权限设置
  71 + MENU_USER: NewPermissionContentBase, //公司员工管理
  72 + MENU_ENTERPRISE_BASIC: NewPermissionContentBase, //企业基础设置(大节点)
  73 + MENU_SYSTEM_FUNCTION: NewPermissionContentBase, //系统功能(大节点)
  74 + MENU_CONMPANY: NewPermissionContentBase, //企业信息维护
  75 + MENU_CHANCE_TEMP: NewPermissionContentBase, //机会模板管理
  76 + MENU_SORCE: NewPermissionContentBase, //评分模式
  77 + MENU_CHANCE: NewPermissionContentBase, //机会管理
  78 +}
@@ -3,6 +3,8 @@ package routers @@ -3,6 +3,8 @@ package routers
3 import ( 3 import (
4 "oppmg/controllers" 4 "oppmg/controllers"
5 5
  6 + "github.com/astaxie/beego/context"
  7 +
6 "oppmg/middleware" 8 "oppmg/middleware"
7 9
8 "github.com/astaxie/beego" 10 "github.com/astaxie/beego"
@@ -84,9 +86,20 @@ func init() { @@ -84,9 +86,20 @@ func init() {
84 beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"), 86 beego.NSRouter("/company", &controllers.CompanyController{}, "post:InitCompany"),
85 beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"), 87 beego.NSRouter("/company/info", &controllers.CompanyController{}, "post:GetCompanyForUCenter"),
86 ) 88 )
  89 +
87 beego.AddNamespace(nsV1) 90 beego.AddNamespace(nsV1)
88 beego.AddNamespace(nsAuth) 91 beego.AddNamespace(nsAuth)
89 beego.AddNamespace(nsUcenter) 92 beego.AddNamespace(nsUcenter)
90 93
  94 + nsTest := beego.NewNamespace("/test",
  95 + beego.NSCond(func(ctx *context.Context) bool {
  96 + if beego.BConfig.RunMode != "prod" {
  97 + return true
  98 + }
  99 + return false
  100 + }),
  101 + beego.NSRouter("/te", &controllers.RbacController{}, "get:GetRoleMenuAll"),
  102 + )
  103 + beego.AddNamespace(nsTest)
91 beego.SetStaticPath("/log", beego.AppConfig.String("log_filename")) 104 beego.SetStaticPath("/log", beego.AppConfig.String("log_filename"))
92 } 105 }
  1 +package rbac
  2 +
  3 +import (
  4 + "oppmg/common/log"
  5 + "oppmg/models"
  6 + "oppmg/protocol"
  7 + "oppmg/utils"
  8 +)
  9 +
  10 +//获取全部的权限菜单
  11 +func GetMenuAll() ([]protocol.PermissionItem, error) {
  12 + const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code
  13 + FROM menu WHERE enabled=1 ORDER BY sort `
  14 + var (
  15 + list []protocol.PermissionItem
  16 + err error
  17 + )
  18 + err = utils.ExecuteQueryAll(&list, datasql)
  19 + if err != nil {
  20 + log.Error("EXECUTE SQL err:%s", err)
  21 + return nil, protocol.NewErrWithMessage("1")
  22 + }
  23 + return list, nil
  24 +}
  25 +
  26 +//
  27 +func GetRoleHasMenu(roleid int64, companyid int64) (*protocol.ResponseRoleMenus, error) {
  28 + var (
  29 + roleData *models.Role
  30 + err error
  31 + )
  32 + roleData, err = models.GetRoleById(roleid)
  33 + if err != nil {
  34 + log.Error("获取角色数据失败:%s", err)
  35 + return nil, err
  36 + }
  37 + if roleData.Types != models.ROLETYPES_ROLE {
  38 + log.Error("角色类型错误")
  39 + return nil, protocol.NewErrWithMessage("1")
  40 + }
  41 + if roleData.CompanyId != companyid {
  42 + log.Error("角色的公司id不匹配")
  43 + return nil, protocol.NewErrWithMessage("1")
  44 + }
  45 + var (
  46 + rolemenu []models.RoleMenu
  47 + ids []int64
  48 + )
  49 + rolemenu, err = models.GetRoleMenuByRole(roleid)
  50 + if err != nil {
  51 + log.Error("获取角色下的菜单数据失败:%s", err)
  52 + return nil, protocol.NewErrWithMessage("1")
  53 + }
  54 + for _, v := range rolemenu {
  55 + ids = append(ids, v.MenuId)
  56 + }
  57 + data := &protocol.ResponseRoleMenus{
  58 + RoleId: roleData.Id,
  59 + RoleName: roleData.Name,
  60 + MenuId: ids,
  61 + }
  62 + return data, nil
  63 +}
  64 +
  65 +func GetRoleHasMenuAll(roleid int64, companyid int64) (map[string]PermissionContentObject, error) {
  66 + var (
  67 + roleData *models.Role
  68 + err error
  69 + )
  70 + roleData, err = models.GetRoleById(roleid)
  71 + if err != nil {
  72 + log.Error("获取角色数据失败:%s", err)
  73 + return nil, err
  74 + }
  75 + if roleData.Types != models.ROLETYPES_ROLE {
  76 + log.Error("角色类型错误")
  77 + return nil, protocol.NewErrWithMessage("1")
  78 + }
  79 + if roleData.CompanyId != companyid {
  80 + log.Error("角色的公司id不匹配")
  81 + return nil, protocol.NewErrWithMessage("1")
  82 + }
  83 + var (
  84 + rolemenu []models.RoleMenu
  85 + returnList = make(map[string]PermissionContentObject)
  86 + )
  87 + rolemenu, err = models.GetRoleMenuByRole(roleid)
  88 + if err != nil {
  89 + log.Error("获取角色下的菜单数据失败:%s", err)
  90 + return nil, protocol.NewErrWithMessage("1")
  91 + }
  92 + for _, v := range rolemenu {
  93 + if fn, ok := CodePermissionObject[v.Code]; ok {
  94 + obj := fn()
  95 + err := obj.StringUnmarshal(v.Opption)
  96 + if err != nil {
  97 + log.Error("解析权限规则失败", err)
  98 + continue
  99 + }
  100 + returnList[v.Code] = obj
  101 + }
  102 + }
  103 + return returnList, nil
  104 +}
  105 +
  106 +func RoleMenuEdit(companyid int64, roleid int64, menuids []int64) {
  107 +
  108 +}
1 package rbac 1 package rbac
2 2
3 import ( 3 import (
4 - "oppmg/common/log"  
5 - "oppmg/models"  
6 - "oppmg/protocol"  
7 - "oppmg/utils" 4 + "encoding/json"
8 ) 5 )
9 6
10 -//获取全部的权限菜单  
11 -func GetMenuAll() ([]protocol.PermissionItem, error) {  
12 - const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code  
13 - FROM menu WHERE enabled=1 ORDER BY sort `  
14 - var (  
15 - list []protocol.PermissionItem  
16 - err error  
17 - )  
18 - err = utils.ExecuteQueryAll(&list, datasql)  
19 - if err != nil {  
20 - log.Error("EXECUTE SQL err:%s", err)  
21 - return nil, protocol.NewErrWithMessage("1")  
22 - }  
23 - return list, nil 7 +//PermissionBase 路由对应的权限
  8 +type PermissionBase struct {
  9 + CodeName string //模块标识
  10 + ActionName string
  11 + // MethodMap map[string]func()
24 } 12 }
25 13
26 -//  
27 -func GetRoleHasMenu(roleid int64, companyid int64) (*protocol.ResponseRoleMenus, error) {  
28 - var (  
29 - roleData *models.Role  
30 - err error  
31 - )  
32 - roleData, err = models.GetRoleById(roleid)  
33 - if err != nil {  
34 - log.Error("获取角色数据失败:%s", err)  
35 - return nil, err  
36 - }  
37 - if roleData.Types != models.ROLETYPES_ROLE {  
38 - log.Error("角色类型错误")  
39 - return nil, protocol.NewErrWithMessage("1")  
40 - }  
41 - if roleData.CompanyId != companyid {  
42 - log.Error("角色的公司id不匹配")  
43 - return nil, protocol.NewErrWithMessage("1")  
44 - }  
45 - var (  
46 - rolemenu []models.RoleMenu  
47 - ids []int64  
48 - )  
49 - rolemenu, err = models.GetRoleMenuByRole(roleid) 14 +var routerPermission = map[string]PermissionBase{
  15 + "/v1/department/list": PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "check"},
  16 + "/v1/department/add": PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "add"},
  17 + "/v1/department/edit": PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "edit"},
  18 + "/v1/department/delete": PermissionBase{CodeName: "OPPMG_DEPARTMENT", ActionName: "delete"},
  19 +}
  20 +
  21 +var permissionObject = map[string]interface{}{
  22 + "": 0,
  23 +}
  24 +
  25 +//模块编号
  26 +const (
  27 + MENU_DEPARTMENT string = "OPPMG_DEPARTMENT" //公司部门管理模块
  28 + MENU_POSITION string = "OPPMG_POSITION" //公司职务管理
  29 + MENU_RBAC string = "OPPMG_RBAC" //员工角色/权限设置
  30 + MENU_USER string = "OPPMG_USER" //公司员工管理
  31 + MENU_ENTERPRISE_BASIC string = "OPPMG_ENTERPRISE_BASIC" //企业基础设置(大节点)
  32 + MENU_SYSTEM_FUNCTION string = "OPPMG_SYSTEM_FUNCTION" //系统功能(大节点)
  33 + MENU_CONMPANY string = "OPPMG_CONMPANY" //企业信息维护
  34 + MENU_CHANCE_TEMP string = "OPPMG_CHANCE_TEMP" //机会模板管理
  35 + MENU_SORCE string = "OPPMG_SORCE" //评分模式
  36 + MENU_CHANCE string = "OPPMG_CHANCE" //机会管理
  37 +)
  38 +
  39 +type PermissionContentObject interface {
  40 + StringUnmarshal(string) error
  41 + ObjectMarshal() (string, error)
  42 +}
  43 +
  44 +type PermissionContentBase struct {
  45 + Check int8 `json:"check"`
  46 +}
  47 +
  48 +func NewPermissionContentBase() PermissionContentObject {
  49 + return &PermissionContentBase{}
  50 +}
  51 +
  52 +func (p *PermissionContentBase) StringUnmarshal(s string) error {
  53 + err := json.Unmarshal([]byte(s), p)
  54 + return err
  55 +}
  56 +
  57 +func (p *PermissionContentBase) ObjectMarshal() (string, error) {
  58 + bt, err := json.Marshal(p)
50 if err != nil { 59 if err != nil {
51 - log.Error("获取角色下的菜单数据失败:%s", err)  
52 - return nil, protocol.NewErrWithMessage("1")  
53 - }  
54 - for _, v := range rolemenu {  
55 - ids = append(ids, v.MenuId) 60 + return "", err
56 } 61 }
57 - data := &protocol.ResponseRoleMenus{  
58 - RoleId: roleData.Id,  
59 - RoleName: roleData.Name,  
60 - MenuId: ids,  
61 - }  
62 - return data, nil 62 + return string(bt), err
63 } 63 }
64 64
65 -func RoleMenuEdit(companyid int64, roleid int64, menuids []int64) {  
66 65
  66 +type CodeToObject func() PermissionContentObject
  67 +
  68 +var CodePermissionObject = map[string]CodeToObject{
  69 + MENU_DEPARTMENT: NewPermissionContentBase, //公司部门管理模块
  70 + MENU_POSITION: NewPermissionContentBase, //公司职务管理
  71 + MENU_RBAC: NewPermissionContentBase, //员工角色/权限设置
  72 + MENU_USER: NewPermissionContentBase, //公司员工管理
  73 + MENU_ENTERPRISE_BASIC: NewPermissionContentBase, //企业基础设置(大节点)
  74 + MENU_SYSTEM_FUNCTION: NewPermissionContentBase, //系统功能(大节点)
  75 + MENU_CONMPANY: NewPermissionContentBase, //企业信息维护
  76 + MENU_CHANCE_TEMP: NewPermissionContentBase, //机会模板管理
  77 + MENU_SORCE: NewPermissionContentBase, //评分模式
  78 + MENU_CHANCE: NewPermissionContentBase, //机会管理
67 } 79 }
@@ -70,6 +70,7 @@ token 的响应内容 @@ -70,6 +70,7 @@ token 的响应内容
70 70
71 ```json 71 ```json
72 { 72 {
  73 + "token":""
73 "code": 0, 74 "code": 0,
74 "msg": "成功", 75 "msg": "成功",
75 "data": { 76 "data": {
@@ -147,7 +148,6 @@ token 的响应内容 @@ -147,7 +148,6 @@ token 的响应内容
147 148
148 ## 公司部门管理 149 ## 公司部门管理
149 150
150 -  
151 ### 部门列表 151 ### 部门列表
152 152
153 - 请求路径:/v1/department/list 153 - 请求路径:/v1/department/list
@@ -155,43 +155,45 @@ token 的响应内容 @@ -155,43 +155,45 @@ token 的响应内容
155 - 请求 json: 155 - 请求 json:
156 156
157 ```json 157 ```json
158 -{  
159 -  
160 -} 158 +{}
161 ``` 159 ```
162 160
163 - 正常响应 json 161 - 正常响应 json
164 162
165 ```json 163 ```json
166 { 164 {
167 - "code": 0,  
168 - "msg": "成功",  
169 - "data": {  
170 - "list": [  
171 - {  
172 - "id": 1,  
173 - "company_id": 1,  
174 - "name": "部门1",  
175 - "parant_id": 0,  
176 - "manages": [{  
177 - "id":1,  
178 - "name":"主管"  
179 - }],  
180 - "member": 1  
181 - },  
182 - {  
183 - "id": 2,  
184 - "company_id": 1,  
185 - "name": "部门1-2",  
186 - "parant_id": 1,  
187 - "manages": [{  
188 - "id":1,  
189 - "name":"主管"  
190 - }],  
191 - "member": 1  
192 - }  
193 - ]  
194 - } 165 + "code": 0,
  166 + "msg": "成功",
  167 + "data": {
  168 + "lists": [
  169 + {
  170 + "id": 1,
  171 + "company_id": 1,
  172 + "name": "部门1",
  173 + "parant_id": 0,
  174 + "manages": [
  175 + {
  176 + "id": 1,
  177 + "name": "主管"
  178 + }
  179 + ],
  180 + "member": 1
  181 + },
  182 + {
  183 + "id": 2,
  184 + "company_id": 1,
  185 + "name": "部门1-2",
  186 + "parant_id": 1,
  187 + "manages": [
  188 + {
  189 + "id": 1,
  190 + "name": "主管"
  191 + }
  192 + ],
  193 + "member": 1
  194 + }
  195 + ]
  196 + }
195 } 197 }
196 ``` 198 ```
197 199
@@ -199,9 +201,6 @@ token 的响应内容 @@ -199,9 +201,6 @@ token 的响应内容
199 201
200 --- 202 ---
201 203
202 -  
203 -  
204 -  
205 ### 添加部门 204 ### 添加部门
206 205
207 - 请求路径:/v1/department/add 206 - 请求路径:/v1/department/add
@@ -289,7 +288,6 @@ token 的响应内容 @@ -289,7 +288,6 @@ token 的响应内容
289 288
290 ## 公司职位管理 289 ## 公司职位管理
291 290
292 -  
293 ### 职位列表 291 ### 职位列表
294 292
295 - 请求路径:/v1/position/list 293 - 请求路径:/v1/position/list
@@ -297,64 +295,62 @@ token 的响应内容 @@ -297,64 +295,62 @@ token 的响应内容
297 - 请求 json: 295 - 请求 json:
298 296
299 ```json 297 ```json
300 -{  
301 -  
302 -} 298 +{}
303 ``` 299 ```
304 300
305 - 响应 json 301 - 响应 json
306 302
307 ```json 303 ```json
308 { 304 {
309 - "code": 0,  
310 - "msg": "成功",  
311 - "data": [  
312 - {  
313 - "id": 1,  
314 - "name": "董事长",  
315 - "parent_id": 0  
316 - },  
317 - {  
318 - "id": 2,  
319 - "name": "总经理",  
320 - "parent_id": 1  
321 - },  
322 - {  
323 - "id": 3,  
324 - "name": "副总经理",  
325 - "parent_id": 2  
326 - },  
327 - {  
328 - "id": 4,  
329 - "name": "技术总监",  
330 - "parent_id": 2  
331 - },  
332 - {  
333 - "id": 5,  
334 - "name": "职位a",  
335 - "parent_id": 0  
336 - },  
337 - {  
338 - "id": 6,  
339 - "name": "职位b-1",  
340 - "parent_id": 9  
341 - },  
342 - {  
343 - "id": 7,  
344 - "name": "职位a-2",  
345 - "parent_id": 5  
346 - },  
347 - {  
348 - "id": 8,  
349 - "name": "职位a-1-1",  
350 - "parent_id": 6  
351 - },  
352 - {  
353 - "id": 9,  
354 - "name": "职位b-1",  
355 - "parent_id": 0  
356 - }  
357 - ] 305 + "code": 0,
  306 + "msg": "成功",
  307 + "data": [
  308 + {
  309 + "id": 1,
  310 + "name": "董事长",
  311 + "parent_id": 0
  312 + },
  313 + {
  314 + "id": 2,
  315 + "name": "总经理",
  316 + "parent_id": 1
  317 + },
  318 + {
  319 + "id": 3,
  320 + "name": "副总经理",
  321 + "parent_id": 2
  322 + },
  323 + {
  324 + "id": 4,
  325 + "name": "技术总监",
  326 + "parent_id": 2
  327 + },
  328 + {
  329 + "id": 5,
  330 + "name": "职位a",
  331 + "parent_id": 0
  332 + },
  333 + {
  334 + "id": 6,
  335 + "name": "职位b-1",
  336 + "parent_id": 9
  337 + },
  338 + {
  339 + "id": 7,
  340 + "name": "职位a-2",
  341 + "parent_id": 5
  342 + },
  343 + {
  344 + "id": 8,
  345 + "name": "职位a-1-1",
  346 + "parent_id": 6
  347 + },
  348 + {
  349 + "id": 9,
  350 + "name": "职位b-1",
  351 + "parent_id": 0
  352 + }
  353 + ]
358 } 354 }
359 ``` 355 ```
360 356
@@ -448,6 +444,7 @@ token 的响应内容 @@ -448,6 +444,7 @@ token 的响应内容
448 --- 444 ---
449 445
450 ## 公司员工角色 446 ## 公司员工角色
  447 +
451 ### 角色列表 448 ### 角色列表
452 449
453 - 请求路径:/v1/rbac/role/list 450 - 请求路径:/v1/rbac/role/list
@@ -455,113 +452,110 @@ token 的响应内容 @@ -455,113 +452,110 @@ token 的响应内容
455 - 请求 json: 452 - 请求 json:
456 453
457 ```json 454 ```json
458 -{  
459 -  
460 -} 455 +{}
461 ``` 456 ```
462 457
463 - 响应 json 458 - 响应 json
464 459
465 ```json 460 ```json
466 -  
467 { 461 {
468 - "code": 0,  
469 - "msg": "成功",  
470 - "data": {  
471 - "list": [  
472 - {  
473 - "id": 1,  
474 - "company_id": 1,  
475 - "name": "部门1",  
476 - "parant_id": 0,  
477 - "manages": [],  
478 - "members": [  
479 - {  
480 - "id": 1,  
481 - "name": "Jennifer Clark"  
482 - }  
483 - ],  
484 - "member": 1  
485 - },  
486 - {  
487 - "id": 2,  
488 - "company_id": 1,  
489 - "name": "部门1-2",  
490 - "parant_id": 1,  
491 - "manages": [],  
492 - "members": [],  
493 - "member": 1  
494 - },  
495 - {  
496 - "id": 3,  
497 - "company_id": 1,  
498 - "name": "部门1-2-3",  
499 - "parant_id": 2,  
500 - "manages": [],  
501 - "members": [],  
502 - "member": 0  
503 - },  
504 - {  
505 - "id": 4,  
506 - "company_id": 1,  
507 - "name": "部门1-2-4",  
508 - "parant_id": 2,  
509 - "manages": [],  
510 - "members": [],  
511 - "member": 0  
512 - },  
513 - {  
514 - "id": 5,  
515 - "company_id": 1,  
516 - "name": "部门1-2-5",  
517 - "parant_id": 3,  
518 - "manages": [],  
519 - "members": [],  
520 - "member": 0  
521 - },  
522 - {  
523 - "id": 7,  
524 - "company_id": 1,  
525 - "name": "部门1-2-5-7",  
526 - "parant_id": 5,  
527 - "manages": [],  
528 - "members": [],  
529 - "member": 0  
530 - },  
531 - {  
532 - "id": 10,  
533 - "company_id": 1,  
534 - "name": "部门2",  
535 - "parant_id": 0,  
536 - "manages": [],  
537 - "members": [],  
538 - "member": 0  
539 - },  
540 - {  
541 - "id": 26,  
542 - "company_id": 1,  
543 - "name": "部门名称1",  
544 - "parant_id": 1,  
545 - "manages": [  
546 - {  
547 - "id": 1,  
548 - "name": "Jennifer Clark"  
549 - }  
550 - ],  
551 - "members": [],  
552 - "member": 0  
553 - },  
554 - {  
555 - "id": 27,  
556 - "company_id": 1,  
557 - "name": "部门名称1",  
558 - "parant_id": 1,  
559 - "manages": [],  
560 - "members": [],  
561 - "member": 0  
562 - }  
563 - ]  
564 - } 462 + "code": 0,
  463 + "msg": "成功",
  464 + "data": {
  465 + "list": [
  466 + {
  467 + "id": 1,
  468 + "company_id": 1,
  469 + "name": "部门1",
  470 + "parant_id": 0,
  471 + "manages": [],
  472 + "members": [
  473 + {
  474 + "id": 1,
  475 + "name": "Jennifer Clark"
  476 + }
  477 + ],
  478 + "member": 1
  479 + },
  480 + {
  481 + "id": 2,
  482 + "company_id": 1,
  483 + "name": "部门1-2",
  484 + "parant_id": 1,
  485 + "manages": [],
  486 + "members": [],
  487 + "member": 1
  488 + },
  489 + {
  490 + "id": 3,
  491 + "company_id": 1,
  492 + "name": "部门1-2-3",
  493 + "parant_id": 2,
  494 + "manages": [],
  495 + "members": [],
  496 + "member": 0
  497 + },
  498 + {
  499 + "id": 4,
  500 + "company_id": 1,
  501 + "name": "部门1-2-4",
  502 + "parant_id": 2,
  503 + "manages": [],
  504 + "members": [],
  505 + "member": 0
  506 + },
  507 + {
  508 + "id": 5,
  509 + "company_id": 1,
  510 + "name": "部门1-2-5",
  511 + "parant_id": 3,
  512 + "manages": [],
  513 + "members": [],
  514 + "member": 0
  515 + },
  516 + {
  517 + "id": 7,
  518 + "company_id": 1,
  519 + "name": "部门1-2-5-7",
  520 + "parant_id": 5,
  521 + "manages": [],
  522 + "members": [],
  523 + "member": 0
  524 + },
  525 + {
  526 + "id": 10,
  527 + "company_id": 1,
  528 + "name": "部门2",
  529 + "parant_id": 0,
  530 + "manages": [],
  531 + "members": [],
  532 + "member": 0
  533 + },
  534 + {
  535 + "id": 26,
  536 + "company_id": 1,
  537 + "name": "部门名称1",
  538 + "parant_id": 1,
  539 + "manages": [
  540 + {
  541 + "id": 1,
  542 + "name": "Jennifer Clark"
  543 + }
  544 + ],
  545 + "members": [],
  546 + "member": 0
  547 + },
  548 + {
  549 + "id": 27,
  550 + "company_id": 1,
  551 + "name": "部门名称1",
  552 + "parant_id": 1,
  553 + "manages": [],
  554 + "members": [],
  555 + "member": 0
  556 + }
  557 + ]
  558 + }
565 } 559 }
566 ``` 560 ```
567 561
@@ -569,9 +563,6 @@ token 的响应内容 @@ -569,9 +563,6 @@ token 的响应内容
569 563
570 --- 564 ---
571 565
572 -  
573 -  
574 -  
575 ### 添加角色 566 ### 添加角色
576 567
577 - 请求路径:/v1/rbac/role/add 568 - 请求路径:/v1/rbac/role/add