调整数据结构;

完成用户列表操作及分页;
This commit is contained in:
yubaolee 2015-11-15 23:06:43 +08:00
parent f4ae5bb150
commit 7acef13ce2
7 changed files with 600 additions and 695 deletions

868
DB.sql
View File

@ -1,6 +1,6 @@
/*==============================================================*/ /*==============================================================*/
/* DBMS name: Microsoft SQL Server 2008 */ /* DBMS name: Microsoft SQL Server 2008 */
/* Created on: 2015/10/27 8:57:02 */ /* Created on: 2015/11/15 23:04:57 */
/*==============================================================*/ /*==============================================================*/
@ -11,6 +11,20 @@ if exists (select 1
drop table Module drop table Module
go go
if exists (select 1
from sysobjects
where id = object_id('ModuleElement')
and type = 'U')
drop table ModuleElement
go
if exists (select 1
from sysobjects
where id = object_id('ModuleElementGrant')
and type = 'U')
drop table ModuleElementGrant
go
if exists (select 1 if exists (select 1
from sysobjects from sysobjects
where id = object_id('ModuleRole') where id = object_id('ModuleRole')
@ -25,27 +39,6 @@ if exists (select 1
drop table Org drop table Org
go go
if exists (select 1
from sysobjects
where id = object_id('Page')
and type = 'U')
drop table Page
go
if exists (select 1
from sysobjects
where id = object_id('PageElement')
and type = 'U')
drop table PageElement
go
if exists (select 1
from sysobjects
where id = object_id('PageElementGrant')
and type = 'U')
drop table PageElementGrant
go
if exists (select 1 if exists (select 1
from sysobjects from sysobjects
where id = object_id('Role') where id = object_id('Role')
@ -383,11 +376,287 @@ alter table Module
add constraint PK_aos_sys_module primary key nonclustered (Id) add constraint PK_aos_sys_module primary key nonclustered (Id)
go go
/*==============================================================*/
/* Table: ModuleElement */
/*==============================================================*/
create table ModuleElement (
Id int identity,
DomId varchar(255) not null default ' ',
Name varchar(255) not null default ' ',
Type int not null default 0,
ModuleId int not null default 0,
Remark varchar(4000) not null default ' '
)
go
if exists (select 1 from sys.extended_properties
where major_id = object_id('ModuleElement') and minor_id = 0)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElement'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'模块元素表',
'user', @CurrentUser, 'table', 'ModuleElement'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Id')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'Id'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'流水号',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'Id'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'DomId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'DomId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'DOM ID',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'DomId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Name')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'Name'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'名称',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'Name'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Type')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'Type'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'类型',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'Type'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ModuleId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'ModuleId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'所属功能模块流水号',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'ModuleId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Remark')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'Remark'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'备注',
'user', @CurrentUser, 'table', 'ModuleElement', 'column', 'Remark'
go
alter table ModuleElement
add constraint PK_MODULEELEMENT primary key (Id)
go
/*==============================================================*/
/* Table: ModuleElementGrant */
/*==============================================================*/
create table ModuleElementGrant (
Id int identity,
ElementId int not null default 0,
UserId int not null default 0,
RoleId int not null default 0,
GrantType int not null default 0
)
go
if exists (select 1 from sys.extended_properties
where major_id = object_id('ModuleElementGrant') and minor_id = 0)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElementGrant'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'元素授权表',
'user', @CurrentUser, 'table', 'ModuleElementGrant'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Id')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'Id'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'流水号',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'Id'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ElementId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'ElementId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'页面元素流水号',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'ElementId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'UserId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'UserId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'用户流水号',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'UserId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'RoleId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'RoleId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'角色流水号',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'RoleId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('ModuleElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'GrantType')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'GrantType'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'权限类型',
'user', @CurrentUser, 'table', 'ModuleElementGrant', 'column', 'GrantType'
go
alter table ModuleElementGrant
add constraint PK_MODULEELEMENTGRANT primary key (Id)
go
/*==============================================================*/ /*==============================================================*/
/* Table: ModuleRole */ /* Table: ModuleRole */
/*==============================================================*/ /*==============================================================*/
create table ModuleRole ( create table ModuleRole (
Id int not null, Id int identity,
RoleId int not null default 0, RoleId int not null default 0,
ModuleId int not null default 0, ModuleId int not null default 0,
Type int not null default 0, Type int not null default 0,
@ -860,550 +1129,6 @@ alter table Org
add constraint PK_ORG primary key (Id) add constraint PK_ORG primary key (Id)
go go
/*==============================================================*/
/* Table: Page */
/*==============================================================*/
create table Page (
Id int identity,
ModuleId int not null default 0,
Name varchar(255) not null default ' ',
Url varchar(255) not null default ' ',
Type int not null default 0,
Enabled bit not null default 1,
IsDefault bit not null default 0,
Icon varchar(255) not null default ' ',
IconBig varchar(255) not null default ' ',
Vector varchar(255) not null default ' ',
SortNo int not null default 0
)
go
if exists (select 1 from sys.extended_properties
where major_id = object_id('Page') and minor_id = 0)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'一个模块可以有多个页面',
'user', @CurrentUser, 'table', 'Page'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Id')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'Id'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'流水号',
'user', @CurrentUser, 'table', 'Page', 'column', 'Id'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ModuleId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'ModuleId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'功能模块ID',
'user', @CurrentUser, 'table', 'Page', 'column', 'ModuleId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Name')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'Name'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'名称',
'user', @CurrentUser, 'table', 'Page', 'column', 'Name'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Url')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'Url'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'页面URL',
'user', @CurrentUser, 'table', 'Page', 'column', 'Url'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Type')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'Type'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'类型',
'user', @CurrentUser, 'table', 'Page', 'column', 'Type'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Enabled')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'Enabled'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'使能状态',
'user', @CurrentUser, 'table', 'Page', 'column', 'Enabled'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'IsDefault')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'IsDefault'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'是否缺省子页面',
'user', @CurrentUser, 'table', 'Page', 'column', 'IsDefault'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Icon')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'Icon'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'小图标',
'user', @CurrentUser, 'table', 'Page', 'column', 'Icon'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'IconBig')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'IconBig'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'大图标',
'user', @CurrentUser, 'table', 'Page', 'column', 'IconBig'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Vector')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'Vector'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'矢量图标',
'user', @CurrentUser, 'table', 'Page', 'column', 'Vector'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('Page')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'SortNo')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'Page', 'column', 'SortNo'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'排序号',
'user', @CurrentUser, 'table', 'Page', 'column', 'SortNo'
go
alter table Page
add constraint PK_PAGE primary key (Id)
go
/*==============================================================*/
/* Table: PageElement */
/*==============================================================*/
create table PageElement (
Id int not null,
DomId varchar(255) not null default ' ',
Name varchar(255) not null default ' ',
Type int not null default 0,
ModuleId int not null default 0,
Remark varchar(4000) not null default ' '
)
go
if exists (select 1 from sys.extended_properties
where major_id = object_id('PageElement') and minor_id = 0)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElement'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'页面元素表',
'user', @CurrentUser, 'table', 'PageElement'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Id')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'Id'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'流水号',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'Id'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'DomId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'DomId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'DOM ID',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'DomId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Name')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'Name'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'名称',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'Name'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Type')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'Type'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'类型',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'Type'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ModuleId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'ModuleId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'所属功能模块流水号',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'ModuleId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElement')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Remark')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'Remark'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'备注',
'user', @CurrentUser, 'table', 'PageElement', 'column', 'Remark'
go
alter table PageElement
add constraint PK_PAGEELEMENT primary key (Id)
go
/*==============================================================*/
/* Table: PageElementGrant */
/*==============================================================*/
create table PageElementGrant (
Id int not null,
ElementId int not null default 0,
UserId int not null default 0,
RoleId int not null default 0,
PostId int not null default 0,
GrantType int not null default 0
)
go
if exists (select 1 from sys.extended_properties
where major_id = object_id('PageElementGrant') and minor_id = 0)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElementGrant'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'页面元素授权表',
'user', @CurrentUser, 'table', 'PageElementGrant'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'Id')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'Id'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'流水号',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'Id'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'ElementId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'ElementId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'页面元素流水号',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'ElementId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'UserId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'UserId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'用户流水号',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'UserId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'RoleId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'RoleId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'角色流水号',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'RoleId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'PostId')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'PostId'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'岗位流水号',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'PostId'
go
if exists(select 1 from sys.extended_properties p where
p.major_id = object_id('PageElementGrant')
and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'GrantType')
)
begin
declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'GrantType'
end
select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
'权限类型',
'user', @CurrentUser, 'table', 'PageElementGrant', 'column', 'GrantType'
go
alter table PageElementGrant
add constraint PK_PAGEELEMENTGRANT primary key (Id)
go
/*==============================================================*/ /*==============================================================*/
/* Table: Role */ /* Table: Role */
/*==============================================================*/ /*==============================================================*/
@ -1596,7 +1321,7 @@ go
/* Table: [User] */ /* Table: [User] */
/*==============================================================*/ /*==============================================================*/
create table [User] ( create table [User] (
Id int not null, Id int identity,
Account varchar(255) not null default ' ', Account varchar(255) not null default ' ',
Password varchar(255) not null default ' ', Password varchar(255) not null default ' ',
Name varchar(255) not null default ' ', Name varchar(255) not null default ' ',
@ -2300,7 +2025,7 @@ go
/* Table: UserModule */ /* Table: UserModule */
/*==============================================================*/ /*==============================================================*/
create table UserModule ( create table UserModule (
Id int not null, Id int identity,
UserId int not null default 0, UserId int not null default 0,
ModuleId int not null default 0, ModuleId int not null default 0,
Type int not null default 0, Type int not null default 0,
@ -2448,7 +2173,7 @@ go
/* Table: UserOrg */ /* Table: UserOrg */
/*==============================================================*/ /*==============================================================*/
create table UserOrg ( create table UserOrg (
Id int not null, Id int identity,
OrgId int not null default 0, OrgId int not null default 0,
UserId int not null default 0, UserId int not null default 0,
OperateTime datetime not null default getdate(), OperateTime datetime not null default getdate(),
@ -2557,7 +2282,7 @@ go
/* Table: UserRole */ /* Table: UserRole */
/*==============================================================*/ /*==============================================================*/
create table UserRole ( create table UserRole (
Id int not null, Id int identity,
RoleId int not null default 0, RoleId int not null default 0,
UserId int not null default 0, UserId int not null default 0,
OperateTime datetime not null default getdate(), OperateTime datetime not null default getdate(),
@ -2661,4 +2386,3 @@ go
alter table UserRole alter table UserRole
add constraint PK_USERROLE primary key (Id) add constraint PK_USERROLE primary key (Id)
go go

View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using Infrastructure;
using OpenAuth.Domain;
namespace OpenAuth.App.ViewModel
{
public class UserView
{
/// <summary>
/// 用户ID
/// </summary>
/// <returns></returns>
public int Id { get; set; }
/// <summary>
/// </summary>
/// <returns></returns>
public string Account { get; set; }
/// <summary>
/// 组织名称
/// </summary>
/// <returns></returns>
public string Name { get; set; }
/// <summary>
/// </summary>
/// <returns></returns>
public int Sex { get; set; }
/// <summary>
/// 当前状态
/// </summary>
/// <returns></returns>
public int Status { get; set; }
/// <summary>
/// 组织类型
/// </summary>
/// <returns></returns>
public int Type { get; set; }
/// <summary>
/// 创建时间
/// </summary>
/// <returns></returns>
public DateTime CreateTime { get; set; }
/// <summary>
/// 创建人名字
/// </summary>
/// <value>The create user.</value>
public string CreateUser { get; set; }
/// <summary>
/// 所属组织名称,多个可用,分隔
/// </summary>
/// <value>The organizations.</value>
public string Organizations { get; set; }
public string OrganizationIds { get; set; }
public static implicit operator UserView(User user)
{
return AutoMapperExt.ConvertTo<User, UserView>(user);
}
public static implicit operator User(UserView view)
{
return AutoMapperExt.ConvertTo<UserView, User>(view);
}
}
}

View File

@ -1,62 +0,0 @@
@model dynamic
@{
ViewBag.Title = "title";
Layout = null;
}
<div class="bjui-pageContent">
<div style="float: left; width: 100%; height: 240px; overflow: auto;" class="table table-bordered">
<ul id="lookupTree" class="ztree"></ul>
</div>
</div>
<div class="bjui-pageFooter">
<ul>
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
<li>
<a href="javascript:;" id="btnSelected" data-toggle="lookupback"
data-args="{nationid:'A001', nation:'CN'}"
class="btn btn-blue" title="选择本项" data-icon="check">选择</a>
</li>
</ul>
</div>
<script type="text/javascript">
$(document).ready(function () {
Init();
});
function Init() {
var setting = {
view: {
selectedMulti: false
},
data: {
key: {
name: 'Name',
title: 'Name'
},
simpleData: {
enable: true,
idKey: 'Id',
pIdKey: 'ParentId',
rootPId: 'null'
}
},
callback: {
onClick: zTreeOnClick
}
};
$.getJSON('OrgManager/LoadOrg', function (json) {
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
zTreeObj.expandAll(true);
});
}
function zTreeOnClick(event, treeId, treeNode) {
var selected = "{ParentName:'" + treeNode.Name + "', ParentId:" + treeNode.Id + "}";
$("#btnSelected").attr("data-args",selected);
}
//@@ sourceURL=lookupParent.js
</script>

View File

@ -0,0 +1,130 @@
@model OpenAuth.App.ViewModel.UserView
@{
ViewBag.Title = "title";
Layout = null;
}
<div class="bjui-pageContent">
<form action="/UserManager/Add" class="pageForm" data-toggle="validate">
<table class="table table-condensed table-hover">
<tbody>
<tr>
<td align="center"><h3>* 添加</h3></td>
</tr>
<tr>
<td>
@Html.HiddenFor(m =>m.CreateTime)
@Html.HiddenFor(m =>m.Id)
<label for="Account" class="control-label x90">用户账号:</label>
<input type="text" name="Account" id="Account" value="@Model.Account"
data-rule="required" size="20">
</td>
</tr>
<tr>
<td>
<label for="Name" class="control-label x90">姓名/昵称:</label>
<input type="text" name="Name" id="Name" value="@Model.Name" size="20">
</td>
</tr>
<tr>
<td>
<label for="Organizations" class="control-label x90">所属机构:</label>
<input id="OrganizationIds" name="OrganizationIds" value="@Model.OrganizationIds" style="display: none" />
<input type="text" name="Organizations" id="Organizations"
data-toggle="selectztree" size="20" data-tree="#j_select_tree1" value="@Model.Organizations">
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree" >
</ul>
</td>
</tr>
<tr>
<td>
<label for="Status" class="control-label x85">设置状态:</label>
<select name="Status" id="Status" data-toggle="selectpicker" data-rule="required">
<option value="0">正常</option>
<option value="1">禁用</option>
</select>
</td>
</tr>
<tr>
<td>
<label for="Sex" class="control-label x85">性别:</label>
<select name="Sex" id="Sex" data-toggle="selectpicker" data-rule="required">
<option value="0">男</option>
<option value="1">女</option>
</select>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="bjui-pageFooter">
<ul>
<li><button type="button" class="btn-close">关闭</button></li>
<li><button type="submit" class="btn-green">保存</button></li>
</ul>
</div>
<script type="text/javascript">
$(document).ready(function () {
Init();
});
function Init() {
var setting = {
view: {
selectedMulti: false
},
check: {
enable: true,
chkStyle: "checkbox",
chkboxType: { "Y": "", "N": "" } //去掉勾选时级联
},
data: {
key: {
name: 'Name',
title: 'Name'
},
simpleData: {
enable: true,
idKey: 'Id',
pIdKey: 'ParentId',
rootPId: 'null'
}
},
callback: {
onClick: zTreeOnClick,
onCheck: zTreeCheck
}
};
$.getJSON('OrgManager/LoadOrg', function (json) {
var zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
zTreeObj.expandAll(true);
});
}
function zTreeCheck(e, treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj(treeId),
nodes = zTree.getCheckedNodes(true);
var ids = '', names = '';
for (var i = 0; i < nodes.length; i++) {
ids += ',' + nodes[i].Id;
names += ',' + nodes[i].Name;
}
if (ids.length > 0) { //去掉第一个逗号
ids = ids.substr(1);
names = names.substr(1);
}
var $from = $('#' + treeId).data('fromObj');
if ($from && $from.length) $from.val(names);
$('#OrganizationIds').val(ids);
}
function zTreeOnClick(event, treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj(treeId);
zTree.checkNode(treeNode, !treeNode.checked, true, true);
event.preventDefault();
}
</script>

View File

@ -1,52 +0,0 @@

@{
ViewBag.Title = "title";
Layout = null;
}
<div class="bjui-pageContent">
<form action="/OrgManager/AddOrg" class="pageForm" data-toggle="validate">
<table class="table table-condensed table-hover">
<tbody>
<tr>
<td align="center"><h3>* 添加</h3></td>
</tr>
<tr>
<td>
<label for="Name" class="control-label x90">机构名称:</label>
<input type="text" name="Name" id="Name" value=""
data-rule="required" size="20">
</td>
</tr>
<tr>
<td>
<input id="ParentId" name="ParentId" type="hidden">
<label for="ParentName" class="control-label x90">上级机构:</label>
<input type="text" name="ParentName" id="ParentName"
value="" data-toggle="lookup" data-url="/OrgManager/LookupParent">
</td>
</tr>
<tr>
<td>
<label for="Status" class="control-label x85">设置状态:</label>
<select name="Status" id="Status" data-toggle="selectpicker" data-rule="required">
<option value="0">正常</option>
<option value="1">禁用</option>
</select>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="bjui-pageFooter">
<ul>
<li><button type="button" class="btn-close">关闭</button></li>
<li><button type="submit" class="btn-green">保存</button></li>
</ul>
</div>

View File

@ -0,0 +1,83 @@
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenAuth.App;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Repository;
namespace OpenAuth.UnitTest
{
/// <summary>
/// TestOrgApp 的摘要说明
/// </summary>
[TestClass]
public class TestUserApp
{
private UserManagerApp _app = new UserManagerApp(new UserRepository(), new OrgRepository());
private string _time = DateTime.Now.ToString("HH_mm_ss_ms");
[TestMethod]
public void TestAdd()
{
for (int i = 0; i < 30; i++)
{
Add();
}
}
[TestMethod]
public void TestDel()
{
var user = new UserView
{
Account = "user" + _time,
Name = "即将被删除的账号" + _time,
OrganizationIds = "3,2"
};
_app.AddOrUpdate(user);
Console.WriteLine("new user:" + user.Id);
_app.Delete(user.Id);
}
[TestMethod]
public void TestLoad()
{
var users = _app.Load(1,1, 10);
}
[TestMethod]
public void TestEdit()
{
var user = Add();
user.Name = "修改后的名称" + _time;
_app.AddOrUpdate(user);
Console.WriteLine(user.Name);
}
private UserView Add()
{
var user = new UserView
{
Account = "user" + _time,
Name = "新用户" + _time,
OrganizationIds = "3,2"
};
_app.AddOrUpdate(user);
Console.WriteLine(user.Name + " \t用户ID" + user.Id);
return user;
}
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{54F96D9D-A534-4ADF-ADAD-ACFE3C42BC44}" Label="" LastModificationDate="1447426691" Name="OpenAuthDB" Objects="264" Symbols="27" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?> <?PowerDesigner AppLocale="UTF16" ID="{54F96D9D-A534-4ADF-ADAD-ACFE3C42BC44}" Label="" LastModificationDate="1447599897" Name="OpenAuthDB" Objects="226" Symbols="24" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
<!-- do not edit this file --> <!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object"> <Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@ -12,7 +12,7 @@
<a:Code>PDM_OA</a:Code> <a:Code>PDM_OA</a:Code>
<a:CreationDate>1430102287</a:CreationDate> <a:CreationDate>1430102287</a:CreationDate>
<a:Creator>yubaolee</a:Creator> <a:Creator>yubaolee</a:Creator>
<a:ModificationDate>1447426593</a:ModificationDate> <a:ModificationDate>1447599897</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier> <a:Modifier>Administrator</a:Modifier>
<a:History>ORG {9C5FE510-8BFA-4205-BF00-FC94E77A24A2} <a:History>ORG {9C5FE510-8BFA-4205-BF00-FC94E77A24A2}
DAT 1430102318 DAT 1430102318
@ -193,7 +193,7 @@ UpdateTableStatistics=Yes
UpdateColumnStatistics=Yes UpdateColumnStatistics=Yes
[FolderOptions\Physical Objects\Database Generation] [FolderOptions\Physical Objects\Database Generation]
GenScriptName=crebas.sql GenScriptName=DB.sql
GenScriptName0=crebas.sql GenScriptName0=crebas.sql
GenScriptName1= GenScriptName1=
GenScriptName2= GenScriptName2=
@ -204,7 +204,7 @@ GenScriptName6=
GenScriptName7= GenScriptName7=
GenScriptName8= GenScriptName8=
GenScriptName9= GenScriptName9=
GenPathName=E:\测试学习\OpenAuth.Net\数据库设计关系图\ GenPathName=F:\测试学习\OpenAuth.Net\
GenSingleFile=Yes GenSingleFile=Yes
GenODBC=Yes GenODBC=Yes
GenCheckModel=No GenCheckModel=No
@ -4642,7 +4642,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o14"> <o:ReferenceSymbol Id="o14">
<a:CreationDate>1445622899</a:CreationDate> <a:CreationDate>1445622899</a:CreationDate>
<a:ModificationDate>1447426452</a:ModificationDate> <a:ModificationDate>1447426452</a:ModificationDate>
<a:Rect>((-14368,-69613), (-9868,-48829))</a:Rect> <a:Rect>((-14480,-69613), (-9756,-48829))</a:Rect>
<a:ListOfPoints>((-13408,-69613),(-13408,-58801),(-10828,-58801),(-10828,-48829))</a:ListOfPoints> <a:ListOfPoints>((-13408,-69613),(-13408,-58801),(-10828,-58801),(-10828,-48829))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
@ -4665,7 +4665,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o17"> <o:ReferenceSymbol Id="o17">
<a:CreationDate>1445690822</a:CreationDate> <a:CreationDate>1445690822</a:CreationDate>
<a:ModificationDate>1447426454</a:ModificationDate> <a:ModificationDate>1447426454</a:ModificationDate>
<a:Rect>((6066,-44264), (26828,-37469))</a:Rect> <a:Rect>((6066,-44264), (26941,-37469))</a:Rect>
<a:ListOfPoints>((21766,-44264),(21766,-37881),(6066,-37881))</a:ListOfPoints> <a:ListOfPoints>((21766,-44264),(21766,-37881),(6066,-37881))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
@ -4776,7 +4776,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o31"> <o:ReferenceSymbol Id="o31">
<a:CreationDate>1445692935</a:CreationDate> <a:CreationDate>1445692935</a:CreationDate>
<a:ModificationDate>1447426481</a:ModificationDate> <a:ModificationDate>1447426481</a:ModificationDate>
<a:Rect>((50915,-65638), (61039,-11782))</a:Rect> <a:Rect>((50803,-65638), (61152,-11782))</a:Rect>
<a:ListOfPoints>((60396,-11782),(60396,-31736),(51559,-31736),(51559,-65638))</a:ListOfPoints> <a:ListOfPoints>((60396,-11782),(60396,-31736),(51559,-31736),(51559,-65638))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
@ -4820,7 +4820,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o36"> <o:ReferenceSymbol Id="o36">
<a:CreationDate>1445703432</a:CreationDate> <a:CreationDate>1445703432</a:CreationDate>
<a:ModificationDate>1447426452</a:ModificationDate> <a:ModificationDate>1447426452</a:ModificationDate>
<a:Rect>((-6822,-67310), (2928,-45110))</a:Rect> <a:Rect>((-6934,-67310), (3040,-45110))</a:Rect>
<a:ListOfPoints>((-350,-67310),(-350,-58993),(-3544,-58993),(-3544,-45110))</a:ListOfPoints> <a:ListOfPoints>((-350,-67310),(-350,-58993),(-3544,-58993),(-3544,-45110))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>
@ -4842,7 +4842,7 @@ DESTINATION 0 新宋体,8,N</a:FontList>
<o:ReferenceSymbol Id="o39"> <o:ReferenceSymbol Id="o39">
<a:CreationDate>1445703433</a:CreationDate> <a:CreationDate>1445703433</a:CreationDate>
<a:ModificationDate>1447426437</a:ModificationDate> <a:ModificationDate>1447426437</a:ModificationDate>
<a:Rect>((4392,-90068), (13865,-67632))</a:Rect> <a:Rect>((4280,-90068), (13879,-67632))</a:Rect>
<a:ListOfPoints>((4518,-67632),(4518,-76744),(13640,-76744),(13640,-90068))</a:ListOfPoints> <a:ListOfPoints>((4518,-67632),(4518,-76744),(13640,-76744),(13640,-90068))</a:ListOfPoints>
<a:CornerStyle>1</a:CornerStyle> <a:CornerStyle>1</a:CornerStyle>
<a:ArrowStyle>1</a:ArrowStyle> <a:ArrowStyle>1</a:ArrowStyle>