資源簡介
一、表的說明
1具權限項掩碼表:包括字段 ID,權限類別,權限明細,權限碼,下屬權限碼 等
權限碼 用二進制數為標志 如1 2 4 8 16等
下屬權限碼 是該權限所包含的統一權限類別的其他的權限 用二進制數表示
權限明細與權限碼保持一致 但是用字符串表示 如edit delect 等
權限類別是某一功能的表示 如client 等
2 角色表:包括字段,ID,角色名,角色的描述 等
3權限表:ID,權限類別,權限碼總和
權限類別 跟權限表的權限類別關聯
權限碼總和 是指同一權限類別的權限總和(用二進制表示權限碼的意義就是能夠通過權限碼的總和可以分出具體的那些權限)
4 用戶表:包括三個或以上字段,ID,用戶名,對該用戶的描述,其它(如地址、電話等信息);
5用戶部門表:包含 ID,部門編號,部門名稱 等
6部門-角色-用戶表 ID,部門ID,角色ID,用戶ID
用來解決一個用戶多部門多角色的問題 同一個職員在一個部門也可以擁有多個角色
如 用戶1-部門1-角色1
用戶1-部門2-角色1
用戶1-部門3-角色2
等等
二、程序解決方法
1具權限項掩碼表
GO
if exists (select 1
from sysobjects
where id = object_id('t_Object')
and type = 'U')
drop table t_Object
GO
create table t_Object(
FObjectno varchar(40) not null,
FObjectgroup varchar(40) not null,
FObjectorder int not null,
FSysID varchar(40) not null default ('system'),
F0bjectdetail nvarchar(40) not null default (''),
FAccessmask bigint not null default ((0)),
FAccessinclude bigint not null default ((0)),
FServicetype nvarchar(20) not null default (''),
FObjectid bigint not null,
constraint [PK_t_Object] primary key clustered
(
FSysID asc,
Fobjectid asc
)with (ignore_dup_key = off) on [primary]
) on [primary]
GO
2 角色表
GO
if exists (select 1
from sysobjects
where id = object_id('t_Role')
and type = 'U')
drop table t_Role
GO
create table t_Role(
FRoleID bigint not null,
FSysID nvarchar(40) not null,
FRoleName nvarchar(50) not null,
FRoleType nvarchar(40) not null,
FRoleNO nvarchar(40) null,
FDesc nvarchar(40) null
constraint [PK_t_Role] primary key clustered
(
FRoleID ASC,
FSysID ASC
)with (ignore_dup_key = off) on [primary]
) on [primary]
GO
3權限表
GO
if exists (select 1
from sysobjects
where id = object_id('t_RoleRelation')
and type = 'U')
drop table t_RoleRelation
GO
create table t_RoleRelation(
FRoleID bigint not null,
FSysID nvarchar(40) not null,
FObjectNO nvarchar(40) not null,
FAccessMask bigint null
constraint [PK_t_RoleRelation] primary key clustered
(
FRoleID ASC,
FSysID ASC,
FObjectNO ASC
)with (ignore_dup_key = off) on [primary]
) on [primary]
GO
4 用戶表
GO
create table t_Employee(
FEmpID bigint not null,
FEmpNO nvarchar(50) not null,
FEmpName nvarchar(50) not null,
FEmpType smallint not null,
FSysID varchar(40) not null,
FDeptID bigint null DEFAULT ((-1)),
FSex nchar(1) null DEFAULT (''),
FBirthday datetime null,
FMobile nvarchar(50) null,
FEmail nvarchar(100) null,
FAllowSMS bit not null DEFAULT ('True'),
constraint [PK_t_Employee] primary key clustered
(
FEmpID ASC,
FSysID ASC
)with (ignore_dup_key = off) on [primary]
) on [primary]
GO
5用戶部門表
GO
create table t_Department (
FDeptID bigint not null,
FDeptNo nvarchar(50) not null,
FDeptName nvarchar(50) not null,
FDesc nvarchar(255) null,
FSysID varchar(40) not null,
constraint [PK_t_Department] primary key clustered
(
FDeptID ASC,
FSysID ASC
)with (ignore_dup_key = off) on [primary]
) on [primary]
GO
6部門-角色-用戶表
復制代碼
GO
if exists (select 1
from sysobjects
where id = object_id('t_RoleAccess')
and type = 'U')
drop table t_RoleAccess
GO
create table t_RoleAccess(
FRoleAccessID bigint not null,
FCoid nvarchar(40) not null,
FRoleID bigint not null,
FBuID bigint not null,
FDeptID bigint not null,
FEmpID bigint not null,
FHidTag smallint null,
FDelTag smallint null,
FState smallint null
constraint [PK_t_RoleAccess] primary key clustered
(
FRoleAccessID ASC,
FCoid ASC
)with (ignore_dup_key = off) on [primary]
) on [primary]
GO
代碼片段和文件信息
評論
共有 條評論