改进版本的精确数据权限定义和实现
来源:互联网 发布:网页模板源码下载 编辑:程序博客网 时间:2024/06/10 08:24
由于工程实现上的某些小问题,为了达到方便实现如图效果,对数据结构做了一点点的调整。
新的数据结构如下图:
第一个图片的数据源视图:
IF EXISTS (SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'RoleDataPermit') AND OBJECTPROPERTY(id, N'ISVIEW') = 1)DROP VIEW RoleDataPermitGO/*****视图:查询所有角色的数据权限*****/CREATE VIEW RoleDataPermitASwith List as (select distinct G.ID as DataId, null as ParentId, PM.RoleId, 0 as Action, G.Name as 模块, null as 读写权限from SYS_ModuleGroup Gjoin SYS_Module M on M.ModuleGroupId = G.IDjoin SYS_RolePerm_Module PM on PM.ModuleId = M.IDleft join SYS_RolePerm_Data PD on PD.PermId = PM.IDwhere PM.Permission >= 0 or PD.ID is not nullunion allselect M.ID as DataId, case when M.ModuleGroupId is null then M.ParentId else M.ModuleGroupId end as ParentId, PM.RoleId, 1 as Action, M.ApplicationName as 模块, null as 读写权限from SYS_Module Mjoin SYS_RolePerm_Module PM on PM.ModuleId = M.IDwhere PM.Permission >= 0union allselect PM.ID as DataId, PM.ModuleId as ParentId, PM.RoleId, 2 as Action, '无归属数据' as 模块, case when PM.Permission = 0 then '只读' else '读写' end as 读写权限from SYS_RolePerm_Module PMwhere PM.Permission >= 0union allselect PD.ID as DataId, M.ModuleId as ParentId, M.RoleId, PD.Mode + 3 as Action, case PD.Mode when 0 then '仅本人' when 1 then '仅本部门' when 2 then '本部门所有' when 3 then '本机构所有' when 4 then '根机构所有' else '自定义' end as 模块, case when PD.Permission = 0 and PD.Mode < 5 then '只读' when PD.Permission = 1 and PD.Mode < 5 then '读写' else null end as 读写权限from SYS_RolePerm_Data PDjoin SYS_RolePerm_Module M on M.ID = PD.PermIdunion allselect PC.ID as DataId, PC.PermDataId as ParentId, PM.RoleId, 9 as Action, O.FullName as 模块, case when PC.Permission = 0 then '只读' else '读写' end as 读写权限from SYS_RolePerm_Module PMjoin SYS_RolePerm_Data PD on PD.PermId = PM.ID and PD.Mode = 5join SYS_RolePerm_Custom PC on PC.PermDataId = PD.ID and PC.OrgId is not nulljoin SYS_Organization O on O.ID = PC.OrgIdunion allselect PC.ID as DataId, PC.PermDataId as ParentId, PM.RoleId, 10 as Action, U.Name + '(' + U.LoginName + ')' as 模块, case when PC.Permission = 0 then '只读' else '读写' end as 读写权限from SYS_RolePerm_Module PMjoin SYS_RolePerm_Data PD on PD.PermId = PM.ID and PD.Mode = 5join SYS_RolePerm_Custom PC on PC.PermDataId = PD.ID and PC.UserId is not nulljoin SYS_User U on U.ID = PC.UserId)select newid() as ID, * from ListGO
2 0
- 改进版本的精确数据权限定义和实现
- 高精度数据权限定义和实现
- NSLog的宏定义改进版本
- 功能权限和数据权限管理的实现
- Android 2.2版本的改进和提升
- 数据权限的实现
- 改进版本的五子棋
- 浅谈数据权限的实现方法和作用机制
- 改进版本的压缩和解压的shell脚本
- 定义者权限和调用者权限的区别
- 精确延时的实现
- 定义的数据和函数
- 改进版本的快速排序
- 改进erlang版本的protobuf
- java实现double的精确计算和四舍五入
- 协议的定义和实现
- 【复数】的定义和实现
- 【有理数】的定义和实现
- Divide Two Integers
- ubuntukylin14.04下github 常用操作
- UVA10285(DP)
- Android获取手机配置信息
- jquery UI学习笔记-知问前端之自动补全工具UI
- 改进版本的精确数据权限定义和实现
- 热爱编程,热爱生活,快速适应IT新技术
- HDU 4169 Wealthy Family
- 概率dp HDU 3853
- 《编写高质量代码:改善Java程序的151个建议》 建议10
- binary tree zigzag level order traversal leetcode c++
- oracle常见查询转换笔记
- CXF+Maven+Eclipse开发基于jax-rs规范的WebService
- C语言——为什么调用函数不能在主函数之后