---
title: "OpenJWeb快速开发平台组织结构继承权限的实现"
author: "cjc"
date: "2009-03-11T11:05:00Z"
tags: []
slug: "openjweb"
draft: false
lastmod: "2009-03-11T11:05:00Z"
id: 446863
url: "https://cjc.iteye.com/blog/446863"
---

OpenJWeb快速开发平台中实现了上级组织结构下的人员可获得下级组织结构的权限,sql:

create or replace view v\_user\_auth as  
\--select distinct user\_id,login\_id,comm\_code,auth\_name,auth\_resource from (  
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 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 from comm\_org\_emp\_rel a,comm\_dept b,comm\_user c where b.row\_id = a.org\_id and c.dept\_id=b.pk\_id) a,  
(  
select a.dept\_id,c.auth\_id,b.tree\_code,c.comm\_code ,c.auth\_name,c.auth\_resource 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 ||'%' ;

例如下级组织结构001001具有某功能的权限,则上级组织结构001则可获得此功能的权限,如果用户A属于001部门,则

此用户可获得分配给001001组织的权限.使用spring security框架可以从这个视图中获取权限记录.