去除权限中的租户

This commit is contained in:
XM-GO
2023-05-27 12:48:42 +08:00
parent 2e6cb34922
commit 573f73cc91
6 changed files with 36 additions and 33 deletions

View File

@@ -8,7 +8,6 @@ import (
entity "pandax/apps/system/entity"
services "pandax/apps/system/services"
"pandax/pkg/global"
"strconv"
)
type SystemApiApi struct {
@@ -61,7 +60,6 @@ func (s *SystemApiApi) GetAllApis(rc *restfulx.ReqCtx) {
func (s *SystemApiApi) GetPolicyPathByRoleId(rc *restfulx.ReqCtx) {
roleKey := rc.Request.QueryParameter("roleKey")
tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId))
ca := casbin.CasbinS{ModelPath: global.Conf.Casbin.ModelPath}
rc.ResData = ca.GetPolicyPathByRoleId(tenantId, roleKey)
rc.ResData = ca.GetPolicyPathByRoleId(roleKey)
}

View File

@@ -11,7 +11,6 @@ import (
entity "pandax/apps/system/entity"
services "pandax/apps/system/services"
"pandax/pkg/global"
"strconv"
)
type RoleApi struct {
@@ -63,9 +62,8 @@ func (r *RoleApi) InsertRole(rc *restfulx.ReqCtx) {
role.RoleId = insert.RoleId
r.RoleMenuApp.Insert(insert.RoleId, role.MenuIds)
//添加权限
tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId))
ca := casbin.CasbinS{ModelPath: global.Conf.Casbin.ModelPath}
ca.UpdateCasbin(tenantId, role.RoleKey, role.ApiIds)
ca.UpdateCasbin(role.RoleKey, role.ApiIds)
}
// UpdateRole 修改用户角色
@@ -80,9 +78,8 @@ func (r *RoleApi) UpdateRole(rc *restfulx.ReqCtx) {
// 添加角色菜单绑定
r.RoleMenuApp.Insert(role.RoleId, role.MenuIds)
//修改api权限
tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId))
ca := casbin.CasbinS{ModelPath: global.Conf.Casbin.ModelPath}
ca.UpdateCasbin(tenantId, role.RoleKey, role.ApiIds)
ca.UpdateCasbin(role.RoleKey, role.ApiIds)
}
// UpdateRoleStatus 修改用户角色状态