diff --git a/OpenAuth.App/FormApp.cs b/OpenAuth.App/FormApp.cs index 3ce29990..ff0a23be 100644 --- a/OpenAuth.App/FormApp.cs +++ b/OpenAuth.App/FormApp.cs @@ -25,6 +25,7 @@ namespace OpenAuth.App public void Add(Form obj) { Repository.Add(obj); + Repository.ExecuteSql(FormUtil.GetSql(obj)); } public void Update(Form obj) diff --git a/OpenAuth.App/FormUtil.cs b/OpenAuth.App/FormUtil.cs index c80e89a1..63d0316f 100644 --- a/OpenAuth.App/FormUtil.cs +++ b/OpenAuth.App/FormUtil.cs @@ -438,14 +438,14 @@ namespace OpenAuth.App /** * 功能: 创建数据sql */ - public static string GetSql(Form form,JObject JObject){ + public static string GetSql(Form form){ // 获取字段并处理 - var jsonArray = JArray.Parse(JObject.GetValue("data").ToString()); + var jsonArray = JArray.Parse(form.ContentData); // 数据库名称 - string data_name="`from_data_"+ form.Id+"`"; + string tableName="[Form_"+ form.FrmDbId + "]"; // 创建数据表 - StringBuilder sql =new StringBuilder("CREATE TABLE "+data_name+ " (`id` int(64) NOT NULL COMMENT '主键' ,") ; + StringBuilder sql =new StringBuilder("CREATE TABLE "+tableName+ " (id int(64) NOT NULL COMMENT '主键' ,") ; string sqlDefault = ""; @@ -454,18 +454,18 @@ namespace OpenAuth.App string name = json["name"].ToString(); string type = json["leipiplugins"].ToString(); - sql.Append("`" + name + "` " + field_type_sql(type));//字段拼接 + sql.Append("[" + name + "] " + field_type_sql(type));//字段拼接 if ("checkboxs" == (type)) - sqlDefault += field_type_sql_default(data_name, name, "0"); + sqlDefault += field_type_sql_default(tableName, name, "0"); else - sqlDefault += field_type_sql_default(data_name, name, "''"); + sqlDefault += field_type_sql_default(tableName, name, "''"); } - sql.Append("PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1 ROW_FORMAT=COMPACT;"); - return sql.ToString()+sqlDefault; + sql.Append("PRIMARY KEY ([id])) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1 ROW_FORMAT=COMPACT;"); + return sql+sqlDefault; } //获取控件字段类型 的sql diff --git a/OpenAuth.Mvc/Views/Forms/index.cshtml b/OpenAuth.Mvc/Views/Forms/index.cshtml index 1a989255..26082c5b 100644 --- a/OpenAuth.Mvc/Views/Forms/index.cshtml +++ b/OpenAuth.Mvc/Views/Forms/index.cshtml @@ -60,6 +60,14 @@ placeholder="表单名称" autocomplete="off" class="layui-input"> + +
+ +
+ +
+
@@ -68,25 +76,12 @@
-
- -
- - -
-
+ -
- -
- - -
-
-
diff --git a/OpenAuth.Repository/BaseRepository.cs b/OpenAuth.Repository/BaseRepository.cs index 161d0caf..ab0e1f35 100644 --- a/OpenAuth.Repository/BaseRepository.cs +++ b/OpenAuth.Repository/BaseRepository.cs @@ -146,5 +146,9 @@ namespace OpenAuth.Repository return dbSet; } - } + public int ExecuteSql(string sql) + { + return Context.Database.ExecuteSqlCommand(sql); + } + } } diff --git a/OpenAuth.Repository/Interface/IRepository.cs b/OpenAuth.Repository/Interface/IRepository.cs index 6414c7ca..f4eaf26a 100644 --- a/OpenAuth.Repository/Interface/IRepository.cs +++ b/OpenAuth.Repository/Interface/IRepository.cs @@ -58,5 +58,7 @@ namespace OpenAuth.Repository.Interface void Delete(Expression> exp); void Save(); + + int ExecuteSql(string sql); } } \ No newline at end of file