码迷,mamicode.com
首页 > 其他好文 > 详细

最简单的权限管理

时间:2016-05-18 00:23:02      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 1 USE [AirCRM]
 2 GO
 3 
 4 /****** Object:  Table [dbo].[CRM_Department]    Script Date: 2015/4/9 16:36:09 ******/
 5 SET ANSI_NULLS ON
 6 GO
 7 
 8 SET QUOTED_IDENTIFIER ON
 9 GO
10 
11 CREATE TABLE [dbo].[CRM_Department](
12     [ID] [int] IDENTITY(1,1) NOT NULL,
13     [DepartmentGUID] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
14     [DepartmentName] [nvarchar](100) NOT NULL,
15     [DepartmentAliasName] [nvarchar](50) NULL,
16     [DepartmentStatus] [bit] NOT NULL,
17     [DepartmentParentGUID] [uniqueidentifier] NULL,
18     [DepartmentDescription] [nvarchar](250) NULL,
19     [DepartmentManagerGUID] [uniqueidentifier] NULL,
20     [DepartmentTypeGUID] [uniqueidentifier] NULL,
21     [DepartmetnOrganizationGUID] [uniqueidentifier] NULL,
22  CONSTRAINT [PK_CRM_Department] PRIMARY KEY CLUSTERED 
23 (
24     [DepartmentGUID] ASC
25 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
26 ) ON [PRIMARY]
27 
28 GO
29 
30 ALTER TABLE [dbo].[CRM_Department] ADD  CONSTRAINT [DF_CRM_Department_DepartmentGUID]  DEFAULT (newid()) FOR [DepartmentGUID]
31 GO
32 
33 ALTER TABLE [dbo].[CRM_Department]  WITH CHECK ADD  CONSTRAINT [FK_CRM_Department_CRM_Department] FOREIGN KEY([DepartmentParentGUID])
34 REFERENCES [dbo].[CRM_Department] ([DepartmentGUID])
35 GO
36 
37 ALTER TABLE [dbo].[CRM_Department] CHECK CONSTRAINT [FK_CRM_Department_CRM_Department]
38 GO
39 
40 ALTER TABLE [dbo].[CRM_Department]  WITH CHECK ADD  CONSTRAINT [FK_CRM_Department_CRM_Organization] FOREIGN KEY([DepartmetnOrganizationGUID])
41 REFERENCES [dbo].[CRM_Organization] ([OrganizationGUID])
42 GO
43 
44 ALTER TABLE [dbo].[CRM_Department] CHECK CONSTRAINT [FK_CRM_Department_CRM_Organization]
45 GO
46 
47 ALTER TABLE [dbo].[CRM_Department]  WITH CHECK ADD  CONSTRAINT [FK_CRM_Department_CRM_Person] FOREIGN KEY([DepartmentManagerGUID])
48 REFERENCES [dbo].[CRM_Person] ([PersonGUID])
49 GO
50 
51 ALTER TABLE [dbo].[CRM_Department] CHECK CONSTRAINT [FK_CRM_Department_CRM_Person]
52 GO
53 
54 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构-部门编号 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NID
55 GO
56 
57 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构-部门GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmentGUID
58 GO
59 
60 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构-部门名称 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmentName
61 GO
62 
63 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构-部门别名 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmentAliasName
64 GO
65 
66 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构-状态(0:启用,1:禁用) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmentStatus
67 GO
68 
69 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N上一级部门GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmentParentGUID
70 GO
71 
72 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构-部门说明 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmentDescription
73 GO
74 
75 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N部门管理者GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmentManagerGUID
76 GO
77 
78 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构-部门类型GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmentTypeGUID
79 GO
80 
81 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N部门所属组织机构GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Department, @level2type=NCOLUMN,@level2name=NDepartmetnOrganizationGUID
82 GO
 1 USE [AirCRM]
 2 GO
 3 
 4 /****** Object:  Table [dbo].[CRM_Menu]    Script Date: 2015/4/9 17:04:24 ******/
 5 SET ANSI_NULLS ON
 6 GO
 7 
 8 SET QUOTED_IDENTIFIER ON
 9 GO
10 
11 CREATE TABLE [dbo].[CRM_Menu](
12     [ID] [int] IDENTITY(1,1) NOT NULL,
13     [MenuGUID] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
14     [MenuName] [nvarchar](50) NOT NULL,
15     [MenuItemCaption] [nvarchar](50) NOT NULL,
16     [MenuItemCaptionEnglish] [nvarchar](50) NULL,
17     [IsParentMenuItem] [bit] NOT NULL,
18     [MenuItemICON] [nvarchar](50) NULL,
19     [MenuItemStatus] [bit] NULL,
20     [MenuItemUrl] [nvarchar](250) NULL,
21     [MenuItemType] [nvarchar](150) NULL,
22     [MenuParentGUID] [uniqueidentifier] NULL,
23  CONSTRAINT [PK_CRM_Menu] PRIMARY KEY CLUSTERED 
24 (
25     [MenuGUID] ASC
26 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
27 ) ON [PRIMARY]
28 
29 GO
30 
31 ALTER TABLE [dbo].[CRM_Menu] ADD  CONSTRAINT [DF_CRM_Menu_MenuGUID]  DEFAULT (newid()) FOR [MenuGUID]
32 GO
33 
34 ALTER TABLE [dbo].[CRM_Menu]  WITH CHECK ADD  CONSTRAINT [FK_CRM_Menu_CRM_Menu] FOREIGN KEY([MenuParentGUID])
35 REFERENCES [dbo].[CRM_Menu] ([MenuGUID])
36 GO
37 
38 ALTER TABLE [dbo].[CRM_Menu] CHECK CONSTRAINT [FK_CRM_Menu_CRM_Menu]
39 GO
40 
41 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuGUID
42 GO
43 
44 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单名称 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuName
45 GO
46 
47 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单标题 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuItemCaption
48 GO
49 
50 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单项英文标题 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuItemCaptionEnglish
51 GO
52 
53 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N是否为父级菜单 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NIsParentMenuItem
54 GO
55 
56 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单图标 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuItemICON
57 GO
58 
59 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单项状态(0:启用,1:禁用) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuItemStatus
60 GO
61 
62 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单项URL , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuItemUrl
63 GO
64 
65 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单项类型 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuItemType
66 GO
67 
68 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N菜单项父菜单GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Menu, @level2type=NCOLUMN,@level2name=NMenuParentGUID
69 GO
 1 USE [AirCRM]
 2 GO
 3 
 4 /****** Object:  Table [dbo].[CRM_Organization]    Script Date: 2015/4/9 16:35:54 ******/
 5 SET ANSI_NULLS ON
 6 GO
 7 
 8 SET QUOTED_IDENTIFIER ON
 9 GO
10 
11 CREATE TABLE [dbo].[CRM_Organization](
12     [ID] [int] IDENTITY(1,1) NOT NULL,
13     [OrganizationGUID] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
14     [OrganizationName] [nvarchar](250) NOT NULL,
15     [OrganizationAliasName] [nvarchar](50) NULL,
16     [OrganizationCode] [nvarchar](50) NULL,
17     [OrganizationAddress] [nvarchar](250) NULL,
18     [OrganizationStatus] [bit] NOT NULL,
19     [OrganizationTypeGUID] [uniqueidentifier] NULL,
20     [OrganizationDescription] [nvarchar](250) NULL,
21     [OrganizationParentGUID] [uniqueidentifier] NULL,
22  CONSTRAINT [PK_CRM_Organization] PRIMARY KEY CLUSTERED 
23 (
24     [OrganizationGUID] ASC
25 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
26 ) ON [PRIMARY]
27 
28 GO
29 
30 ALTER TABLE [dbo].[CRM_Organization] ADD  CONSTRAINT [DF_CRM_Organization_OrganizationGUID]  DEFAULT (newid()) FOR [OrganizationGUID]
31 GO
32 
33 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构编号 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NID
34 GO
35 
36 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationGUID
37 GO
38 
39 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构名称 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationName
40 GO
41 
42 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构别名 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationAliasName
43 GO
44 
45 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构代码 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationCode
46 GO
47 
48 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构地址 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationAddress
49 GO
50 
51 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构状态(0:启用,1:禁用) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationStatus
52 GO
53 
54 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构类型GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationTypeGUID
55 GO
56 
57 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N组织机构说明 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationDescription
58 GO
59 
60 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N上一级组织机构GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Organization, @level2type=NCOLUMN,@level2name=NOrganizationParentGUID
61 GO
 1 USE [AirCRM]
 2 GO
 3 
 4 /****** Object:  Table [dbo].[CRM_Permissons]    Script Date: 2015/4/9 17:04:08 ******/
 5 SET ANSI_NULLS ON
 6 GO
 7 
 8 SET QUOTED_IDENTIFIER ON
 9 GO
10 
11 CREATE TABLE [dbo].[CRM_Permissons](
12     [ID] [int] IDENTITY(1,1) NOT NULL,
13     [PermissionGUID] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
14     [PermissionName] [nvarchar](50) NOT NULL,
15     [PermissionDescription] [nvarchar](250) NULL,
16     [PermissionStatus] [bit] NOT NULL,
17     [PermissionOwinerGUID] [nvarchar](max) NULL,
18     [PermissionIsExpire] [bit] NULL,
19     [PermissionValidDate] [date] NULL,
20     [PermissionMenuListGUID] [nvarchar](250) NULL,
21  CONSTRAINT [PK_CRM_Permissons] PRIMARY KEY CLUSTERED 
22 (
23     [PermissionGUID] ASC
24 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
25 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
26 
27 GO
28 
29 ALTER TABLE [dbo].[CRM_Permissons] ADD  CONSTRAINT [DF_CRM_Permissons_PermissionGUID]  DEFAULT (newid()) FOR [PermissionGUID]
30 GO
31 
32 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限编号 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NID
33 GO
34 
35 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NPermissionGUID
36 GO
37 
38 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限名称 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NPermissionName
39 GO
40 
41 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限说明 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NPermissionDescription
42 GO
43 
44 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限状态(0:启用,1:禁用,2:锁定,3:过期) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NPermissionStatus
45 GO
46 
47 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限拥有者GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NPermissionOwinerGUID
48 GO
49 
50 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限是否已过期 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NPermissionIsExpire
51 GO
52 
53 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限有效日期 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NPermissionValidDate
54 GO
55 
56 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N权限对应的菜单GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Permissons, @level2type=NCOLUMN,@level2name=NPermissionMenuListGUID
57 GO
 1 USE [AirCRM]
 2 GO
 3 
 4 /****** Object:  Table [dbo].[CRM_Role]    Script Date: 2015/4/9 16:35:01 ******/
 5 SET ANSI_NULLS ON
 6 GO
 7 
 8 SET QUOTED_IDENTIFIER ON
 9 GO
10 
11 CREATE TABLE [dbo].[CRM_Role](
12     [ID] [int] IDENTITY(1,1) NOT NULL,
13     [RoleGUID] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
14     [RoleName] [nvarchar](50) NOT NULL,
15     [RoleAliasName] [nvarchar](50) NULL,
16     [RoleDescription] [nvarchar](250) NULL,
17     [RoleLevel] [int] NOT NULL,
18     [RoleParentGUID] [uniqueidentifier] NOT NULL,
19     [RolePermissionListGUID] [nvarchar](250) NULL,
20  CONSTRAINT [PK_CRM_Role] PRIMARY KEY CLUSTERED 
21 (
22     [RoleGUID] ASC
23 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
24 ) ON [PRIMARY]
25 
26 GO
27 
28 ALTER TABLE [dbo].[CRM_Role] ADD  CONSTRAINT [DF_CRM_Role_RoleGUID]  DEFAULT (newid()) FOR [RoleGUID]
29 GO
30 
31 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N角色编号 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Role, @level2type=NCOLUMN,@level2name=NID
32 GO
33 
34 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N角色编号 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Role, @level2type=NCOLUMN,@level2name=NRoleGUID
35 GO
36 
37 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N角色名称 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Role, @level2type=NCOLUMN,@level2name=NRoleName
38 GO
39 
40 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N角色别名 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Role, @level2type=NCOLUMN,@level2name=NRoleAliasName
41 GO
42 
43 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N角色说明 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Role, @level2type=NCOLUMN,@level2name=NRoleDescription
44 GO
45 
46 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N角色级别 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Role, @level2type=NCOLUMN,@level2name=NRoleLevel
47 GO
48 
49 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N上一级角色GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Role, @level2type=NCOLUMN,@level2name=NRoleParentGUID
50 GO
51 
52 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N角色权限清单GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_Role, @level2type=NCOLUMN,@level2name=NRolePermissionListGUID
53 GO
  1 USE [AirCRM]
  2 GO
  3 
  4 /****** Object:  Table [dbo].[CRM_User]    Script Date: 2015/4/9 16:34:25 ******/
  5 SET ANSI_NULLS ON
  6 GO
  7 
  8 SET QUOTED_IDENTIFIER ON
  9 GO
 10 
 11 CREATE TABLE [dbo].[CRM_User](
 12     [ID] [int] IDENTITY(1,1) NOT NULL,
 13     [UserGUID] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
 14     [UserGroupGUID] [uniqueidentifier] NULL,
 15     [UserName] [nvarchar](50) NOT NULL,
 16     [UserPassword] [nvarchar](50) NOT NULL,
 17     [UserType] [int] NULL,
 18     [UserStatus] [bit] NOT NULL,
 19     [IsUserRegitry] [bit] NULL,
 20     [IsSystemAdd] [bit] NULL,
 21     [RegistryDate] [date] NOT NULL,
 22     [RegistryMobile] [nvarchar](15) NOT NULL,
 23     [RegistryEmail] [nvarchar](250) NULL,
 24     [UserLoginCounts] [int] NOT NULL,
 25     [UserLastLoginDate] [date] NULL,
 26     [UserLastLoginAddress] [nvarchar](50) NULL,
 27     [UserLastLoginIP] [nvarchar](50) NULL,
 28     [UserPasswordErrorCount] [int] NULL,
 29     [UserRegistryQQ] [nvarchar](50) NULL,
 30     [UserPermissionListGUID] [nvarchar](250) NULL,
 31     [IsExpire] [bit] NOT NULL,
 32     [ValidDate] [date] NULL,
 33     [UserOperationLog] [nvarchar](max) NULL,
 34     [UserRoleGUID] [uniqueidentifier] NULL,
 35  CONSTRAINT [PK_CRM_User] PRIMARY KEY CLUSTERED 
 36 (
 37     [UserGUID] ASC
 38 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
 39 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
 40 
 41 GO
 42 
 43 ALTER TABLE [dbo].[CRM_User] ADD  CONSTRAINT [DF_Table_1_UserGuid]  DEFAULT (newid()) FOR [UserGUID]
 44 GO
 45 
 46 ALTER TABLE [dbo].[CRM_User]  WITH CHECK ADD  CONSTRAINT [FK_CRM_User_CRM_Role] FOREIGN KEY([UserRoleGUID])
 47 REFERENCES [dbo].[CRM_Role] ([RoleGUID])
 48 GO
 49 
 50 ALTER TABLE [dbo].[CRM_User] CHECK CONSTRAINT [FK_CRM_User_CRM_Role]
 51 GO
 52 
 53 ALTER TABLE [dbo].[CRM_User]  WITH CHECK ADD  CONSTRAINT [FK_CRM_User_CRM_UserGroup] FOREIGN KEY([UserGroupGUID])
 54 REFERENCES [dbo].[CRM_UserGroup] ([UserGroupGUID])
 55 GO
 56 
 57 ALTER TABLE [dbo].[CRM_User] CHECK CONSTRAINT [FK_CRM_User_CRM_UserGroup]
 58 GO
 59 
 60 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户编号 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NID
 61 GO
 62 
 63 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserGUID
 64 GO
 65 
 66 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserGroupGUID
 67 GO
 68 
 69 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户名 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserName
 70 GO
 71 
 72 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户密码 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserPassword
 73 GO
 74 
 75 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户类型(0:普通用户,1:客户,2:企业用户,3:系统管理员,4:开发人员,5:测试人员) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserType
 76 GO
 77 
 78 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户状态(0:启用,1:禁用,2:新增,3:锁定,4:已过期) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserStatus
 79 GO
 80 
 81 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户通过WEB自己注册 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NIsUserRegitry
 82 GO
 83 
 84 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N通过系统后台添加 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NIsSystemAdd
 85 GO
 86 
 87 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户注册日期 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NRegistryDate
 88 GO
 89 
 90 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户注册手机号码 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NRegistryMobile
 91 GO
 92 
 93 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户注册邮箱地址 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NRegistryEmail
 94 GO
 95 
 96 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户登陆次数 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserLoginCounts
 97 GO
 98 
 99 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户最后登陆时间 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserLastLoginDate
100 GO
101 
102 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户最后登陆地址 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserLastLoginAddress
103 GO
104 
105 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户最后登陆IP地址 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserLastLoginIP
106 GO
107 
108 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户密码错误次数(超过3次自动锁定用户,解锁后才能登陆) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserPasswordErrorCount
109 GO
110 
111 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户注册QQ号码 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserRegistryQQ
112 GO
113 
114 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户权限列表 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserPermissionListGUID
115 GO
116 
117 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户是否已过期(0:未过期,1:已过期) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NIsExpire
118 GO
119 
120 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户有效日期(空值为永久有效) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NValidDate
121 GO
122 
123 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户操作日志 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserOperationLog
124 GO
125 
126 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户的角色GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_User, @level2type=NCOLUMN,@level2name=NUserRoleGUID
127 GO
 1 USE [AirCRM]
 2 GO
 3 
 4 /****** Object:  Table [dbo].[CRM_UserGroup]    Script Date: 2015/4/9 16:34:45 ******/
 5 SET ANSI_NULLS ON
 6 GO
 7 
 8 SET QUOTED_IDENTIFIER ON
 9 GO
10 
11 CREATE TABLE [dbo].[CRM_UserGroup](
12     [ID] [int] IDENTITY(1,1) NOT NULL,
13     [UserGroupGUID] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
14     [UserGroupName] [nvarchar](50) NOT NULL,
15     [UserGroupCreater] [nvarchar](50) NOT NULL,
16     [UserGroupCreateDate] [date] NOT NULL,
17     [UserGroupStatus] [bit] NOT NULL,
18     [UserGroupMembersGUID] [nvarchar](250) NULL,
19     [UserGroupPermissionListGUID] [nvarchar](250) NULL,
20     [UserGroupValidDate] [date] NULL,
21     [UserGroupIsExpire] [bit] NULL,
22     [UserGroupDescription] [nvarchar](250) NULL,
23     [UserGroupRoleGUID] [uniqueidentifier] NULL,
24  CONSTRAINT [PK_CRM_UserGroup] PRIMARY KEY CLUSTERED 
25 (
26     [UserGroupGUID] ASC
27 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
28 ) ON [PRIMARY]
29 
30 GO
31 
32 ALTER TABLE [dbo].[CRM_UserGroup] ADD  CONSTRAINT [DF_CRM_UserGroup_UserGroupGUID]  DEFAULT (newid()) FOR [UserGroupGUID]
33 GO
34 
35 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组编号 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NID
36 GO
37 
38 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupGUID
39 GO
40 
41 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组名称 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupName
42 GO
43 
44 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组创建者 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupCreater
45 GO
46 
47 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组创建日期 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupCreateDate
48 GO
49 
50 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组状态(0:启用,1:禁用,2:新增,3:锁定) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupStatus
51 GO
52 
53 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组成员GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupMembersGUID
54 GO
55 
56 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组权限列表GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupPermissionListGUID
57 GO
58 
59 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组有效期(空值为永久有效) , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupValidDate
60 GO
61 
62 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组是否已过期 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupIsExpire
63 GO
64 
65 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组说明 , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupDescription
66 GO
67 
68 EXEC sys.sp_addextendedproperty @name=NMS_Description, @value=N用户组的角色GUID , @level0type=NSCHEMA,@level0name=Ndbo, @level1type=NTABLE,@level1name=NCRM_UserGroup, @level2type=NCOLUMN,@level2name=NUserGroupRoleGUID
69 GO

 

最简单的权限管理

标签:

原文地址:http://www.cnblogs.com/linhongquan/p/5503596.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!