SQL实例代码:取栏目树,过滤用户权限和无效栏目._SQL SERVER数据库_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

SQL实例代码:取栏目树,过滤用户权限和无效栏目.

作者:黑客防线网安SQL维护基地 来源:黑客防线网安SQL维护基地 浏览次数:0

本篇关键词:栏目权限无效用户
黑客防线网安网讯:       文由网友whl供稿,特此感谢!/**  * Desc: 取栏目树 ,过滤用户权限和无效栏目  * Author: WHL  * Date: 2009-05-31 15:17  */ /** 1. 取某用户有权限(np_cms_column_security表有记...

       文由网友whl供稿特此感谢!
/**
  * Desc: 取栏目树 ,过滤用户权限和无效栏目
  * Author: WHL
  * Date: 2009-05-31 15:17
  */

 
/** 1. 取某用户有权限(np_cms_column_security表有记录且t.action_1 = ‘1′)的栏目的树 **/
01.createorreplaceviewV_NP_CTREE_BSas
02.selectB.*from(
03.selectA.*, lag(A.column_id) over(partitionbyA.column_idorderby0 ) RK
04.  from(select/*+choose */
05.         t.*
06.          fromnp_cms_column t
07.         wheret.is_active ='1'
08.        connectbypriort.column_id = t.parent_id
09.         startwitht.column_idin(selectt.column_id
10.                                      fromnp_cms_column_security t
11.                                     wheret.subject_id ='mazj'
12.                                          /*这里添加角色过滤*/
13.                                       andt.action_1 ='1'))A) B
14. wherenotexists
15. (select0
16.          from(selectdistinctd.column_id
17.                  fromnp_cms_column d
18.                connectbypriord.column_id = d.parent_id
19.                 startwithd.column_idin
20.                    (selectt.column_id
21.                       fromnp_cms_column_security t
22.                      wheret.subject_id ='mazj'
23.                           /* 这里添加角色过滤*/
24.                        andt.action_1 ='0'
25.                           /* 排除有权限树下的非授权ID,既 Action_1=0的*/
26.                        andexists
27.                      (select0
28.                               from(selectdistinctd.column_id
29.                                       fromnp_cms_column d
30.                                     connectbypriord.column_id =
31.                                                 d.parent_id
32.                                      startwithd.column_idin
33.                                                 (selectt.column_id
34.                                                    fromnp_cms_column_security t
35.                                                   wheret.subject_id =
36.                                                         'mazj'
37.                                                        /*这里添加角色过滤*/
38.                                                     andt.action_1 ='1')) C1
39.                              whereC1.column_id = t.column_id))
40.                        andd.is_active ='1') C
41.         whereC.column_id = B.column_idandB.RKisnull)andB.RKisnull
42.unionall
43.selectc.*, 0 RKfromnp_cms_column cwherec.parent_id = 0;
————————————————————————
/** 2.得到栏目的虚拟父亲ID(考虑到把断层的节点接起来)**/

01.createorreplaceviewV_NP_CTREE_PAas
02.selectB.*,
03.       (caseB.column_id
04.         when1then0elsenvl(B.father, 1)end) VFA
05.  from(selectv.*,
06.               (selectvv.column_id
07.                  fromV_NP_CTREE_BS vv
08.                 wherevv.column_id = v.parent_id) FATHER
09.          fromV_NP_CTREE_BS v) B;
————————————————————————
/** 3. 取出门户需要的栏目树 **/

1.--create or replace view V_NP_CTREE_RS as
2.select
3. D.*, LPAD(' ', 2 *level- 1) || SYS_CONNECT_BY_PATH(D.COLUMN_NAME,'/') "Path"
4.  from(selectc.*
5.          fromV_NP_CTREE_PA c
6.         orderbyc.VFA, c.disorderdesc, c.column_iddesc) D
7.connectbypriorD.column_id = D.VFA
8. startwithD.column_id = 1;

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-10908-1.html
网站维护教程更新时间:2012-03-21 03:12:15  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer