---
title: "OpenJWeb快速开发平台组织结构权限继承变更说明"
author: "cjc"
date: "2009-03-28T09:10:00Z"
tags: []
slug: "openjweb"
draft: false
lastmod: "2009-03-28T09:10:00Z"
id: 446854
url: "https://cjc.iteye.com/blog/446854"
---

原来的组织结构权限继承设置为,当下级部门拥有某权限时,则上级部门拥有这个权限.但感觉不太合理,因为一个部门角色众多,例如给下级部门的系统管理员一个admin权限,上级部门的人员不应该所有角色都得到这个权限,这样做也是很危险的.

现在改为这种方式:

在部门下建立角色树,角色树具有权限继承关系,即上级角色可以获得下级的角色权限,这样比较合理,部门不能获得部门下面的角色的权限,但部门节点的权限可以被本部门全体人员共用,只是部门权限不具有继承性.

与角色类似,如果岗位,职位权限要实现继承的话,与角色的实现方式相同,下面是角色权限继承的sql语句:

create or replace view v\_user\_auth as  
select a.user\_id,a.login\_id,b.comm\_code,b.auth\_name,b.auth\_resource from  
comm\_user a,comm\_auth b ,comm\_user\_auth c  
where c.user\_id = a.user\_id  
and c.auth\_id = b.auth\_id  
union  
select a.user\_id,a.login\_id,b.comm\_code,b.auth\_name,b.auth\_resource from  
comm\_user a,comm\_auth b , comm\_user\_role d,comm\_role\_auth e  
where a.user\_id = d.user\_id  
and d.role\_id = e.role\_id  
and e.auth\_id = b.auth\_id

union

select a.user\_id,a.login\_id,b.comm\_code,b.auth\_name,b.auth\_resource from (  
select a.user\_id,a.login\_id,b.row\_id row\_id,b.tree\_code,b.org\_type from comm\_user a,comm\_dept b where a.dept\_id=b.pk\_id union  
select a.user\_id,c.login\_id,a.org\_id row\_id,b.tree\_code,b.org\_type from comm\_org\_emp\_rel a,comm\_dept b,comm\_user c where b.row\_id = a.org\_id  
and c.user\_id=a.user\_id) a,  
(  
select a.dept\_id,c.auth\_id,b.tree\_code,c.comm\_code ,c.auth\_name,c.auth\_resource,b.org\_type,b.row\_id from comm\_dept\_auth a,comm\_dept b,comm\_auth c where a.dept\_id =b.row\_id  
and a.auth\_id=c.auth\_id) b  
where ((b.tree\_code like a.tree\_code ||'%' and b.org\_type in ('ROLES')) --如果是角色类型的组织结构节点，则继承  
and a.org\_type in ('ROLES'))  
or b.row\_id = a.row\_id --行政部门关联