权限管理(数据库部分)
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SysFun]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[SysFun]( [Node_id] [int] IDENTITY(1,1) NOT NULL, [DisplayName] [varchar](50) NULL, [NameSpace] [varchar](50) NULL, [FullFrmName] [varchar](50) NULL, [ParentNode_id] [int] NULL, CONSTRAINT [PK_SysFun] PRIMARY KEY CLUSTERED ( [Node_id] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RoleInfo]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[RoleInfo]( [Role_id] [int] IDENTITY(1,1) NOT NULL, [RoleName] [varchar](50) NULL, [RoleDes] [varchar](200) NULL, CONSTRAINT [PK_RoleInfo] PRIMARY KEY CLUSTERED ( [Role_id] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RoleRight]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[RoleRight]( [RoleRight_id] [int] IDENTITY(1,1) NOT NULL, [Role_id] [int] NULL, [Node_id] [int] NULL, CONSTRAINT [PK_RoleRight] PRIMARY KEY CLUSTERED ( [RoleRight_id] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserInfo]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[UserInfo]( [user_id] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](50) NULL, [WorkerNO] [varchar](50) NULL, [telephone] [varchar](50) NULL, [Email] [varchar](50) NULL, [Role_id] [int] NULL, [Pwd] [varchar](50) NULL, CONSTRAINT [PK_UserInfo] PRIMARY KEY CLUSTERED ( [user_id] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RoleRight_RoleInfo]') AND parent_object_id = OBJECT_ID(N'[dbo].[RoleRight]')) ALTER TABLE [dbo].[RoleRight] WITH CHECK ADD CONSTRAINT [FK_RoleRight_RoleInfo] FOREIGN KEY([Role_id]) REFERENCES [dbo].[RoleInfo] ([Role_id]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RoleRight_SysFun]') AND parent_object_id = OBJECT_ID(N'[dbo].[RoleRight]')) ALTER TABLE [dbo].[RoleRight] WITH CHECK ADD CONSTRAINT [FK_RoleRight_SysFun] FOREIGN KEY([Node_id]) REFERENCES [dbo].[SysFun] ([Node_id]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserInfo_RoleInfo]') AND parent_object_id = OBJECT_ID(N'[dbo].[UserInfo]')) ALTER TABLE [dbo].[UserInfo] WITH CHECK ADD CONSTRAINT [FK_UserInfo_RoleInfo] FOREIGN KEY([Role_id]) REFERENCES [dbo].[RoleInfo] ([Role_id])