diff --git a/OpenAuth.App/FormApp.cs b/OpenAuth.App/FormApp.cs index 3e2cfd29..349f45fe 100644 --- a/OpenAuth.App/FormApp.cs +++ b/OpenAuth.App/FormApp.cs @@ -1,4 +1,5 @@ -using Infrastructure; +using System; +using Infrastructure; using OpenAuth.App.Request; using OpenAuth.App.Response; using OpenAuth.Repository.Domain; @@ -15,38 +16,47 @@ namespace OpenAuth.App /// public TableData Load(QueryFormListReq request) { - + return new TableData { count = Repository.GetCount(null), - data = Repository.Find(request.page, request.limit,"CreateDate desc") + data = Repository.Find(request.page, request.limit, "CreateDate desc") }; } public void Add(Form obj) { UnitWork.Add(obj); - UnitWork.ExecuteSql(FormUtil.GetSql(obj)); + if (!string.IsNullOrEmpty(obj.DbName)) + { + UnitWork.ExecuteSql(FormUtil.GetSql(obj)); + } UnitWork.Save(); } - + public void Update(Form obj) { Repository.Update(u => u.Id == obj.Id, u => new Form { - ContentData = obj.ContentData, - Content = obj.Content, - ContentParse = obj.ContentParse, - Name = obj.Name, - DbName = obj.DbName + ContentData = obj.ContentData, + Content = obj.Content, + ContentParse = obj.ContentParse, + Name = obj.Name, + DbName = obj.DbName, + SortCode = obj.SortCode, + Description = obj.Description, + ModifyDate = DateTime.Now }); - Repository.ExecuteSql(FormUtil.GetSql(obj)); + if (!string.IsNullOrEmpty(obj.DbName)) + { + UnitWork.ExecuteSql(FormUtil.GetSql(obj)); + } } public FormResp FindSingle(string id) { - var form = Get(id); + var form = Get(id); return form.MapTo(); } diff --git a/OpenAuth.App/FormUtil.cs b/OpenAuth.App/FormUtil.cs index 25a6264f..0de6c5cf 100644 --- a/OpenAuth.App/FormUtil.cs +++ b/OpenAuth.App/FormUtil.cs @@ -498,7 +498,7 @@ namespace OpenAuth.App var jsonArray = JArray.Parse(form.ContentData); // 数据库名称 - string tableName="["+ form.DbName + "]"; + string tableName= form.DbName ; // 创建数据表 StringBuilder sql =new StringBuilder("if exists ( select * from sysobjects where name = '" +tableName+"' and type = 'U') drop table " diff --git a/OpenAuth.App/Response/FormResp.cs b/OpenAuth.App/Response/FormResp.cs index c6aa48f6..394ce4a5 100644 --- a/OpenAuth.App/Response/FormResp.cs +++ b/OpenAuth.App/Response/FormResp.cs @@ -36,6 +36,13 @@ namespace OpenAuth.App.Response /// public string Content { get; set; } + /// + /// 排序码 + /// + public int SortCode { get; set; } + + public string Description { get; set; } + /// /// 数据库名称 diff --git a/OpenAuth.Mvc/Views/Forms/Edit.cshtml b/OpenAuth.Mvc/Views/Forms/Edit.cshtml index ba444b24..77e3e65b 100644 --- a/OpenAuth.Mvc/Views/Forms/Edit.cshtml +++ b/OpenAuth.Mvc/Views/Forms/Edit.cshtml @@ -9,7 +9,7 @@ } -
+ @@ -21,7 +21,7 @@
-
+
-
- +
+
-
-
+
- +
-
+
- +
@@ -60,16 +60,16 @@
-
- - - - - - - - - +
+ + + + + + + + +