添加Dicts表Define字段,修改数据库脚本,新增数据库基础数据

This commit is contained in:
renshuo 2016-11-03 11:24:34 +08:00
parent 78c3482c73
commit b74a37aad3
8 changed files with 82 additions and 23 deletions

View File

@ -31,8 +31,8 @@ namespace Bootstrap.Admin.Models
} }
var ret = new QueryData<Dict>(); var ret = new QueryData<Dict>();
ret.total = data.Count(); ret.total = data.Count();
// TODO: 通过option.Sort属性判断对那列进行排序现在统一对名称列排序 // 通过option.Sort属性判断对那列进行排序现在对字典表Category列排序
data = Order == "asc" ? data.OrderBy(t => t.Name) : data.OrderByDescending(t => t.Name); data = Order == "asc" ? data.OrderBy(t => t.Category) : data.OrderByDescending(t => t.Category);
ret.rows = data.Skip(Offset).Take(Limit); ret.rows = data.Skip(Offset).Take(Limit);
return ret; return ret;
} }

View File

@ -6,7 +6,8 @@
ID: "dictID", ID: "dictID",
Category: "dictCate", Category: "dictCate",
Name: "dictName", Name: "dictName",
Code: "dictCode" Code: "dictCode",
Define:"dictDefine"
} }
}) })
}); });
@ -19,7 +20,8 @@
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, { title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "字典种类", field: "Category", sortable: true }, { title: "字典种类", field: "Category", sortable: true },
{ title: "字典名称", field: "Name", sortable: false }, { title: "字典名称", field: "Name", sortable: false },
{ title: "字典代码", field: "Code", sortable: false } { title: "字典代码", field: "Code", sortable: true },
{ title: "字典定义", field: "Define", sortable: false }
] ]
}); });
@ -36,6 +38,10 @@
dictCode: { dictCode: {
required: true, required: true,
maxlength: 50 maxlength: 50
},
dictDefine: {
required: false,
maxlength: 50
} }
}); });
}); });

View File

@ -47,6 +47,10 @@
<label class="control-label" for="dictCode">字典代码</label> <label class="control-label" for="dictCode">字典代码</label>
<input type="text" class="form-control" id="dictCode" name="dictCode" maxlength="50" /> <input type="text" class="form-control" id="dictCode" name="dictCode" maxlength="50" />
</div> </div>
<div class="form-group col-lg-6">
<label class="control-label" for="dictDefine">字典定义</label>
<input type="text" class="form-control" id="dictDefine" name="dictDefine" maxlength="50" />
</div>
</form> </form>
</div> </div>
} }

View File

@ -27,5 +27,11 @@
/// 代号 /// 代号
/// </summary> /// </summary>
public string Code { get; set; } public string Code { get; set; }
/// <summary>
/// 1表示系统使用0表示用户自定义
/// 默认为1
/// </summary>
public int Define { get; set; }
} }
} }

View File

@ -37,7 +37,8 @@ namespace Bootstrap.DataAccess
ID = (int)reader[0], ID = (int)reader[0],
Category = (string)reader[1], Category = (string)reader[1],
Name = (string)reader[2], Name = (string)reader[2],
Code = (string)reader[3] Code = (string)reader[3],
Define = (int)reader[4]
}); });
} }
} }
@ -87,8 +88,8 @@ namespace Bootstrap.DataAccess
if (p.Name.Length > 50) p.Name.Substring(0, 50); if (p.Name.Length > 50) p.Name.Substring(0, 50);
if (p.Code.Length > 50) p.Code.Substring(0, 50); if (p.Code.Length > 50) p.Code.Substring(0, 50);
string sql = p.ID == 0 ? string sql = p.ID == 0 ?
"Insert Into Dicts (Category, Name, Code) Values (@Category, @Name, @Code)" : "Insert Into Dicts (Category, Name, Code ,Define) Values (@Category, @Name, @Code, @Define)" :
"Update Dicts set Category = @Category, Name = @Name, @Code = Code where ID = @ID"; "Update Dicts set Category = @Category, Name = @Name, @Code = Code ,@Define = Define where ID = @ID";
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
@ -97,6 +98,7 @@ namespace Bootstrap.DataAccess
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", p.Name, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", p.Name, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", p.Code, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", p.Code, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Define", p.Define, ParameterDirection.Input));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
ret = true; ret = true;

View File

@ -14,7 +14,7 @@ namespace Bootstrap.DataAccess.Tests
[TestInitialize] [TestInitialize]
public void Initialized() public void Initialized()
{ {
Dict = new Dict() { Category = "__测试菜单__", Name = "__测试子菜单1__", Code = "2" }; Dict = new Dict() { Category = "__测试菜单__", Name = "__测试子菜单1__", Code = "2",Define = 0 };
} }
[TestCleanup] [TestCleanup]

View File

@ -8,11 +8,11 @@ SET IDENTITY_INSERT [dbo].[Users] OFF
DELETE From Dicts where ID in (1, 2) DELETE From Dicts where ID in (1, 2)
SET IDENTITY_INSERT [dbo].[Dicts] ON SET IDENTITY_INSERT [dbo].[Dicts] ON
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code]) VALUES (1, N'菜单', N'系统菜单', N'0') INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (1, N'菜单', N'系统菜单', N'0', 0)
INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code]) VALUES (2, N'菜单', N'外部菜单', N'1') INSERT [dbo].[Dicts] ([ID], [Category], [Name], [Code], [Define]) VALUES (2, N'菜单', N'外部菜单', N'1', 0)
SET IDENTITY_INSERT [dbo].[Dicts] OFF SET IDENTITY_INSERT [dbo].[Dicts] OFF
DELETE FROM Navigations where ID in (1, 2, 3, 4, 5, 6, 7, 8) DELETE FROM Navigations where ID in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
SET IDENTITY_INSERT [dbo].[Navigations] ON SET IDENTITY_INSERT [dbo].[Navigations] ON
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (1, 0, N'菜单管理', 10, N'fa fa-dashboard', N'~/Admin/Menus', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (1, 0, N'菜单管理', 10, N'fa fa-dashboard', N'~/Admin/Menus', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (2, 0, N'用户管理', 20, N'fa fa-user', N'~/Admin/Users', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (2, 0, N'用户管理', 20, N'fa fa-user', N'~/Admin/Users', N'0')
@ -21,5 +21,46 @@ INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [C
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (5, 0, N'字典表维护', 50, N'fa fa-book', N'~/Admin/Dicts', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (5, 0, N'字典表维护', 50, N'fa fa-book', N'~/Admin/Dicts', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (6, 0, N'个性化维护', 60, N'fa fa-pencil', N'~/Admin/Profiles', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (6, 0, N'个性化维护', 60, N'fa fa-pencil', N'~/Admin/Profiles', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (7, 0, N'系统日志', 70, N'fa fa-gears', N'~/Admin/Logs', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (7, 0, N'系统日志', 70, N'fa fa-gears', N'~/Admin/Logs', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (8, 0, N'返回前台', 80, N'fa fa-hand-o-left', N'~/Home', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (8, 0, N'通知管理', 80, N'fa fa-bell-o', N'~/Admin/News', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (9, 0, N'个人中心', 90, N'fa fa-male', N'~/Admin/Infos', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (10, 0, N'返回前台', 100, N'fa fa-hand-o-left', N'~/Home', N'0')
SET IDENTITY_INSERT [dbo].[Navigations] OFF SET IDENTITY_INSERT [dbo].[Navigations] OFF
DELETE From Groups where ID in (1)
SET IDENTITY_INSERT [dbo].[Groups] ON
INSERT [dbo].[Groups] ([ID], [GroupName], [Description]) VALUES (1, N'开发', N'开发部门')
SET IDENTITY_INSERT [dbo].[Groups] OFF
DELETE FROM NavigationRole where ID in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
SET IDENTITY_INSERT [dbo].[NavigationRole] ON
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (1, 1, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (2, 2, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (3, 3, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (4, 4, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (5, 5, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (6, 6, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (7, 7, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (8, 8, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (9, 9, 1)
INSERT [dbo].[NavigationRole] ([ID], [NavigationID], [RoleID]) VALUES (10, 10, 1)
SET IDENTITY_INSERT [dbo].[NavigationRole] OFF
DELETE FROM RoleGroup where ID in (1)
SET IDENTITY_INSERT [dbo].[RoleGroup] ON
INSERT [dbo].[RoleGroup] ([ID], [RoleID], [GroupID]) VALUES (1, 1, 1)
SET IDENTITY_INSERT [dbo].[RoleGroup] OFF
DELETE FROM Roles where ID in (1)
SET IDENTITY_INSERT [dbo].[Roles] ON
INSERT [dbo].[Roles] ([ID], [RoleName], [Description]) VALUES (1, N'Administrator', N'系统超级管理员')
SET IDENTITY_INSERT [dbo].[Roles] OFF
DELETE FROM UserGroup where ID in (1)
SET IDENTITY_INSERT [dbo].[UserGroup] ON
INSERT [dbo].[UserGroup] ([ID], [UserID], [GroupID]) VALUES (1, 1, 1)
SET IDENTITY_INSERT [dbo].[UserGroup] OFF
DELETE FROM UserRole where ID in (1)
SET IDENTITY_INSERT [dbo].[UserRole] ON
INSERT [dbo].[UserRole] ([ID], [UserID], [RoleID]) VALUES (1, 1, 1)
SET IDENTITY_INSERT [dbo].[UserRole] OFF

View File

@ -151,26 +151,24 @@ GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleGroup', @level2type=N'COLUMN',@level2name=N'GroupID' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleGroup', @level2type=N'COLUMN',@level2name=N'GroupID'
GO GO
/****** Object: Table [dbo].[Dicts] Script Date: 2016/10/31 星期一 11:33:42 ******/ /****** Object: Table [dbo].[Dicts] Script Date: 2016/11/2 星期三 16:57:31 ******/
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO
SET QUOTED_IDENTIFIER ON SET QUOTED_IDENTIFIER ON
GO GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Dicts]( CREATE TABLE [dbo].[Dicts](
[ID] [int] IDENTITY(1,1) NOT NULL, [ID] [int] IDENTITY(1,1) NOT NULL,
[Category] [nvarchar](50) NOT NULL, [Category] [nvarchar](50) NOT NULL,
[Name] [nvarchar](50) NOT NULL, [Name] [nvarchar](50) NOT NULL,
[Code] [nvarchar](50) NOT NULL, [Code] [nvarchar](50) NOT NULL,
[Define] [int] NOT NULL,
CONSTRAINT [PK_dbo.Dict] PRIMARY KEY CLUSTERED CONSTRAINT [PK_dbo.Dict] PRIMARY KEY CLUSTERED
( (
[ID] ASC [ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] ) ON [PRIMARY]
GO GO
SET ANSI_PADDING OFF ALTER TABLE [dbo].[Dicts] ADD CONSTRAINT [DF_Dicts_Define] DEFAULT ((1)) FOR [Define]
GO GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字典Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Dicts', @level2type=N'COLUMN',@level2name=N'ID' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字典Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Dicts', @level2type=N'COLUMN',@level2name=N'ID'
GO GO
@ -180,7 +178,9 @@ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字典名称'
GO GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字典代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Dicts', @level2type=N'COLUMN',@level2name=N'Code' EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'字典代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Dicts', @level2type=N'COLUMN',@level2name=N'Code'
GO GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0表示系统使用1表示自定义' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Dicts', @level2type=N'COLUMN',@level2name=N'Define'
GO GO
/****** Object: Table [dbo].[Logs] Script Date: 11/02/2016 15:33:28 ******/ /****** Object: Table [dbo].[Logs] Script Date: 11/02/2016 15:33:28 ******/
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO