From 4352ad5cbeef498392178655cb367ee38e574178 Mon Sep 17 00:00:00 2001 From: schangxiang@126.com <schangxiang@126.com> Date: 周二, 29 4月 2025 18:05:47 +0800 Subject: [PATCH] 222 --- Weben_CMS专用代码生成器/Code/Generate/BLL_Generate.cs | 38 Weben_CMS专用代码生成器/Code/Generate/Procedure_Generate.cs | 272 ++ Weben_CMS专用代码生成器/Code/Templete/VUE/VUE方法配置.txt | 17 Weben_CMS专用代码生成器/Code/Utility/SQLHelper.cs | 254 + Weben_CMS专用代码生成器/Code/Model/Enum/DataTypeEnum.cs | 36 Weben_CMS专用代码生成器/Code/GenerateCode_WeiBen_CMS.csproj | 246 + Weben_CMS专用代码生成器/Code/Generate/Entity/AddModel_Generate.cs | 35 Weben_CMS专用代码生成器/Code/Properties/Resources.Designer.cs | 63 Weben_CMS专用代码生成器/Code/Generate/Entity/InputModel_Generate.cs | 49 Weben_CMS专用代码生成器/Code/Utility/MySqlHelper.cs | 262 ++ Weben_CMS专用代码生成器/Code/Model/ColumnModell.cs | 47 Weben_CMS专用代码生成器/Code/Templete/Proc/分页存储过程.txt | 39 Weben_CMS专用代码生成器/Code/Templete/Entity/InputModel模板.txt | 48 Weben_CMS专用代码生成器/Code/Properties/Settings.Designer.cs | 26 Weben_CMS专用代码生成器/Code/Utility/StructStrHelper.cs | 1682 +++++++++++++ Weben_CMS专用代码生成器/Code/Templete/Proc/列表存储过程.txt | 34 Weben_CMS专用代码生成器/Code/Generate/DAL_Generate.cs | 52 Weben_CMS专用代码生成器/Code/Robot.ico | 0 Weben_CMS专用代码生成器/Code/Utility/CommonHelper.cs | 262 ++ Weben_CMS专用代码生成器/Code/Model/Proc.cs | 52 Weben_CMS专用代码生成器/Code/Properties/AssemblyInfo.cs | 36 Weben_CMS专用代码生成器/Code/DataBaseFactory/Default/SqlServerDataBaseServiceHandle.cs | 130 + Weben_CMS专用代码生成器/Code/Templete/Proc/增加一条记录存储过程.txt | 21 Weben_CMS专用代码生成器/Code/Templete/InitSQL模板.txt | 14 Weben_CMS专用代码生成器/Code/Templete/Proc/修改一条记录存储过程2.txt | 17 Weben_CMS专用代码生成器/Code/Model/ListItem.cs | 32 Weben_CMS专用代码生成器/Code/packages.config | 14 Weben_CMS专用代码生成器/Code/Generate/Services_InterfaceRealize_Generate.cs | 43 Weben_CMS专用代码生成器/Code/MainForm.resx | 120 Weben_CMS专用代码生成器/Code/Properties/Settings.settings | 7 Weben_CMS专用代码生成器/Code/Templete/Entity/OutputModel模板.txt | 22 Weben_CMS专用代码生成器/Code/Utility/ListHelper.cs | 274 ++ Weben_CMS专用代码生成器/Code/Properties/Resources.resx | 117 Weben_CMS专用代码生成器/Code/DataBaseFactory/Default/MySqlDataBaseServiceHandle.cs | 113 Weben_CMS专用代码生成器/Code/App.config | 25 Weben_CMS专用代码生成器/Code/Generate/VUE/VUE_Generate.cs | 58 Weben_CMS专用代码生成器/Code/Templete/VUE/VUE文件模板.txt | 485 +++ Weben_CMS专用代码生成器/Code/Utility/TextHelper.cs | 171 + Weben_CMS专用代码生成器/Code/Templete/Services接口实现模板.txt | 192 + Weben_CMS专用代码生成器/Code/Program.cs | 21 Weben_CMS专用代码生成器/Code/Templete/DAL模板.txt | 257 + Weben_CMS专用代码生成器/Code/Generate/VUE/VUE_FunConfig_Generate.cs | 35 Weben_CMS专用代码生成器/Code/Generate/Model_Generate.cs | 115 Weben_CMS专用代码生成器/Code/Generate/Controller/Controller_Generate.cs | 36 Weben_CMS专用代码生成器/Code/Templete/BLL模板.txt | 178 + Weben_CMS专用代码生成器/Code/Generate/Entity/OutputModel_Generate.cs | 47 Weben_CMS专用代码生成器/Code/Generate/Services_Interface_Generate.cs | 30 Weben_CMS专用代码生成器/Code/Model/Enum/DataBaseEnum.cs | 16 Weben_CMS专用代码生成器/Code/Model/SystemCommonVar.cs | 50 Weben_CMS专用代码生成器/Code/Templete/Entity/AddModel模板.txt | 14 Weben_CMS专用代码生成器/Code/Templete/Proc/得到一个实体存储过程.txt | 19 Weben_CMS专用代码生成器/Code/MainForm.cs | 377 ++ Weben_CMS专用代码生成器/Code/DataBaseFactory/DataBaseServiceFactory.cs | 27 Weben_CMS专用代码生成器/Code/Generate/InsertSQL_Generate.cs | 71 Weben_CMS专用代码生成器/Code/Templete/Services接口模板.txt | 59 Weben_CMS专用代码生成器/Code/DataBaseFactory/DataBaseServiceHandle.cs | 39 Weben_CMS专用代码生成器/Code/GenerateCode_WeiBen_CMS.sln | 29 Weben_CMS专用代码生成器/Code/MainForm.Designer.cs | 594 ++++ Weben_CMS专用代码生成器/Code/Generate/BaseGenerate.cs | 17 Weben_CMS专用代码生成器/Code/Templete/Controller模板.txt | 274 ++ Weben_CMS专用代码生成器/版本说明.txt | 5 Weben_CMS专用代码生成器/Code/Templete/Proc/修改一条记录存储过程.txt | 17 62 files changed, 7,732 insertions(+), 0 deletions(-) diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/App.config" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/App.config" new file mode 100644 index 0000000..df9319f --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/App.config" @@ -0,0 +1,25 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<configuration> + <connectionStrings> + <add name="鏈湴_MySql_CMS" connectionString="Server=localhost;Database=4b25b01c1f7f49d19153de6b0906eafc_project;Uid=root;Pwd=123abc.com;" /> + <add name="LA22012_姝︽眽鐗ч噹_鐢熶骇搴揰浼熸湰鐜" connectionString="Data Source=10.10.40.166;Initial Catalog=WHMY_Prod_Test;Persist Security Info=True;User ID=sa;Password=123abc.com" /> + <add name="LA22012_姝︽眽鐗ч噹_鐢熶骇搴揰26娴嬭瘯鐜" connectionString="Data Source=172.27.96.26;Initial Catalog=WHMY_Prod_Test;Persist Security Info=True;User ID=sa;Password=MJC!2022@wms" /> + <add name="LA22012_姝︽眽鐗ч噹_澶囦欢搴揰浼熸湰鐜" connectionString="Data Source=10.10.40.166;Initial Catalog=WHMY_Admin.NET;Persist Security Info=True;User ID=sa;Password=123abc.com" /> + <add name="LA22012_姝︽眽鐗ч噹_澶囦欢搴揰26娴嬭瘯鐜" connectionString="Data Source=172.27.96.26;Initial Catalog=WHMY_Admin.NET;Persist Security Info=True;User ID=sa;Password=MJC!2022@wms" /> + <add name="LA21030_姝︽眽鐗ч噹_鐢熶骇" connectionString="Data Source=172.27.105.59;Initial Catalog=WHMY_Admin.NET;Persist Security Info=True;User ID=sa;Password=123abc.com" /> + <add name="LA21030_姝︽眽鐗ч噹_鏈湴" connectionString="Data Source=localhost;Initial Catalog=WHMY_Admin.NET;Persist Security Info=True;User ID=sa;Password=123abc.com" /> + <add name="LA18032_AoSinWms_浜�" connectionString="Data Source=120.53.244.200;Initial Catalog=LA18032_AoSinWms;Persist Security Info=True;User ID=sa;Password=123abc.com" /> + <add name="GSiemens_LES" connectionString="Data Source=localhost;Initial Catalog=GSiemens_LES;Persist Security Info=True;User ID=sa;Password=123abc.com" /> + <add name="GSiemens_WIP" connectionString="Data Source=.;Initial Catalog=GSiemens_WIP;Persist Security Info=True;User ID=sa;Password=123abc.com" /> + <add name="LocalhostConn" connectionString="Data Source=shaocx;Initial Catalog=SOADB;User ID=sa;Password=1111" /> + </connectionStrings> +<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration> diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/DataBaseServiceFactory.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/DataBaseServiceFactory.cs" new file mode 100644 index 0000000..0333e41 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/DataBaseServiceFactory.cs" @@ -0,0 +1,27 @@ +锘縰sing GenerateCode_GEBrilliantFactory; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_WeiBen_WMS.DataBaseFactory +{ + public class DataBaseServiceFactory + { + public static DataBaseServiceHandle GetHandle(DataBaseEnum meterialType) + { + DataBaseServiceHandle handle = null; + switch (meterialType) + { + case DataBaseEnum.SqlServer: + handle = new SqlServerDataBaseServiceHandle(); + break; + case DataBaseEnum.MySql: + handle = new MySqlDataBaseServiceHandle(); + break; + } + return handle; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/DataBaseServiceHandle.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/DataBaseServiceHandle.cs" new file mode 100644 index 0000000..c8c6ec9 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/DataBaseServiceHandle.cs" @@ -0,0 +1,39 @@ +锘縰sing GenerateCode_GEBrilliantFactory; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_WeiBen_WMS.DataBaseFactory +{ + public class DataBaseServiceHandle + { + #region 铏氭柟娉� + + /// <summary> + /// 鑾峰彇鏁版嵁搴撹〃鍒楄〃 + /// </summary> + /// <param name="tableName"></param> + /// <param name="connStr"></param> + /// <returns></returns> + public virtual List<ColumnModel> GetColumnList(string tableName, string connStr) + { + return null; + } + + + /// <summary> + /// 杞崲 + /// </summary> + /// <param name="dt"></param> + /// <returns></returns> + public virtual List<ColumnModel> DataTableToList(DataTable dt) + { + return null; + } + + #endregion + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/Default/MySqlDataBaseServiceHandle.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/Default/MySqlDataBaseServiceHandle.cs" new file mode 100644 index 0000000..0e91efd --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/Default/MySqlDataBaseServiceHandle.cs" @@ -0,0 +1,113 @@ +锘縰sing GenerateCode_GEBrilliantFactory; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_WeiBen_WMS.DataBaseFactory +{ + public class MySqlDataBaseServiceHandle : DataBaseServiceHandle + { + public override List<ColumnModel> GetColumnList(string tableName, string connStr) + { + //string strSql = $"SELECT COLUMN_NAME as ColumnName, COLUMN_TYPE as DataType, IS_NULLABLE as IsNullable, CHARACTER_MAXIMUM_LENGTH as DataLength,COLUMN_COMMENT as Description " + + // $"FROM INFORMATION_SCHEMA.COLUMNS " + + // $"WHERE TABLE_NAME = '{tableName}'"; + string strSql = $"SELECT c.COLUMN_NAME as ColumnName, c.COLUMN_TYPE as DataType, c.IS_NULLABLE as IsNullable, c.CHARACTER_MAXIMUM_LENGTH as DataLength, c.COLUMN_COMMENT as Description, " + + $"CASE WHEN kcu.COLUMN_NAME IS NOT NULL THEN 'true' ELSE 'false' END AS IsPrimaryKey " + + $"FROM INFORMATION_SCHEMA.COLUMNS c " + + $"LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu " + + $"ON c.TABLE_SCHEMA = kcu.TABLE_SCHEMA " + + $"AND c.TABLE_NAME = kcu.TABLE_NAME " + + $"AND c.COLUMN_NAME = kcu.COLUMN_NAME " + + $"AND kcu.CONSTRAINT_NAME = 'PRIMARY' " + + $"WHERE c.TABLE_NAME = '{tableName}'"; + + + List<ColumnModel> columnList = new List<ColumnModel>(); + try + { + DataSet ds = MySqlHelper.Query(connStr, strSql); + columnList = DataTableToList(ds.Tables[0]); + } + catch + { + throw; + } + finally + { + } + return columnList; + } + + public override List<ColumnModel> DataTableToList(DataTable dt) + { + try + { + List<ColumnModel> modelList = new List<ColumnModel>(); + int rowsCount = dt.Rows.Count; + if (rowsCount > 0) + { + ColumnModel model; + for (int n = 0; n < rowsCount; n++) + { + model = new ColumnModel(); + //if (dt.Rows[n]["Precision"]!=null && dt.Rows[n]["Precision"].ToString() != "") + //{ + // model.Precision = int.Parse(dt.Rows[n]["Precision"].ToString()); + //} + //if (dt.Rows[n]["Scale"].ToString() != "") + //{ + // model.Scale = int.Parse(dt.Rows[n]["Scale"].ToString()); + //} + model.ColumnName = dt.Rows[n]["ColumnName"].ToString(); + model.DataLength = dt.Rows[n]["DataLength"].ToString(); + model.DataType = dt.Rows[n]["DataType"].ToString(); + + if (model.DataType.ToUpper() == "nvarchar".ToUpper()) + { + if (model.DataLength != "-1") + { + model.DataLength = ((int)Convert.ToInt32(model.DataLength) / 2).ToString(); + } + } + + model.Description = dt.Rows[n]["Description"].ToString(); + if (dt.Rows[n]["IsNullable"].ToString() != "") + { + if ((dt.Rows[n]["IsNullable"].ToString() == "1") || (dt.Rows[n]["IsNullable"].ToString().ToLower() == "true")) + { + model.IsNullable = true; + } + else + { + model.IsNullable = false; + } + } + if (dt.Rows[n]["IsPrimaryKey"].ToString() != "") + { + if ((dt.Rows[n]["IsPrimaryKey"].ToString() == "1") || (dt.Rows[n]["IsPrimaryKey"].ToString().ToLower() == "true")) + { + model.IsPrimaryKey = true; + } + else + { + model.IsPrimaryKey = false; + } + } + + modelList.Add(model); + } + } + return modelList; + } + catch (Exception) + { + + throw; + } + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/Default/SqlServerDataBaseServiceHandle.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/Default/SqlServerDataBaseServiceHandle.cs" new file mode 100644 index 0000000..8483fe7 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/DataBaseFactory/Default/SqlServerDataBaseServiceHandle.cs" @@ -0,0 +1,130 @@ +锘縰sing GenerateCode_GEBrilliantFactory; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_WeiBen_WMS.DataBaseFactory +{ + public class SqlServerDataBaseServiceHandle : DataBaseServiceHandle + { + public override List<ColumnModel> GetColumnList(string tableName, string connStr) + { + string strSql = @" select +col.name as ColumnName, +t.name as DataType, +ep.value as Description, +col.max_length as DataLength, +col.is_nullable as IsNullable, + +( + select top 1 ind.is_primary_key from sys.index_columns ic + left join sys.indexes ind + on ic.object_id=ind.object_id + and ic.index_id=ind.index_id + and ind.name like 'PK_%' + where ic.object_id=obj.object_id + and ic.column_id=col.column_id +) as IsPrimaryKey, +col.Precision, +col.Scale +from sys.objects obj +inner join sys.columns col +on obj.object_id=col.object_id +left join sys.types t +on t.user_type_id=col.user_type_id +left join sys.extended_properties ep +on ep.major_id=obj.object_id +and ep.minor_id=col.column_id +and ep.name='MS_Description' +where obj.name='" + tableName + "' "; + + + List<ColumnModel> columnList = new List<ColumnModel>(); + try + { + DataSet ds = SqlHelper.Query(connStr, strSql); + columnList = DataTableToList(ds.Tables[0]); + } + catch + { + throw; + } + finally + { + } + return columnList; + } + + public override List<ColumnModel> DataTableToList(DataTable dt) + { + try + { + List<ColumnModel> modelList = new List<ColumnModel>(); + int rowsCount = dt.Rows.Count; + if (rowsCount > 0) + { + ColumnModel model; + for (int n = 0; n < rowsCount; n++) + { + model = new ColumnModel(); + if (dt.Rows[n]["Precision"].ToString() != "") + { + model.Precision = int.Parse(dt.Rows[n]["Precision"].ToString()); + } + if (dt.Rows[n]["Scale"].ToString() != "") + { + model.Scale = int.Parse(dt.Rows[n]["Scale"].ToString()); + } + model.ColumnName = dt.Rows[n]["ColumnName"].ToString(); + model.DataLength = dt.Rows[n]["DataLength"].ToString(); + model.DataType = dt.Rows[n]["DataType"].ToString(); + + if (model.DataType.ToUpper() == "nvarchar".ToUpper()) + { + if (model.DataLength != "-1") + { + model.DataLength = ((int)Convert.ToInt32(model.DataLength) / 2).ToString(); + } + } + + model.Description = dt.Rows[n]["Description"].ToString(); + if (dt.Rows[n]["IsNullable"].ToString() != "") + { + if ((dt.Rows[n]["IsNullable"].ToString() == "1") || (dt.Rows[n]["IsNullable"].ToString().ToLower() == "true")) + { + model.IsNullable = true; + } + else + { + model.IsNullable = false; + } + } + if (dt.Rows[n]["IsPrimaryKey"].ToString() != "") + { + if ((dt.Rows[n]["IsPrimaryKey"].ToString() == "1") || (dt.Rows[n]["IsPrimaryKey"].ToString().ToLower() == "true")) + { + model.IsPrimaryKey = true; + } + else + { + model.IsPrimaryKey = false; + } + } + + modelList.Add(model); + } + } + return modelList; + } + catch (Exception) + { + + throw; + } + } + + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/BLL_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/BLL_Generate.cs" new file mode 100644 index 0000000..6f28036 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/BLL_Generate.cs" @@ -0,0 +1,38 @@ +锘� +using System.Collections.Generic; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鐢熸垚BLL + /// </summary> + public class BLL_Generate : BaseGenerate + { + public static string CreateBLLText(string filePrefixName, string TableName, string entityName, string Author, + string ChinaComment, string primaryKey, string primaryKeyDesc, string Modulelogo, string tableAlias, + string addEntityParam, + List<ColumnModel> columnNameList) + { + var str = TextHelper.ReadText(@"Templete\BLL妯℃澘.txt"); + + CommonReplace(ref str); + + str = str.Replace("$TableName$", TableName);//琛ㄥ悕 + str = str.Replace("$Author$", Author);//浣滆�� + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str = str.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + str = str.Replace("$EntityName$", entityName);//瀹炰綋绫诲悕 + + str = str.Replace("$FilePrefixName$", filePrefixName);//妯″潡鍚� + str = str.Replace("$Modulelogo$", Modulelogo);//妯″潡绠�鍐� + str = str.Replace("$PrimaryKey$", primaryKey);//涓婚敭 + str = str.Replace("$PrimaryKeyDesc$", primaryKeyDesc);//鎻忚堪 + str = str.Replace("$TableAlias$", tableAlias);//琛ㄥ埆鍚� + + str = str.Replace("$AddEntityParam$", addEntityParam); + + str = str.Replace("$ToSingleModel$", StructStrHelper.GetToModelStr(columnNameList));//鍔ㄦ�佺粰瀹炰綋绫昏祴鍊� + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/BaseGenerate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/BaseGenerate.cs" new file mode 100644 index 0000000..c517aa8 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/BaseGenerate.cs" @@ -0,0 +1,17 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_GEBrilliantFactory +{ + public class BaseGenerate + { + public static void CommonReplace(ref string str) + { + str = str.Replace("$ProjectNamePrefix$", MainForm.projectNamePrefix); + str = str.Replace("$DataBaseName$", MainForm.dataBaseName); + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Controller/Controller_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Controller/Controller_Generate.cs" new file mode 100644 index 0000000..3889b30 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Controller/Controller_Generate.cs" @@ -0,0 +1,36 @@ +锘� + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鐢熸垚Controller绫� + /// </summary> + public class Controller_Generate : BaseGenerate + { + public static string CreateText(string Modulelogo, + string ChinaComment, List<ColumnModel> columnNameList, string entityName, string orderByName = "") + { + var str = TextHelper.ReadText(@"Templete\Controller妯℃澘.txt"); + CommonReplace(ref str); + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str = str.Replace("$EntityName$", entityName); + str = str.Replace("$Modulelogo$", Modulelogo);//妯″潡绠�鍐� + str = str.Replace("$OrderByName$", orderByName == "" ? "Id" : orderByName);//妯″潡绠�鍐� + + str = str.Replace("$ValidateEmptyForInsert$", StructStrHelper.GetValidateEmptyStrForController(columnNameList)); + str = str.Replace("$ValidateEmptyForUpdate$", StructStrHelper.GetValidateEmptyStrForController(columnNameList, false)); + + + + var pageStr = StructStrHelper.GetPageFilterStrForController(columnNameList); + str = str.Replace("$PageSearchFilter$", pageStr); + + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/DAL_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/DAL_Generate.cs" new file mode 100644 index 0000000..7ba7605 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/DAL_Generate.cs" @@ -0,0 +1,52 @@ +锘� + +using System.Collections.Generic; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鐢熸垚DAL + /// </summary> + public class DAL_Generate : BaseGenerate + { + public static string CreateDALText(string filePrefixName, string TableName, string entityName, string Author, + string ChinaComment, string primaryKey, string primaryKeyDesc, string Modulelogo,string tableAlias, + List<ColumnModel> columnNameList) + { + + var str = TextHelper.ReadText(@"Templete\DAL妯℃澘.txt"); + + CommonReplace(ref str); + + //瀛樺偍杩囩▼鍚� + ProcName procName = CommonHelper.GetProcName(Modulelogo); + str = str.Replace("$AddProcName$", procName.AddProc); + str = str.Replace("$UpdateProcName$", procName.UpdateProc); + str = str.Replace("$GetSingleProcName$", procName.GetSingleProc); + str = str.Replace("$GetListProcName$", procName.ListProc); + str = str.Replace("$GetPageListProcName$", procName.PageListProc); + + + + str = str.Replace("$TableName$", TableName);//琛ㄥ悕 + str = str.Replace("$Author$", Author);//浣滆�� + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str = str.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + str = str.Replace("$EntityName$", entityName);//瀹炰綋绫诲悕 + str = str.Replace("$TableAlias$", tableAlias);//琛ㄥ埆鍚� + + str = str.Replace("$FilePrefixName$", filePrefixName);//妯″潡鍚� + str = str.Replace("$Modulelogo$", Modulelogo);//妯″潡绠�鍐� + str = str.Replace("$PrimaryKey$", primaryKey);//涓婚敭 + str = str.Replace("$PrimaryKeyDesc$", primaryKeyDesc);//涓婚敭鎻忚堪 + + + + str = str.Replace("$ToSingleModel$", StructStrHelper.GetToModelStr(columnNameList));//鍔ㄦ�佺粰瀹炰綋绫昏祴鍊� + str = str.Replace("$AddSqlParameter$", StructStrHelper.GetParameterForAddDAL(columnNameList)); + str = str.Replace("$UpdateSqlParameter$", StructStrHelper.GetParameterForUpdateDAL(columnNameList)); + str = str.Replace("$QueryPageSqlParameter$", StructStrHelper.GetParameterForQueryPageDAL(columnNameList)); + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/AddModel_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/AddModel_Generate.cs" new file mode 100644 index 0000000..b262358 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/AddModel_Generate.cs" @@ -0,0 +1,35 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鐢熸垚鏂板鍙傛暟瀹炰綋绫� + /// </summary> + public class AddModel_Generate : BaseGenerate + { + public static string CreateAddModelLText(string addEntityParam, + string ChinaComment, List<ColumnModel> columnNameList) + { + //var str = TextHelper.ReadText(@"Templete\Entity\AddModel妯℃澘.txt"); + var str = TextHelper.ReadText(@"Templete\Entity\InputModel妯℃澘.txt"); + CommonReplace(ref str); + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + + str = str.Replace("$AddEntityParam$", addEntityParam); + + string attrString = ""; + + List<ColumnModel> newColumnNameList = ListHelper.RemoveIdCreatorModifier(columnNameList); + for (int i = 0; i < newColumnNameList.Count; ++i) + { + attrString += StructStrHelper.GenerateAttributeForAddModel(newColumnNameList[i]); + } + str = str.Replace("$AddAttributes$", attrString); + + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/InputModel_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/InputModel_Generate.cs" new file mode 100644 index 0000000..d2e34cf --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/InputModel_Generate.cs" @@ -0,0 +1,49 @@ +锘� + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鐢熸垚鏌ヨ瀹炰綋绫� + /// </summary> + public class InputModel_Generate : BaseGenerate + { + public static string CreateQueryModelLText(string Modulelogo, + string ChinaComment, List<ColumnModel> columnNameList, string entityName) + { + var str = TextHelper.ReadText(@"Templete\Entity\InputModel妯℃澘.txt"); + CommonReplace(ref str); + + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str = str.Replace("$EntityName$", entityName); + + str = str.Replace("$Modulelogo$", Modulelogo);//妯″潡绠�鍐� + + //澶勭悊 鍒嗛〉鏌ヨ閮ㄥ垎 + string attrString = ""; + + List<ColumnModel> newColumnNameList = ListHelper.OnlyRemoveId(columnNameList); + for (int i = 0; i < newColumnNameList.Count; ++i) + { + attrString += StructStrHelper.GenerateAttributeForQueryModel(newColumnNameList[i]); + attrString += StructStrHelper.GenerateAttributeForQueryModelMode(newColumnNameList[i]); + } + str = str.Replace("$QueryAttributes$", attrString); + + //澶勭悊 鏂板閮ㄥ垎 + attrString = ""; + newColumnNameList = ListHelper.RemoveIdCreatorModifier(columnNameList); + for (int i = 0; i < newColumnNameList.Count; ++i) + { + attrString += StructStrHelper.GenerateAttribute(i,newColumnNameList[i]); + } + str = str.Replace("$AddAttributes$", attrString); + + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/OutputModel_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/OutputModel_Generate.cs" new file mode 100644 index 0000000..25766c4 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Entity/OutputModel_Generate.cs" @@ -0,0 +1,47 @@ +锘� + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 杈撳嚭鍙傛暟- 鐢熸垚鏌ヨ瀹炰綋绫� + /// </summary> + public class OutputModel_Generate : BaseGenerate + { + public static string CreateQueryModelLText(string Modulelogo, + string ChinaComment, List<ColumnModel> columnNameList, string entityName) + { + var str = TextHelper.ReadText(@"Templete\Entity\OutputModel妯℃澘.txt"); + CommonReplace(ref str); + + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str = str.Replace("$EntityName$", entityName); + + str = str.Replace("$Modulelogo$", Modulelogo);//妯″潡绠�鍐� + + //澶勭悊 鍒嗛〉鏌ヨ杩斿洖閮ㄥ垎 + string attrString = ""; + List<ColumnModel> newColumnNameList = ListHelper.RemoveCreatedTimeUpdatedTimeCreatedUserIdCreatedUserNameUpdatedUserIdUpdatedUserName(columnNameList); + for (int i = 0; i < newColumnNameList.Count; ++i) + { + attrString += StructStrHelper.GenerateAttribute(i, newColumnNameList[i]); + } + str = str.Replace("$QueryOutputAttributes$", attrString); + + //澶勭悊 瀵煎嚭杩斿洖閮ㄥ垎 + attrString = ""; + newColumnNameList = ListHelper.RemoveIdCreateIdModifyIdDelFlag(columnNameList); + for (int i = 0; i < newColumnNameList.Count; ++i) + { + attrString += StructStrHelper.GenerateAttribute(i, newColumnNameList[i], true); + } + str = str.Replace("$ExportOutputAttributes$", attrString); + + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/InsertSQL_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/InsertSQL_Generate.cs" new file mode 100644 index 0000000..7e06b97 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/InsertSQL_Generate.cs" @@ -0,0 +1,71 @@ +锘� + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// InsertSQL鏂囦欢鐢熸垚 + /// </summary> + public class InsertSQL_Generate : BaseGenerate + { + /// <summary> + /// 鐢熸垚InsertSQL + /// </summary> + /// <param name="TableName"></param> + /// <param name="Author"></param> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static string CreateInsertSQLText(string TableName, string Author, string ChinaComment, + List<ColumnModel> columnNameList) + { + try + { + StringBuilder sbText = new StringBuilder(); + + sbText.Append(GetInsertSQLStr(TableName, Author,ChinaComment, columnNameList)); + + return sbText.ToString(); + } + catch (Exception) + { + throw; + } + } + + + + /// <summary> + /// 鐢熸垚InsertSQL + /// </summary> + /// <param name="TableName"></param> + /// <param name="Author"></param> + /// <param name="columnNameList"></param> + /// <returns></returns> + private static string GetInsertSQLStr(string TableName, string Author, string ChinaComment, List<ColumnModel> columnNameList) + { + var str = TextHelper.ReadText(@"Templete\InitSQL妯℃澘.txt"); + + CommonReplace(ref str); + + str = str.Replace("$TableName$", TableName);//琛ㄥ悕 + str = str.Replace("$Author$", Author);//浣滆�� + str = str.Replace("$TableName$", TableName);//琛ㄥ悕 + str = str.Replace("$Author$", Author);//浣滆�� + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + + str = str.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + + + string str_insert_cols = StructStrHelper.GetColumnsStrNoIDForAdd(columnNameList, ""); + str = str.Replace("$insert_cols$", str_insert_cols); + str = str.Replace("$insert_cols_values$", StructStrHelper.GetColumnsStrNoIDForInsertSQL(columnNameList)); + + return str; + } + + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Model_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Model_Generate.cs" new file mode 100644 index 0000000..2630730 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Model_Generate.cs" @@ -0,0 +1,115 @@ +锘� + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + public class Model_Generate : BaseGenerate + { + + /// <summary> + /// 鍒涘缓瀹炰綋绫� + /// </summary> + /// <param name="tableName">琛ㄥ悕</param> + /// <param name="columnNameList"></param> + /// <param name="filePrefixName">鏂囦欢鍓嶇紑鍚�</param> + /// <param name="nameSpacePath">绫诲懡鍚嶇┖闂�</param> + /// <param name="createPerson">鍒涘缓浜�</param> + /// <param name="chinaComment">涓枃娉ㄩ噴</param> + /// <param name="entityName">瀹炰綋绫诲悕</param> + /// <returns></returns> + public static string GenerateModel(string tableName, List<ColumnModel> columnNameList, string filePrefixName, string nameSpacePath, + string createPerson, string chinaComment, string entityName + ) + { + string header = "using System;\n" + + "using System.Runtime.Serialization; \n" + + " \n" + + "namespace WIP_Models \n" + + "{\n" + + " /// <summary>\n" + + " /// " + chinaComment + "瀹炰綋绫籠n" + + " /// </summary>\n" + + " [DataContract]\n" + + " public class $entityName$ \n" + + " {\n\n"; + int columnCount = columnNameList.Count; + string attrString = ""; + for (int i = 0; i < columnCount; ++i) + { + attrString += StructStrHelper.GenerateAttribute(i, columnNameList[i]); + } + string footer = " }\n" + + "}"; + + string modelContent = header + attrString + footer; + modelContent = modelContent.Replace( + "$NowTimeStr$", DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + + " " + + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);//鍒涘缓鏃堕棿 + modelContent = modelContent.Replace("$CreatePerson$", createPerson);//鍒涘缓浜� + modelContent = modelContent.Replace("$nameSpacePath$", nameSpacePath);//鍛藉悕绌洪棿 + modelContent = modelContent.Replace("$entityName$", entityName);//瀹炰綋绫诲悕 + + CommonReplace(ref modelContent); + + return modelContent; + + } + + + /// <summary> + /// 鍒涘缓瀹炰綋绫� + /// </summary> + /// <param name="tableName">琛ㄥ悕</param> + /// <param name="columnNameList"></param> + /// <param name="filePrefixName">鏂囦欢鍓嶇紑鍚�</param> + /// <param name="nameSpacePath">绫诲懡鍚嶇┖闂�</param> + /// <param name="createPerson">鍒涘缓浜�</param> + /// <param name="chinaComment">涓枃娉ㄩ噴</param> + /// <param name="entityName">瀹炰綋绫诲悕</param> + /// <returns></returns> + public static string GenerateModelParam(string tableName, List<ColumnModel> columnNameList, string filePrefixName, string nameSpacePath, + string createPerson, string chinaComment, string entityName + ) + { + string header = "using System;\n" + + "using System.Runtime.Serialization; \n" + + " \n" + + "namespace " + MainForm.projectNamePrefix + ".Core.Model.ParamModels \n" + + "{\n" + + " /// <summary>\n" + + " /// " + chinaComment + "瀹炰綋绫籠n" + + " /// </summary>\n" + + " public class $entityName$Param : PageParam \n" + + " {\n\n"; + int columnCount = columnNameList.Count; + string attrString = ""; + for (int i = 0; i < columnCount; ++i) + { + attrString += StructStrHelper.GenerateAttribute(i, columnNameList[i]); + } + string footer = " }\n" + + "}"; + + string modelContent = header + attrString + footer; + modelContent = modelContent.Replace( + "$NowTimeStr$", DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + + " " + + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);//鍒涘缓鏃堕棿 + modelContent = modelContent.Replace("$CreatePerson$", createPerson);//鍒涘缓浜� + modelContent = modelContent.Replace("$nameSpacePath$", nameSpacePath);//鍛藉悕绌洪棿 + modelContent = modelContent.Replace("$entityName$", entityName);//瀹炰綋绫诲悕 + + CommonReplace(ref modelContent); + + return modelContent; + + } + + + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Procedure_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Procedure_Generate.cs" new file mode 100644 index 0000000..7bf29f5 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Procedure_Generate.cs" @@ -0,0 +1,272 @@ +锘� + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 瀛樺偍杩囩▼鏂囦欢鐢熸垚 + /// </summary> + public class Procedure_Generate : BaseGenerate + { + /// <summary> + /// 鐢熸垚瀛樺偍杩囩▼鏂囦欢 + /// </summary> + /// <param name="TableName"></param> + /// <param name="TableAlias"></param> + /// <param name="Author"></param> + /// <param name="ChinaComment"></param> + /// <param name="PimaryKey"></param> + /// <param name="filePrefixName"></param> + /// <param name="orderByName"></param> + /// <param name="Modulelogo">妯″潡绠�鍐�</param> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static string CreateProcText(string TableName, string TableAlias, string Author, + string ChinaComment, string PimaryKey, string filePrefixName, string orderByName, string Modulelogo, + List<ColumnModel> columnNameList) + { + try + { + StringBuilder sbText = new StringBuilder(); + + var str_query_1 = StructStrHelper.GetQueryColumnsStr(columnNameList); + var str_query_2 = StructStrHelper.GetQueryColumnsStr(columnNameList, TableAlias);//甯﹀墠缂� + + //1銆佸垎椤靛瓨鍌ㄨ繃绋� + + sbText.Append(GetPageProcStr(columnNameList,TableName, TableAlias, Author, ChinaComment, str_query_1, str_query_2, filePrefixName)); + sbText.Append("\n\n"); + + //2銆佸垪琛ㄥ瓨鍌ㄨ繃绋� + + sbText.Append(GetListProcStr(TableName, TableAlias, Author, ChinaComment, str_query_2, filePrefixName, orderByName)); + sbText.Append("\n\n"); + + //2銆佸緱鍒颁竴涓疄浣撳瓨鍌ㄨ繃绋� + sbText.Append(GetSingleObjectProcStr(TableName, TableAlias, Author, ChinaComment, str_query_2, PimaryKey, filePrefixName, columnNameList)); + sbText.Append("\n\n"); + + //3銆佸鍔犱竴鏉¤褰曞瓨鍌ㄨ繃绋� + sbText.Append(GetAddProcStr(TableName, TableAlias, Author, ChinaComment,filePrefixName, columnNameList)); + sbText.Append("\n\n"); + + //4銆佹洿鏂颁竴鏉¤褰曞瓨鍌ㄨ繃绋� + sbText.Append(GetUpdateProcStr(TableName, TableAlias, Author, ChinaComment, PimaryKey, filePrefixName, columnNameList)); + sbText.Append("\n\n"); + + //5銆佹洿鏂颁竴鏉¤褰曞瓨鍌ㄨ繃绋�2 + sbText.Append(GetUpdateProcStr2(TableName, TableAlias, Author, ChinaComment, PimaryKey, filePrefixName, columnNameList)); + sbText.Append("\n\n"); + + + //瀛樺偍杩囩▼鍚� + ProcName procName = CommonHelper.GetProcName(Modulelogo); + sbText = sbText.Replace("$AddProcName$", procName.AddProc); + sbText = sbText.Replace("$UpdateProcName$", procName.UpdateProc); + sbText = sbText.Replace("$GetSingleProcName$", procName.GetSingleProc); + sbText = sbText.Replace("$GetListProcName$", procName.ListProc); + sbText = sbText.Replace("$GetPageListProcName$", procName.PageListProc); + + + + return sbText.ToString(); + } + catch (Exception) + { + throw; + } + } + + /// <summary> + /// 鍒嗛〉瀛樺偍杩囩▼ + /// </summary> + /// <param name="TableName"></param> + /// <param name="TableAlias"></param> + /// <param name="Author"></param> + /// <param name="ChinaComment"></param> + /// <param name="str_query_1"></param> + /// <param name="str_query_2"></param> + /// <returns></returns> + private static string GetPageProcStr(List<ColumnModel> columnNameList,string TableName, string TableAlias, string Author, string ChinaComment, + string str_query_1, string str_query_2, string filePrefixName) + { + var str_page_proc = TextHelper.ReadText(@"Templete\proc\鍒嗛〉瀛樺偍杩囩▼.txt"); + + str_page_proc = str_page_proc.Replace("$ProcName$", filePrefixName + "_GetPageList");//瀛樺偍杩囩▼鍚� + str_page_proc = str_page_proc.Replace("$TableName$", TableName);//琛ㄥ悕 + str_page_proc = str_page_proc.Replace("$TableAlias$", TableAlias);//鍒悕 + str_page_proc = str_page_proc.Replace("$Author$", Author);//浣滆�� + str_page_proc = str_page_proc.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str_page_proc = str_page_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + + + str_page_proc = str_page_proc.Replace("$page_cols_params$", StructStrHelper.GetInputParamColumnsStrForQueryPage(columnNameList)); + str_page_proc = str_page_proc.Replace("$where_cols_params$", StructStrHelper.GetCols_AssignmentStrForWherePage(TableAlias, columnNameList)); + + str_page_proc = str_page_proc.Replace("$strQueryCol_1$", str_query_1); + str_page_proc = str_page_proc.Replace("$strQueryCol_2$", str_query_2); + return str_page_proc; + } + + /// <summary> + /// 鍒楄〃瀛樺偍杩囩▼(涓嶅垎椤�) + /// </summary> + /// <param name="TableName"></param> + /// <param name="TableAlias"></param> + /// <param name="Author"></param> + /// <param name="ChinaComment"></param> + /// <param name="str_query"></param> + /// <returns></returns> + private static string GetListProcStr(string TableName, string TableAlias, string Author, string ChinaComment, + string str_query, string filePrefixName, string orderByName) + { + var str_list_proc = TextHelper.ReadText(@"Templete\proc\鍒楄〃瀛樺偍杩囩▼.txt"); + + str_list_proc = str_list_proc.Replace("$ProcName$", filePrefixName + "_GetList");//瀛樺偍杩囩▼鍚� + str_list_proc = str_list_proc.Replace("$TableName$", TableName);//琛ㄥ悕 + str_list_proc = str_list_proc.Replace("$TableAlias$", TableAlias);//鍒悕 + str_list_proc = str_list_proc.Replace("$Author$", Author);//浣滆�� + str_list_proc = str_list_proc.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str_list_proc = str_list_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + + str_list_proc = str_list_proc.Replace("$strQueryCol$", str_query); + str_list_proc = str_list_proc.Replace("$orderByName$", orderByName); + return str_list_proc; + } + + /// <summary> + /// 寰楀埌涓�涓疄浣撳瓨鍌ㄨ繃绋� + /// </summary> + /// <param name="TableName"></param> + /// <param name="TableAlias"></param> + /// <param name="Author"></param> + /// <param name="ChinaComment"></param> + /// <param name="str_query_2"></param> + /// <param name="PimaryKey"></param> + /// <param name="columnNameList"></param> + /// <returns></returns> + private static string GetSingleObjectProcStr(string TableName, string TableAlias, string Author, string ChinaComment, + string str_query_2, string PimaryKey, string filePrefixName, List<ColumnModel> columnNameList) + { + try + { + var str_single_proc = TextHelper.ReadText(@"Templete\proc\寰楀埌涓�涓疄浣撳瓨鍌ㄨ繃绋�.txt"); + + str_single_proc = str_single_proc.Replace("$ProcName$", filePrefixName + "_GetModel");//瀛樺偍杩囩▼鍚� + str_single_proc = str_single_proc.Replace("$TableName$", TableName);//琛ㄥ悕 + str_single_proc = str_single_proc.Replace("$TableAlias$", TableAlias);//鍒悕 + str_single_proc = str_single_proc.Replace("$Author$", Author);//浣滆�� + str_single_proc = str_single_proc.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str_single_proc = str_single_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + + str_single_proc = str_single_proc.Replace("$Primary$", PimaryKey); + str_single_proc = str_single_proc.Replace("$strQueryCol$", str_query_2); + var columnModel = StructStrHelper.GetColumnModelByName(PimaryKey, columnNameList); + if (columnModel == null) + throw new Exception("娌℃湁鎵惧埌鐩稿簲鐨勪富閿�硷紒"); + if (columnModel.DataType.ToUpper() == "INT" || columnModel.DataType.ToUpper() == "BIGINT") + { + str_single_proc = str_single_proc.Replace("$DataType$", columnModel.DataType); + } + else + { + str_single_proc = str_single_proc.Replace("$DataType$", columnModel.DataType + "(" + columnModel.DataLength + ")"); + } + + return str_single_proc; + } + catch (Exception) + { + + throw; + } + + } + + /// <summary> + /// 澧炲姞涓�鏉¤褰曞瓨鍌ㄨ繃绋� + /// </summary> + /// <param name="TableName"></param> + /// <param name="TableAlias"></param> + /// <param name="Author"></param> + /// <param name="ChinaComment"></param> + /// <param name="str_query_2"></param> + /// <param name="PimaryKey"></param> + /// <param name="columnNameList"></param> + /// <returns></returns> + private static string GetAddProcStr(string TableName, string TableAlias, string Author, string ChinaComment, + string filePrefixName, List<ColumnModel> columnNameList) + { + var str_proc = TextHelper.ReadText(@"Templete\proc\澧炲姞涓�鏉¤褰曞瓨鍌ㄨ繃绋�.txt"); + + str_proc = str_proc.Replace("$ProcName$", filePrefixName + "_ADD");//瀛樺偍杩囩▼鍚� + str_proc = str_proc.Replace("$TableName$", TableName);//琛ㄥ悕 + str_proc = str_proc.Replace("$TableAlias$", TableAlias);//鍒悕 + str_proc = str_proc.Replace("$Author$", Author);//浣滆�� + str_proc = str_proc.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str_proc = str_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + + + string str_insert_cols = StructStrHelper.GetColumnsStrNoIDForAdd(columnNameList, ""); + str_proc = str_proc.Replace("$insert_cols$", str_insert_cols); + str_proc = str_proc.Replace("$insert_cols_values$", StructStrHelper.GetColumnsStrNoIDForAdd(columnNameList, "@")); + str_proc = str_proc.Replace("$insert_cols_params$", StructStrHelper.GetInputParamColumnsStrForAdd(columnNameList)); + + return str_proc; + } + + /// <summary> + /// 缂栬緫涓�鏉¤褰曞瓨鍌ㄨ繃绋� + /// </summary> + /// <param name="TableName"></param> + /// <param name="TableAlias"></param> + /// <param name="Author"></param> + /// <param name="ChinaComment"></param> + /// <param name="PimaryKey"></param> + /// <param name="columnNameList"></param> + /// <returns></returns> + private static string GetUpdateProcStr(string TableName, string TableAlias, string Author, string ChinaComment, + string PimaryKey, string filePrefixName, List<ColumnModel> columnNameList) + { + var str_proc = TextHelper.ReadText(@"Templete\proc\淇敼涓�鏉¤褰曞瓨鍌ㄨ繃绋�.txt"); + + str_proc = str_proc.Replace("$ProcName$", filePrefixName + "_Update");//瀛樺偍杩囩▼鍚� + str_proc = str_proc.Replace("$TableName$", TableName);//琛ㄥ悕 + str_proc = str_proc.Replace("$TableAlias$", TableAlias);//鍒悕 + str_proc = str_proc.Replace("$Author$", Author);//浣滆�� + str_proc = str_proc.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str_proc = str_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + + str_proc = str_proc.Replace("$Primary$", PimaryKey); + + str_proc = str_proc.Replace("$update_cols_params$", StructStrHelper.GetInputParamColumnsStrForUpdate(columnNameList)); + str_proc = str_proc.Replace("$update_cols_assignment$", StructStrHelper.GetCols_AssignmentStrForUpdate(columnNameList)); + + return str_proc; + } + + private static string GetUpdateProcStr2(string TableName, string TableAlias, string Author, string ChinaComment, + string PimaryKey, string filePrefixName, List<ColumnModel> columnNameList) + { + var str_proc = TextHelper.ReadText(@"Templete\proc\淇敼涓�鏉¤褰曞瓨鍌ㄨ繃绋�2.txt"); + + str_proc = str_proc.Replace("$ProcName$", filePrefixName + "_Update");//瀛樺偍杩囩▼鍚� + str_proc = str_proc.Replace("$TableName$", TableName);//琛ㄥ悕 + str_proc = str_proc.Replace("$TableAlias$", TableAlias);//鍒悕 + str_proc = str_proc.Replace("$Author$", Author);//浣滆�� + str_proc = str_proc.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str_proc = str_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//褰撳墠鏃堕棿 + + str_proc = str_proc.Replace("$Primary$", PimaryKey); + + str_proc = str_proc.Replace("$update_cols_params$", StructStrHelper.GetInputParamColumnsStrForUpdate(columnNameList)); + str_proc = str_proc.Replace("$update_cols_assignment2$", StructStrHelper.GetCols_AssignmentStrForUpdate2(columnNameList)); + + return str_proc; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Services_InterfaceRealize_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Services_InterfaceRealize_Generate.cs" new file mode 100644 index 0000000..59fe858 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Services_InterfaceRealize_Generate.cs" @@ -0,0 +1,43 @@ +锘� + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鐢熸垚Services鐨勬帴鍙e疄鐜版枃浠� + /// </summary> + public class Services_InterfaceRealize_Generate : BaseGenerate + { + public static string CreateText(string Wcf_NameSpacePath, string Modulelogo, string entityName, + string ChinaComment, string filePrefixName, string primaryKey, string TableAlias, string addEntityParam, + List<ColumnModel> columnList,string groupName) + { + var str = TextHelper.ReadText(@"Templete\Services鎺ュ彛瀹炵幇妯℃澘.txt"); + + str = str.Replace("$ValidateEmptyStrForPrimaryKey$", StructStrHelper.GetValidateEmptyStrForPrimaryKey(columnList, primaryKey)); + str = str.Replace("$Wcf_NameSpacePath$", Wcf_NameSpacePath);//WCF椤圭洰鐨勫懡鍚嶇┖闂� + str = str.Replace("$GroupName$", groupName);//鍒嗙粍鍚� + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str = str.Replace("$EntityName$", entityName);//瀹炰綋绫诲悕 + str = str.Replace("$EntityName_FirstLetterLower$", CommonHelper.FirstLowercase(entityName));//棣栧瓧姣嶅皬鍐欙紝灞�閮ㄥ彉閲忓悕 + str = str.Replace("$Modulelogo$", Modulelogo);//妯″潡绠�鍐� + str = str.Replace("$FilePrefixName$", filePrefixName);//妯″潡鍚� + str = str.Replace("$PrimaryKey$", primaryKey);//涓婚敭鍚� + + str = str.Replace("$ValidateEmptyForInsert$", StructStrHelper.GetValidateEmptyStr(columnList)); + str = str.Replace("$ValidateEmptyForUpdate$", StructStrHelper.GetValidateEmptyStr(columnList, false)); + str = str.Replace("$WhereQuery$", StructStrHelper.GetStrForWhereQuery(columnList)); + str = str.Replace("$AddEntityParam$", addEntityParam); + + str = str.Replace("$TableAlias$", TableAlias);//琛ㄥ埆鍚� + + CommonReplace(ref str); + + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Services_Interface_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Services_Interface_Generate.cs" new file mode 100644 index 0000000..f21fe0e --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/Services_Interface_Generate.cs" @@ -0,0 +1,30 @@ +锘� +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鐢熸垚Services鐨勬帴鍙f枃浠� + /// </summary> + public class Services_Interface_Generate : BaseGenerate + { + public static string CreateText(string Wcf_NameSpacePath, string Modulelogo, string entityName, + string ChinaComment, string addEntityParam) + { + var str = TextHelper.ReadText(@"Templete\Services鎺ュ彛妯℃澘.txt"); + + str = str.Replace("$Wcf_NameSpacePath$", Wcf_NameSpacePath);//WCF椤圭洰鐨勫懡鍚嶇┖闂� + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str = str.Replace("$EntityName$", entityName);//瀹炰綋绫诲悕 + str = str.Replace("$Modulelogo$", Modulelogo);//妯″潡绠�鍐� + str = str.Replace("$AddEntityParam$", addEntityParam); + + CommonReplace(ref str); + + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/VUE/VUE_FunConfig_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/VUE/VUE_FunConfig_Generate.cs" new file mode 100644 index 0000000..7cbd067 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/VUE/VUE_FunConfig_Generate.cs" @@ -0,0 +1,35 @@ +锘� +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// VUE鏂规硶閰嶇疆 + /// </summary> + public class VUE_FunConfig_Generate : BaseGenerate + { + /// <summary> + /// VUE鏂规硶閰嶇疆 + /// </summary> + /// <param name="Modulelogo">妯″潡绠�鍐�</param> + /// <param name="ChinaComment">涓枃娉ㄩ噴</param> + /// <param name="routePrefix">WCF璺敱鍓嶇紑</param> + /// <returns></returns> + public static string CreateText(string Modulelogo, + string ChinaComment, string routePrefix,string entityName) + { + var str = TextHelper.ReadText(@"Templete\VUE\VUE鏂规硶閰嶇疆.txt"); + CommonReplace(ref str); + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + str = str.Replace("$Modulelogo$", Modulelogo);//妯″潡绠�鍐� + str = str.Replace("$RoutePrefix$", routePrefix);//妯″潡绠�鍐� + str = str.Replace("$EntityName$", entityName);//妯″潡绠�鍐� + + + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/VUE/VUE_Generate.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/VUE/VUE_Generate.cs" new file mode 100644 index 0000000..48b0dd8 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Generate/VUE/VUE_Generate.cs" @@ -0,0 +1,58 @@ +锘� + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// VUE鏂囦欢 + /// </summary> + public class VUE_Generate : BaseGenerate + { + public static string CreateText(string TableAlias, string modulelogo, string primaryKey, + List<ColumnModel> columnNameList, string ChinaComment + , string emport_templeteFileDownName, string emport_excelCategroy) + { + var str = TextHelper.ReadText(@"Templete\VUE\VUE鏂囦欢妯℃澘.txt"); + + CommonReplace(ref str); + str = str.Replace("$el-table-column$", StructStrHelper.GetElTableColumnStr(columnNameList));//鍒楄〃椤� + + //鏂板/缂栬緫鐣岄潰 + str = str.Replace("$el-item$", StructStrHelper.GetElFormItemStrForAddEditForm(columnNameList)); + + //鏌ョ湅鐣岄潰 + str = str.Replace("$el-item-view$", StructStrHelper.GetElFormItemStrForViewForm(columnNameList)); + + str = str.Replace("$el-form-itemForSearch$", StructStrHelper.GetElFormItemForSearchStr(columnNameList)); + + //瀵煎嚭瀛楃涓� + str = str.Replace("$VueExportColumnHeaderStr$", StructStrHelper.GetVueExportTHeaderArrayStr(columnNameList)); + + + //鍏叡鏌ヨ鐨勫垪 + var SearchFormInputPlaceholderNameStr = ""; + str = str.Replace("$SearchFormInputPlaceholderStr$", StructStrHelper.GetVueSearchFormInputPlaceholderStr(columnNameList, ref SearchFormInputPlaceholderNameStr)); + str = str.Replace("$SearchFormInputPlaceholderNameStr$", SearchFormInputPlaceholderNameStr); + + //楂樼骇鏌ヨ + str = str.Replace("$FormOptionsStr$", StructStrHelper.GetVueFormOptionsStr(columnNameList)); + + str = str.Replace("$ChinaComment$", ChinaComment);//涓枃娉ㄩ噴 + + + str = str.Replace("$Modulelogo$", modulelogo);//琛ㄥ埆鍚�(浠栦竴瀹氳鍦ㄦ渶鍚庢浛鎹�) + str = str.Replace("$TableAlias$", TableAlias);//琛ㄥ埆鍚�(浠栦竴瀹氳鍦ㄦ渶鍚庢浛鎹�) + str = str.Replace("$PrimaryKey$", primaryKey);//涓婚敭 + + //鏇挎崲瀵煎叆鍔熻兘 + str = str.Replace("$emport_templeteFileDownName$", emport_templeteFileDownName); + str = str.Replace("$emport_excelCategroy$", emport_excelCategroy); + + return str; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" new file mode 100644 index 0000000..d226dfc --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.csproj" @@ -0,0 +1,246 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{004A790A-7F45-4D97-95E3-478FD73FB434}</ProjectGuid> + <OutputType>WinExe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>GenerateCode_WeiBen_WMS</RootNamespace> + <AssemblyName>GenerateCode_WeiBen_WMS</AssemblyName> + <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <PublishUrl>publish\</PublishUrl> + <Install>true</Install> + <InstallFrom>Disk</InstallFrom> + <UpdateEnabled>false</UpdateEnabled> + <UpdateMode>Foreground</UpdateMode> + <UpdateInterval>7</UpdateInterval> + <UpdateIntervalUnits>Days</UpdateIntervalUnits> + <UpdatePeriodically>false</UpdatePeriodically> + <UpdateRequired>false</UpdateRequired> + <MapFileExtensions>true</MapFileExtensions> + <ApplicationRevision>0</ApplicationRevision> + <ApplicationVersion>1.0.0.%2a</ApplicationVersion> + <IsWebBootstrapper>false</IsWebBootstrapper> + <UseApplicationTrust>false</UseApplicationTrust> + <BootstrapperEnabled>true</BootstrapperEnabled> + <TargetFrameworkProfile /> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> + <PlatformTarget>x86</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> + <PlatformTarget>x86</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup> + <ApplicationIcon>Robot.ico</ApplicationIcon> + </PropertyGroup> + <ItemGroup> + <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> + <HintPath>packages\Microsoft.Extensions.Logging.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath> + </Reference> + <Reference Include="MySqlConnector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d33d3e53aa5f8c92, processorArchitecture=MSIL"> + <HintPath>packages\MySqlConnector.2.4.0\lib\net48\MySqlConnector.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath> + </Reference> + <Reference Include="System.configuration" /> + <Reference Include="System.Core" /> + <Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath> + </Reference> + <Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath> + </Reference> + <Reference Include="System.Numerics" /> + <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> + </Reference> + <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> + <HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath> + </Reference> + <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> + <HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath> + </Reference> + <Reference Include="System.Transactions" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="System.Data" /> + <Reference Include="System.Deployment" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="DataBaseFactory\DataBaseServiceHandle.cs" /> + <Compile Include="DataBaseFactory\DataBaseServiceFactory.cs" /> + <Compile Include="DataBaseFactory\Default\SqlServerDataBaseServiceHandle.cs" /> + <Compile Include="DataBaseFactory\Default\MySqlDataBaseServiceHandle.cs" /> + <Compile Include="Generate\BaseGenerate.cs" /> + <Compile Include="Generate\Controller\Controller_Generate.cs" /> + <Compile Include="Generate\Entity\AddModel_Generate.cs" /> + <Compile Include="Generate\Entity\OutputModel_Generate.cs" /> + <Compile Include="Generate\InsertSQL_Generate.cs" /> + <Compile Include="Generate\VUE\VUE_Generate.cs" /> + <Compile Include="Generate\Services_InterfaceRealize_Generate.cs" /> + <Compile Include="Generate\VUE\VUE_FunConfig_Generate.cs" /> + <Compile Include="Generate\Services_Interface_Generate.cs" /> + <Compile Include="Generate\Entity\InputModel_Generate.cs" /> + <Compile Include="Generate\BLL_Generate.cs" /> + <Compile Include="Generate\DAL_Generate.cs" /> + <Compile Include="Generate\Procedure_Generate.cs" /> + <Compile Include="Model\Enum\DataBaseEnum.cs" /> + <Compile Include="Model\Enum\DataTypeEnum.cs" /> + <Compile Include="Model\ListItem.cs" /> + <Compile Include="Model\Proc.cs" /> + <Compile Include="Model\SystemCommonVar.cs" /> + <Compile Include="Utility\CommonHelper.cs" /> + <Compile Include="Model\ColumnModell.cs" /> + <Compile Include="Generate\Model_Generate.cs" /> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Utility\ListHelper.cs" /> + <Compile Include="Utility\MySqlHelper.cs" /> + <Compile Include="Utility\SQLHelper.cs" /> + <Compile Include="MainForm.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="MainForm.Designer.cs"> + <DependentUpon>MainForm.cs</DependentUpon> + </Compile> + <Compile Include="Utility\StructStrHelper.cs" /> + <Compile Include="Utility\TextHelper.cs" /> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + <SubType>Designer</SubType> + </EmbeddedResource> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Resources.resx</DependentUpon> + <DesignTime>True</DesignTime> + </Compile> + <EmbeddedResource Include="MainForm.resx"> + <DependentUpon>MainForm.cs</DependentUpon> + </EmbeddedResource> + <None Include="App.config" /> + <None Include="packages.config" /> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + </ItemGroup> + <ItemGroup> + <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> + <Install>false</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> + <Visible>False</Visible> + <ProductName>.NET Framework 3.5 SP1</ProductName> + <Install>true</Install> + </BootstrapperPackage> + <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> + <Visible>False</Visible> + <ProductName>Windows Installer 3.1</ProductName> + <Install>true</Install> + </BootstrapperPackage> + </ItemGroup> + <ItemGroup> + <Content Include="Robot.ico" /> + <Content Include="Templete\Controller妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Entity\AddModel妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Entity\OutputModel妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Proc\淇敼涓�鏉¤褰曞瓨鍌ㄨ繃绋�2.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Proc\淇敼涓�鏉¤褰曞瓨鍌ㄨ繃绋�.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Proc\鍒楄〃瀛樺偍杩囩▼.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Proc\澧炲姞涓�鏉¤褰曞瓨鍌ㄨ繃绋�.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\VUE\VUE鏂囦欢妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Services鎺ュ彛瀹炵幇妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\VUE\VUE鏂规硶閰嶇疆.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Services鎺ュ彛妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Entity\InputModel妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\BLL妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\DAL妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Proc\寰楀埌涓�涓疄浣撳瓨鍌ㄨ繃绋�.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\Proc\鍒嗛〉瀛樺偍杩囩▼.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + <Content Include="Templete\InitSQL妯℃澘.txt"> + <CopyToOutputDirectory>Always</CopyToOutputDirectory> + </Content> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.sln" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.sln" new file mode 100644 index 0000000..d7f6729 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/GenerateCode_WeiBen_CMS.sln" @@ -0,0 +1,29 @@ +锘� +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenerateCode_WeiBen_CMS", "GenerateCode_WeiBen_CMS.csproj", "{004A790A-7F45-4D97-95E3-478FD73FB434}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {004A790A-7F45-4D97-95E3-478FD73FB434}.Debug|Any CPU.ActiveCfg = Debug|x86 + {004A790A-7F45-4D97-95E3-478FD73FB434}.Debug|x86.ActiveCfg = Debug|x86 + {004A790A-7F45-4D97-95E3-478FD73FB434}.Debug|x86.Build.0 = Debug|x86 + {004A790A-7F45-4D97-95E3-478FD73FB434}.Release|Any CPU.ActiveCfg = Release|x86 + {004A790A-7F45-4D97-95E3-478FD73FB434}.Release|x86.ActiveCfg = Release|x86 + {004A790A-7F45-4D97-95E3-478FD73FB434}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5076F6A8-79EC-4DE9-82F3-7095D2B9E409} + EndGlobalSection +EndGlobal diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" new file mode 100644 index 0000000..4b815f1 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.Designer.cs" @@ -0,0 +1,594 @@ +锘縩amespace GenerateCode_GEBrilliantFactory +{ + partial class MainForm + { + /// <summary> + /// 蹇呴渶鐨勮璁″櫒鍙橀噺銆� + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// 娓呯悊鎵�鏈夋鍦ㄤ娇鐢ㄧ殑璧勬簮銆� + /// </summary> + /// <param name="disposing">濡傛灉搴旈噴鏀炬墭绠¤祫婧愶紝涓� true锛涘惁鍒欎负 false銆�</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 绐椾綋璁捐鍣ㄧ敓鎴愮殑浠g爜 + + /// <summary> + /// 璁捐鍣ㄦ敮鎸佹墍闇�鐨勬柟娉� - 涓嶈 + /// 浣跨敤浠g爜缂栬緫鍣ㄤ慨鏀规鏂规硶鐨勫唴瀹广�� + /// </summary> + private void InitializeComponent() + { + this.btnPath = new System.Windows.Forms.Button(); + this.lblds = new System.Windows.Forms.Label(); + this.tbPath = new System.Windows.Forms.TextBox(); + this.btnExit = new System.Windows.Forms.Button(); + this.btn_CreateFile = new System.Windows.Forms.Button(); + this.tb_TableName = new System.Windows.Forms.TextBox(); + this.tb_FileName = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.tb_WCF_NameSpacePath = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.tb_ChinaComment = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.tb_CreatePerson = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.tb_Primary = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.tb_EntityProName = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.tb_EntityName = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.tb_OrderBy = new System.Windows.Forms.TextBox(); + this.label10 = new System.Windows.Forms.Label(); + this.tb_PrimaryDesc = new System.Windows.Forms.TextBox(); + this.label11 = new System.Windows.Forms.Label(); + this.tb_Modulelogo = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.btn_InsertSql = new System.Windows.Forms.Button(); + this.tb_RoutePrefix = new System.Windows.Forms.TextBox(); + this.label13 = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.lbl_DataSource = new System.Windows.Forms.Label(); + this.cmb_DataSource = new System.Windows.Forms.ComboBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.tb_GroupName = new System.Windows.Forms.TextBox(); + this.label16 = new System.Windows.Forms.Label(); + this.label15 = new System.Windows.Forms.Label(); + this.tb_ProjectNamePrefix = new System.Windows.Forms.TextBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.tb_importExcelCategroy = new System.Windows.Forms.TextBox(); + this.ck_IsShowImport = new System.Windows.Forms.CheckBox(); + this.label12 = new System.Windows.Forms.Label(); + this.tb_templeteFileDownName = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.cmb_DataBase = new System.Windows.Forms.ComboBox(); + this.label17 = new System.Windows.Forms.Label(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.SuspendLayout(); + // + // btnPath + // + this.btnPath.Location = new System.Drawing.Point(425, 570); + this.btnPath.Name = "btnPath"; + this.btnPath.Size = new System.Drawing.Size(97, 23); + this.btnPath.TabIndex = 1; + this.btnPath.Text = "閫夋嫨鐢熸垚璺緞"; + this.btnPath.UseVisualStyleBackColor = true; + this.btnPath.Click += new System.EventHandler(this.button1_Click); + // + // lblds + // + this.lblds.AutoSize = true; + this.lblds.Location = new System.Drawing.Point(22, 72); + this.lblds.Name = "lblds"; + this.lblds.Size = new System.Drawing.Size(35, 12); + this.lblds.TabIndex = 2; + this.lblds.Text = "琛ㄥ悕:"; + // + // tbPath + // + this.tbPath.Location = new System.Drawing.Point(106, 566); + this.tbPath.Name = "tbPath"; + this.tbPath.ReadOnly = true; + this.tbPath.Size = new System.Drawing.Size(253, 21); + this.tbPath.TabIndex = 7; + // + // btnExit + // + this.btnExit.Location = new System.Drawing.Point(649, 600); + this.btnExit.Name = "btnExit"; + this.btnExit.Size = new System.Drawing.Size(171, 67); + this.btnExit.TabIndex = 8; + this.btnExit.Text = "閫�鍑�"; + this.btnExit.UseVisualStyleBackColor = true; + this.btnExit.Click += new System.EventHandler(this.btnExit_Click); + // + // btn_CreateFile + // + this.btn_CreateFile.Location = new System.Drawing.Point(106, 600); + this.btn_CreateFile.Name = "btn_CreateFile"; + this.btn_CreateFile.Size = new System.Drawing.Size(157, 67); + this.btn_CreateFile.TabIndex = 14; + this.btn_CreateFile.Text = "鐢熸垚鏂囦欢"; + this.btn_CreateFile.UseVisualStyleBackColor = true; + this.btn_CreateFile.Click += new System.EventHandler(this.btn_CreateFile_Click); + // + // tb_TableName + // + this.tb_TableName.Location = new System.Drawing.Point(92, 69); + this.tb_TableName.Name = "tb_TableName"; + this.tb_TableName.Size = new System.Drawing.Size(183, 21); + this.tb_TableName.TabIndex = 15; + this.tb_TableName.TextChanged += new System.EventHandler(this.tb_TableName_TextChanged); + // + // tb_FileName + // + this.tb_FileName.Location = new System.Drawing.Point(221, 152); + this.tb_FileName.Name = "tb_FileName"; + this.tb_FileName.Size = new System.Drawing.Size(199, 21); + this.tb_FileName.TabIndex = 17; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(25, 154); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(191, 12); + this.label1.TabIndex = 16; + this.label1.Text = "鏂囦欢鍚嶇О(鐢ㄤ簬缁欏悇涓被鍚嶇殑鍓嶇紑):"; + // + // tb_WCF_NameSpacePath + // + this.tb_WCF_NameSpacePath.Location = new System.Drawing.Point(563, 247); + this.tb_WCF_NameSpacePath.Name = "tb_WCF_NameSpacePath"; + this.tb_WCF_NameSpacePath.Size = new System.Drawing.Size(197, 21); + this.tb_WCF_NameSpacePath.TabIndex = 19; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(455, 249); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(101, 12); + this.label2.TabIndex = 18; + this.label2.Text = "WCF椤圭洰鍛藉悕绌洪棿:"; + // + // tb_ChinaComment + // + this.tb_ChinaComment.Location = new System.Drawing.Point(221, 234); + this.tb_ChinaComment.Name = "tb_ChinaComment"; + this.tb_ChinaComment.Size = new System.Drawing.Size(197, 21); + this.tb_ChinaComment.TabIndex = 23; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(26, 234); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(83, 12); + this.label4.TabIndex = 22; + this.label4.Text = "琛ㄧ殑涓枃娉ㄨВ:"; + // + // tb_CreatePerson + // + this.tb_CreatePerson.Location = new System.Drawing.Point(221, 279); + this.tb_CreatePerson.Name = "tb_CreatePerson"; + this.tb_CreatePerson.Size = new System.Drawing.Size(199, 21); + this.tb_CreatePerson.TabIndex = 25; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(26, 289); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(107, 12); + this.label5.TabIndex = 24; + this.label5.Text = "浣犵殑鍚嶅瓧鎷奸煶缂╁啓:"; + // + // tb_Primary + // + this.tb_Primary.Location = new System.Drawing.Point(338, 69); + this.tb_Primary.Name = "tb_Primary"; + this.tb_Primary.Size = new System.Drawing.Size(145, 21); + this.tb_Primary.TabIndex = 27; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(298, 72); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(35, 12); + this.label6.TabIndex = 26; + this.label6.Text = "涓婚敭:"; + // + // tb_EntityProName + // + this.tb_EntityProName.Location = new System.Drawing.Point(560, 141); + this.tb_EntityProName.Name = "tb_EntityProName"; + this.tb_EntityProName.Size = new System.Drawing.Size(183, 21); + this.tb_EntityProName.TabIndex = 31; + this.tb_EntityProName.TextChanged += new System.EventHandler(this.tb_EntityProName_TextChanged); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(436, 149); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(125, 12); + this.label7.TabIndex = 30; + this.label7.Text = "瀹炰綋绫诲璞″悕/琛ㄥ埆鍚�:"; + // + // tb_EntityName + // + this.tb_EntityName.Location = new System.Drawing.Point(92, 108); + this.tb_EntityName.Name = "tb_EntityName"; + this.tb_EntityName.Size = new System.Drawing.Size(183, 21); + this.tb_EntityName.TabIndex = 29; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(22, 111); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(59, 12); + this.label8.TabIndex = 28; + this.label8.Text = "瀹炰綋绫诲悕:"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(463, 210); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(35, 12); + this.label9.TabIndex = 34; + this.label9.Text = "鎺掑簭:"; + // + // tb_OrderBy + // + this.tb_OrderBy.Location = new System.Drawing.Point(503, 207); + this.tb_OrderBy.Name = "tb_OrderBy"; + this.tb_OrderBy.Size = new System.Drawing.Size(145, 21); + this.tb_OrderBy.TabIndex = 35; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(668, 210); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(65, 12); + this.label10.TabIndex = 36; + this.label10.Text = "(榛樿闄嶅簭)"; + // + // tb_PrimaryDesc + // + this.tb_PrimaryDesc.Location = new System.Drawing.Point(569, 69); + this.tb_PrimaryDesc.Name = "tb_PrimaryDesc"; + this.tb_PrimaryDesc.Size = new System.Drawing.Size(145, 21); + this.tb_PrimaryDesc.TabIndex = 38; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(508, 72); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(59, 12); + this.label11.TabIndex = 37; + this.label11.Text = "涓婚敭鎻忚堪:"; + // + // tb_Modulelogo + // + this.tb_Modulelogo.Location = new System.Drawing.Point(221, 202); + this.tb_Modulelogo.Name = "tb_Modulelogo"; + this.tb_Modulelogo.Size = new System.Drawing.Size(199, 21); + this.tb_Modulelogo.TabIndex = 41; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(25, 206); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(167, 12); + this.label3.TabIndex = 40; + this.label3.Text = "妯″潡绠�鍐�(鐢ㄤ簬缁欏悇涓柟娉曞悕):"; + // + // btn_InsertSql + // + this.btn_InsertSql.Location = new System.Drawing.Point(385, 600); + this.btn_InsertSql.Name = "btn_InsertSql"; + this.btn_InsertSql.Size = new System.Drawing.Size(157, 67); + this.btn_InsertSql.TabIndex = 42; + this.btn_InsertSql.Text = "鐢熸垚InitSQL"; + this.btn_InsertSql.UseVisualStyleBackColor = true; + this.btn_InsertSql.Visible = false; + this.btn_InsertSql.Click += new System.EventHandler(this.btn_InsertSql_Click); + // + // tb_RoutePrefix + // + this.tb_RoutePrefix.Location = new System.Drawing.Point(538, 276); + this.tb_RoutePrefix.Name = "tb_RoutePrefix"; + this.tb_RoutePrefix.Size = new System.Drawing.Size(145, 21); + this.tb_RoutePrefix.TabIndex = 44; + this.tb_RoutePrefix.Text = "1111"; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Location = new System.Drawing.Point(463, 282); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(77, 12); + this.label13.TabIndex = 43; + this.label13.Text = "WCF璺敱鍓嶇紑:"; + this.label13.Click += new System.EventHandler(this.label13_Click); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.label17); + this.groupBox1.Controls.Add(this.cmb_DataBase); + this.groupBox1.Controls.Add(this.lbl_DataSource); + this.groupBox1.Controls.Add(this.cmb_DataSource); + this.groupBox1.Location = new System.Drawing.Point(51, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(819, 72); + this.groupBox1.TabIndex = 45; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "鏁版嵁搴撻厤缃�"; + // + // lbl_DataSource + // + this.lbl_DataSource.AutoSize = true; + this.lbl_DataSource.Location = new System.Drawing.Point(10, 48); + this.lbl_DataSource.Name = "lbl_DataSource"; + this.lbl_DataSource.Size = new System.Drawing.Size(89, 12); + this.lbl_DataSource.TabIndex = 1; + this.lbl_DataSource.Text = "鎴戞槸閾炬帴瀛楃涓�"; + // + // cmb_DataSource + // + this.cmb_DataSource.FormattingEnabled = true; + this.cmb_DataSource.Location = new System.Drawing.Point(6, 20); + this.cmb_DataSource.Name = "cmb_DataSource"; + this.cmb_DataSource.Size = new System.Drawing.Size(206, 20); + this.cmb_DataSource.TabIndex = 0; + this.cmb_DataSource.SelectedIndexChanged += new System.EventHandler(this.cmb_DataSource_SelectedIndexChanged); + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.tb_GroupName); + this.groupBox2.Controls.Add(this.label16); + this.groupBox2.Controls.Add(this.label15); + this.groupBox2.Controls.Add(this.tb_ProjectNamePrefix); + this.groupBox2.Controls.Add(this.groupBox3); + this.groupBox2.Controls.Add(this.tb_FileName); + this.groupBox2.Controls.Add(this.lblds); + this.groupBox2.Controls.Add(this.tb_RoutePrefix); + this.groupBox2.Controls.Add(this.tb_TableName); + this.groupBox2.Controls.Add(this.label13); + this.groupBox2.Controls.Add(this.label1); + this.groupBox2.Controls.Add(this.label2); + this.groupBox2.Controls.Add(this.tb_Modulelogo); + this.groupBox2.Controls.Add(this.tb_WCF_NameSpacePath); + this.groupBox2.Controls.Add(this.label3); + this.groupBox2.Controls.Add(this.label4); + this.groupBox2.Controls.Add(this.tb_ChinaComment); + this.groupBox2.Controls.Add(this.tb_PrimaryDesc); + this.groupBox2.Controls.Add(this.label5); + this.groupBox2.Controls.Add(this.label11); + this.groupBox2.Controls.Add(this.tb_CreatePerson); + this.groupBox2.Controls.Add(this.label10); + this.groupBox2.Controls.Add(this.label6); + this.groupBox2.Controls.Add(this.tb_OrderBy); + this.groupBox2.Controls.Add(this.tb_Primary); + this.groupBox2.Controls.Add(this.label9); + this.groupBox2.Controls.Add(this.label8); + this.groupBox2.Controls.Add(this.tb_EntityProName); + this.groupBox2.Controls.Add(this.tb_EntityName); + this.groupBox2.Controls.Add(this.label7); + this.groupBox2.Location = new System.Drawing.Point(51, 90); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(819, 470); + this.groupBox2.TabIndex = 46; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "鑷畾涔夐厤缃�"; + // + // tb_GroupName + // + this.tb_GroupName.Location = new System.Drawing.Point(350, 108); + this.tb_GroupName.Name = "tb_GroupName"; + this.tb_GroupName.Size = new System.Drawing.Size(183, 21); + this.tb_GroupName.TabIndex = 50; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(298, 111); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(47, 12); + this.label16.TabIndex = 49; + this.label16.Text = "鍒嗙粍鍚�:"; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(26, 24); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(71, 12); + this.label15.TabIndex = 47; + this.label15.Text = "椤圭洰鍚嶅墠缂�:"; + // + // tb_ProjectNamePrefix + // + this.tb_ProjectNamePrefix.Location = new System.Drawing.Point(104, 21); + this.tb_ProjectNamePrefix.Name = "tb_ProjectNamePrefix"; + this.tb_ProjectNamePrefix.Size = new System.Drawing.Size(183, 21); + this.tb_ProjectNamePrefix.TabIndex = 48; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.tb_importExcelCategroy); + this.groupBox3.Controls.Add(this.ck_IsShowImport); + this.groupBox3.Controls.Add(this.label12); + this.groupBox3.Controls.Add(this.tb_templeteFileDownName); + this.groupBox3.Controls.Add(this.label14); + this.groupBox3.Location = new System.Drawing.Point(28, 316); + this.groupBox3.Margin = new System.Windows.Forms.Padding(2); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Padding = new System.Windows.Forms.Padding(2); + this.groupBox3.Size = new System.Drawing.Size(272, 118); + this.groupBox3.TabIndex = 46; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "瀵煎叆鍔熻兘"; + // + // tb_importExcelCategroy + // + this.tb_importExcelCategroy.Location = new System.Drawing.Point(143, 86); + this.tb_importExcelCategroy.Name = "tb_importExcelCategroy"; + this.tb_importExcelCategroy.Size = new System.Drawing.Size(113, 21); + this.tb_importExcelCategroy.TabIndex = 50; + // + // ck_IsShowImport + // + this.ck_IsShowImport.AutoSize = true; + this.ck_IsShowImport.Location = new System.Drawing.Point(21, 30); + this.ck_IsShowImport.Margin = new System.Windows.Forms.Padding(2); + this.ck_IsShowImport.Name = "ck_IsShowImport"; + this.ck_IsShowImport.Size = new System.Drawing.Size(108, 16); + this.ck_IsShowImport.TabIndex = 45; + this.ck_IsShowImport.Text = "鏄惁鏈夊鍏ュ姛鑳�"; + this.ck_IsShowImport.UseVisualStyleBackColor = true; + this.ck_IsShowImport.Visible = false; + this.ck_IsShowImport.CheckedChanged += new System.EventHandler(this.ck_IsShowImport_CheckedChanged); + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(9, 94); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(119, 12); + this.label12.TabIndex = 49; + this.label12.Text = "涓婁紶鏂囦欢鐨勮姹傚垎绫�:"; + // + // tb_templeteFileDownName + // + this.tb_templeteFileDownName.Location = new System.Drawing.Point(143, 58); + this.tb_templeteFileDownName.Name = "tb_templeteFileDownName"; + this.tb_templeteFileDownName.Size = new System.Drawing.Size(113, 21); + this.tb_templeteFileDownName.TabIndex = 48; + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(10, 60); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(83, 12); + this.label14.TabIndex = 47; + this.label14.Text = "鏂囦欢涓嬭浇鍚嶅瓧:"; + // + // cmb_DataBase + // + this.cmb_DataBase.FormattingEnabled = true; + this.cmb_DataBase.Location = new System.Drawing.Point(581, 20); + this.cmb_DataBase.Name = "cmb_DataBase"; + this.cmb_DataBase.Size = new System.Drawing.Size(206, 20); + this.cmb_DataBase.TabIndex = 2; + this.cmb_DataBase.SelectedIndexChanged += new System.EventHandler(this.cmb_DataBase_SelectedIndexChanged); + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Location = new System.Drawing.Point(478, 23); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(65, 12); + this.label17.TabIndex = 3; + this.label17.Text = "鏁版嵁搴撶被鍨�"; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(927, 672); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.btn_InsertSql); + this.Controls.Add(this.btn_CreateFile); + this.Controls.Add(this.btnExit); + this.Controls.Add(this.tbPath); + this.Controls.Add(this.btnPath); + this.Name = "MainForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "浼熸湰-CMS-浠g爜鐢熸垚鍣�(浼熸湰涓撶敤)V1.0"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnPath; + private System.Windows.Forms.Label lblds; + private System.Windows.Forms.TextBox tbPath; + private System.Windows.Forms.Button btnExit; + private System.Windows.Forms.Button btn_CreateFile; + private System.Windows.Forms.TextBox tb_TableName; + private System.Windows.Forms.TextBox tb_FileName; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox tb_WCF_NameSpacePath; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox tb_ChinaComment; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox tb_CreatePerson; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox tb_Primary; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox tb_EntityProName; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox tb_EntityName; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox tb_OrderBy; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.TextBox tb_PrimaryDesc; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.TextBox tb_Modulelogo; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button btn_InsertSql; + private System.Windows.Forms.TextBox tb_RoutePrefix; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Label lbl_DataSource; + private System.Windows.Forms.ComboBox cmb_DataSource; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.CheckBox ck_IsShowImport; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.TextBox tb_importExcelCategroy; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.TextBox tb_templeteFileDownName; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.TextBox tb_ProjectNamePrefix; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.TextBox tb_GroupName; + private System.Windows.Forms.ComboBox cmb_DataBase; + private System.Windows.Forms.Label label17; + } +} + diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" new file mode 100644 index 0000000..b98d6f0 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.cs" @@ -0,0 +1,377 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; +using System.IO; +using Newtonsoft.Json; +using System.Windows.Forms.VisualStyles; +using GenerateCode_WeiBen_WMS.DataBaseFactory; + +namespace GenerateCode_GEBrilliantFactory +{ + public partial class MainForm : Form + { + public static string projectNamePrefix = ""; + public static string dataBaseName = ""; + public static DataBaseEnum dataBaseEnum = DataBaseEnum.MySql; + public MainForm() + { + InitializeComponent(); + + this.tbPath.Text = "D:\\C#AutoCreateCodeFile"; + + this.tb_Primary.Text = "id";//涓婚敭鍚� + this.tb_PrimaryDesc.Text = "涓婚敭"; + this.tb_OrderBy.Text = "ModifyTime";//鎺掑簭瀛楁 + + this.tb_ProjectNamePrefix.Text = "Test"; + this.tb_TableName.Text = "scms_auditlogs";//琛ㄥ悕 + this.tb_WCF_NameSpacePath.Text = "WIP_";//WCF椤圭洰鍛藉悕绌洪棿 + this.tb_FileName.Text = "Xiangzi";//鏂囦欢鍓嶇紑鍚� + this.tb_ChinaComment.Text = "琛ㄧ殑涓枃娉ㄨВ";//涓枃娉ㄩ噴 + this.tb_CreatePerson.Text = "shaocx";//鍒涘缓浜� + this.tb_EntityName.Text = "XiangziEntity";//瀹炰綋绫诲悕 + this.tb_EntityProName.Text = "xiangzi";//瀹炰綋绫诲璞″悕 + + this.cmb_DataSource.DropDownStyle = ComboBoxStyle.DropDownList; + List<ListItem> itemList = CommonHelper.GetDataSources(); + foreach (var item in itemList) + { + this.cmb_DataSource.Items.Add(item); + } + this.cmb_DataSource.SelectedIndex = 0; + + this.cmb_DataBase.DropDownStyle = ComboBoxStyle.DropDownList; + List<ListItem> itemList_Db = CommonHelper.GetDataBase(); + foreach (var item in itemList_Db) + { + this.cmb_DataBase.Items.Add(item); + } + this.cmb_DataBase.SelectedIndex = 0; + } + + /// <summary> + /// 淇濆瓨璺緞瀵硅瘽妗� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void button1_Click(object sender, EventArgs e) + { + FolderBrowserDialog fbd = new FolderBrowserDialog(); + if (DialogResult.OK == fbd.ShowDialog()) + { + tbPath.Text = fbd.SelectedPath; + } + } + + private void btnExit_Click(object sender, EventArgs e) + { + Application.Exit(); + } + + //涓�閿敓鎴愭墍鏈夋枃浠� + private void btn_CreateFile_Click(object sender, EventArgs e) + { + try + { + projectNamePrefix = this.tb_ProjectNamePrefix.Text; + if (projectNamePrefix == "") + { + MessageBox.Show("璇疯緭鍏ラ」鐩悕鍓嶇紑锛�"); + this.tb_ProjectNamePrefix.Focus(); + return; + } + + if (dataBaseName == "") + { + MessageBox.Show("璇烽�夋嫨鏁版嵁搴擄紒"); + return; + } + + string primaryKey = this.tb_Primary.Text.Trim();//涓婚敭鍚� + string primaryKeyDesc = this.tb_PrimaryDesc.Text.Trim();//涓婚敭鎻忚堪 + string tableName = this.tb_TableName.Text.Trim();//琛ㄥ悕 + string wcf_NameSpacePath = this.tb_WCF_NameSpacePath.Text.Trim();//WCF椤圭洰鍛藉悕绌洪棿 + string filePrefixName = this.tb_FileName.Text.Trim();//鏂囦欢鍓嶇紑鍚� + string modulelogo = this.tb_Modulelogo.Text.Trim();//妯″潡绠�鍐� + string chinaComment = this.tb_ChinaComment.Text.Trim();//涓枃娉ㄩ噴 + string createPerson = this.tb_CreatePerson.Text.Trim();//鍒涘缓浜� + string entityName = this.tb_EntityName.Text.Trim();//瀹炰綋绫诲悕 + string tableAlias = this.tb_EntityProName.Text.Trim();//瀹炰綋绫诲璞″悕/琛ㄥ埆鍚� + string orderByName = this.tb_OrderBy.Text.Trim();//鎺掑簭瀛楁鍚嶇О + string routePrefix = this.tb_RoutePrefix.Text.Trim();//WCF璺敱鍓嶇紑 + string connStr = this.lbl_DataSource.Text.Trim();//鏁版嵁搴撹繛鎺ュ瓧绗︿覆 + if (connStr == "") + { + MessageBox.Show("璇烽�夋嫨鏁版嵁搴撴簮锛�"); + this.cmb_DataSource.Focus(); + return; + } + if (tableName == "") + { + MessageBox.Show("璇疯緭鍏ヨ〃鍚嶏紒"); + this.tb_TableName.Focus(); + return; + } + if (primaryKey == "") + { + MessageBox.Show("璇疯緭鍏ヤ富閿悕锛�"); + this.tb_Primary.Focus(); + return; + } + if (routePrefix == "") + { + MessageBox.Show("璇疯緭鍏CF璺敱鍓嶇紑锛�"); + this.tb_RoutePrefix.Focus(); + return; + } + + //璇诲彇Mysql + var handler = DataBaseServiceFactory.GetHandle(dataBaseEnum); + List<ColumnModel> columnList = handler.GetColumnList(tableName, connStr); + if (columnList.Count == 0) + { + MessageBox.Show("娌℃湁鑾峰彇鍒拌〃涓嬮潰鐨勫垪闆嗗悎锛�"); + return; + } + + string groupName = this.tb_GroupName.Text.Trim(); + if (groupName == "") + { + MessageBox.Show("璇疯緭鍏ュ垎缁勫悕锛�"); + this.tb_GroupName.Focus(); + return; + } + + string addEntityParam = "Add" + modulelogo + "Param";//鏂板鍙傛暟绫诲悕 + string str_generate = ""; + bool tf; + + //鐢熸垚Model + //CreateModelFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo); + //CreateModelParamFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo); + + //鐢熸垚 InputModel 鏂囦欢 + str_generate = InputModel_Generate.CreateQueryModelLText(modulelogo, chinaComment, columnList, entityName); + tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo); + + //鐢熸垚 OutputModel 鏂囦欢 + str_generate = OutputModel_Generate.CreateQueryModelLText(modulelogo, chinaComment, columnList, entityName); + tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.OutputModel, filePrefixName, entityName, modulelogo); + + //鐢熸垚Controller鏂囦欢 + //str_generate = Controller_Generate.CreateText(modulelogo, chinaComment, columnList, entityName, orderByName); + //tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.Controller, filePrefixName, entityName, modulelogo); + + //鐢熸垚Services鎺ュ彛鏂囦欢 + str_generate = Services_Interface_Generate.CreateText(wcf_NameSpacePath, modulelogo, entityName, chinaComment, addEntityParam); + tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.WCF_InterFace, filePrefixName, entityName, modulelogo); + + + //鐢熸垚Services鎺ュ彛瀹炵幇鏂囦欢 + str_generate = Services_InterfaceRealize_Generate.CreateText(wcf_NameSpacePath, modulelogo, + entityName, chinaComment, filePrefixName, primaryKey, tableAlias, addEntityParam, columnList, groupName); + tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.WCF_InterFaceRealize, filePrefixName, entityName, modulelogo); + + /* + //鐢熸垚瀛樺偍杩囩▼鏂囦欢 + str_generate = Procedure_Generate.CreateProcText(tableName, tableAlias, createPerson, chinaComment, + primaryKey, filePrefixName, orderByName, modulelogo, columnList); + tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.Proc, filePrefixName, entityName, modulelogo); + + //鐢熸垚DAL鏂囦欢 + str_generate = DAL_Generate.CreateDALText(filePrefixName, tableName, entityName, createPerson, + chinaComment, primaryKey, primaryKeyDesc, modulelogo, tableAlias, columnList); + tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.DAL, filePrefixName, entityName, modulelogo); + + //鐢熸垚BLL鏂囦欢 + str_generate = BLL_Generate.CreateBLLText(filePrefixName, tableName, entityName, createPerson, + chinaComment, primaryKey, primaryKeyDesc, modulelogo, tableAlias, addEntityParam, columnList); + tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.BLL, filePrefixName, entityName, modulelogo); + + + + //鐢熸垚AddModel鏂囦欢 + str_generate = AddModel_Generate.CreateAddModelLText(addEntityParam, chinaComment, columnList); + tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.AddModelParam, filePrefixName, entityName, modulelogo); + + + + + //*/ + + //VUE鏂规硶閰嶇疆 + //str_generate = VUE_FunConfig_Generate.CreateText(modulelogo, chinaComment, routePrefix, entityName); + //tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.VUE_FunConfig, filePrefixName, entityName, modulelogo); + + //VUE鏂囦欢 + //str_generate = VUE_Generate.CreateText(tableAlias, modulelogo, primaryKey, columnList, chinaComment + // , this.tb_templeteFileDownName.Text, this.tb_importExcelCategroy.Text); + //tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.VUEFile, filePrefixName, entityName, modulelogo); + + //btn_InsertSql_Click(null, null); + } + catch (Exception ex) + { + MessageBox.Show("鐢熸垚鏂囦欢澶辫触锛�" + ex.Message); + return; + } + //MessageBox.Show("鐢熸垚鏂囦欢鎴愬姛锛�"); + //鎴愬姛涔嬪悗鎵撳紑鏂囦欢澶� + using (System.Diagnostics.Process.Start(this.tbPath.Text + "\\" + this.tb_TableName.Text)) + { + + } + //*/ + } + + #region 鍒嗙被鏂囦欢 + + /// <summary> + /// 鐢熸垚Model + /// </summary> + /// <param name="_tableName"></param> + private void CreateModelFile(List<ColumnModel> strList, string _tableName, string filePrefixName, string nameSpacePath, + string createPerson, string chinaComment, string entityName, string modulelogo) + { + bool tf = TextHelper.Export2File(tbPath.Text, _tableName, + Model_Generate.GenerateModel(_tableName, strList, filePrefixName, nameSpacePath, createPerson, chinaComment, entityName), + FileType.Model, filePrefixName, entityName, modulelogo); + } + + /// <summary> + /// 鐢熸垚Model鍙傛暟 + /// </summary> + /// <param name="_tableName"></param> + private void CreateModelParamFile(List<ColumnModel> strList, string _tableName, string filePrefixName, string nameSpacePath, + string createPerson, string chinaComment, string entityName, string modulelogo) + { + bool tf = TextHelper.Export2File(tbPath.Text, _tableName, + Model_Generate.GenerateModelParam(_tableName, strList, filePrefixName, nameSpacePath, createPerson, chinaComment, entityName), + FileType.Model, filePrefixName, entityName, modulelogo); + } + #endregion + + /// <summary> + /// 鏂囨湰鏀瑰彉浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void tb_TableName_TextChanged(object sender, EventArgs e) + { + string tableName = this.tb_TableName.Text.Trim();//琛ㄥ悕 + if (tableName != "") + { + var str = CommonHelper.TitleToUpper(tableName); + this.tb_FileName.Text = this.tb_EntityName.Text = str; + var index = tableName.IndexOf('_'); + if (index > -1) + { + var moule_str = tableName.Substring(index + 1, tableName.Length - index - 1); + this.tb_Modulelogo.Text = moule_str; + this.tb_EntityProName.Text = CommonHelper.TitleToLower(moule_str); + } + else + { + this.tb_Modulelogo.Text = tableName; + this.tb_EntityProName.Text = CommonHelper.TitleToLower(tableName); + } + } + } + + private void btn_InsertSql_Click(object sender, EventArgs e) + { + string connStr = this.lbl_DataSource.Text.Trim();//鏁版嵁搴撹繛鎺ュ瓧绗︿覆 + if (connStr == "") + { + MessageBox.Show("璇烽�夋嫨鏁版嵁搴撴簮锛�"); + this.cmb_DataSource.Focus(); + return; + } + var tableName = this.tb_TableName.Text.Trim(); + if (tableName == string.Empty) + { + MessageBox.Show("璇疯緭鍏ヨ〃鍚�!"); + return; + } + List<ColumnModel> columnList = StructStrHelper.GetColumnList(tableName, connStr); + if (columnList.Count == 0) + { + MessageBox.Show("娌℃湁鑾峰彇鍒拌〃涓嬮潰鐨勫垪闆嗗悎锛�"); + return; + } + string chinaComment = this.tb_ChinaComment.Text.Trim();//涓枃娉ㄩ噴 + string createPerson = this.tb_CreatePerson.Text.Trim();//鍒涘缓浜� + var str_generate = InsertSQL_Generate.CreateInsertSQLText(tableName, createPerson, chinaComment, columnList); + bool tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.SQL_Insert, "", "", ""); + //MessageBox.Show("鐢熸垚鏂囦欢鎴愬姛锛�"); + //鎴愬姛涔嬪悗鎵撳紑鏂囦欢澶� + using (System.Diagnostics.Process.Start(this.tbPath.Text + "\\" + this.tb_TableName.Text)) + { + + } + } + + private void label13_Click(object sender, EventArgs e) + { + + } + + private void MainForm_Load(object sender, EventArgs e) + { + tb_EntityProName.Enabled = false; + tb_FileName.Enabled = false; + tb_Modulelogo.Enabled = false; + tb_WCF_NameSpacePath.Enabled = false; + tb_RoutePrefix.Enabled = false; + } + + private void cmb_DataSource_SelectedIndexChanged(object sender, EventArgs e) + { + string connStr = (this.cmb_DataSource.SelectedItem as ListItem).Value; + var name = (this.cmb_DataSource.SelectedItem as ListItem).Text; + this.lbl_DataSource.Text = connStr; + dataBaseName = name; + if (name == "GSiemens_LES") + { + this.tb_ProjectNamePrefix.Text = "LES"; + } + else if (name == "GSiemens_WIP") + { + this.tb_ProjectNamePrefix.Text = "WIP"; + } + else if (name.Contains("AoSinWms")) + { + this.tb_ProjectNamePrefix.Text = "AoSinWms"; + } + else + { + this.tb_ProjectNamePrefix.Text = "Test"; + } + } + + private void ck_IsShowImport_CheckedChanged(object sender, EventArgs e) + { + //this.tb_templeteFileDownName.Enabled = false; + //this.tb_importExcelCategroy.Enabled = false; + //if (this.ck_IsShowImport.Checked) + //{ + // this.tb_templeteFileDownName.Enabled = true; + // this.tb_importExcelCategroy.Enabled = true; + //} + } + + private void tb_EntityProName_TextChanged(object sender, EventArgs e) + { + + } + + private void cmb_DataBase_SelectedIndexChanged(object sender, EventArgs e) + { + string connStr = (this.cmb_DataBase.SelectedItem as ListItem).Value; + var name = (this.cmb_DataBase.SelectedItem as ListItem).Text; + + dataBaseEnum = (DataBaseEnum)Enum.Parse(typeof(DataBaseEnum), name); + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.resx" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.resx" new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/MainForm.resx" @@ -0,0 +1,120 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/ColumnModell.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/ColumnModell.cs" new file mode 100644 index 0000000..8911f5e --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/ColumnModell.cs" @@ -0,0 +1,47 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鍒楀璞� + /// </summary> + public class ColumnModel + { + /// <summary> + /// 鍒楀悕 + /// </summary> + public string ColumnName { get; set; } + + /// <summary> + /// 鏁版嵁绫诲瀷 + /// </summary> + public string DataType { get; set; } + + /// <summary> + /// 娉ㄩ噴 + /// </summary> + public string Description { get; set; } + + /// <summary> + /// 瀛楁闀垮害 + /// </summary> + public string DataLength { get; set; } + + /// <summary> + /// 鏄惁鍙负null + /// </summary> + public bool IsNullable { get; set; } + + /// <summary> + /// 鏄惁鏄富閿� + /// </summary> + public bool IsPrimaryKey { get; set; } + + public int Precision { get; set; } + + public int Scale { get; set; } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Enum/DataBaseEnum.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Enum/DataBaseEnum.cs" new file mode 100644 index 0000000..48bda3e --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Enum/DataBaseEnum.cs" @@ -0,0 +1,16 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鏁版嵁搴撴灇涓� + /// </summary> + public enum DataBaseEnum + { + SqlServer = 0, + MySql = 1, + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Enum/DataTypeEnum.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Enum/DataTypeEnum.cs" new file mode 100644 index 0000000..a085fb7 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Enum/DataTypeEnum.cs" @@ -0,0 +1,36 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鏁版嵁绫诲瀷鏋氫妇 + /// </summary> + public enum DataTypeEnum + { + dt_char = 0, + dt_varchar = 1, + dt_datetime = 2, + dt_datetime2 = 3, + dt_int = 4, + dt_bigint = 5, + dt_decimal = 6, + dt_nvarchar = 7, + dt_Varchar_Desc = 8, + dt_Varchar_Ext_Link = 9, + dt_bit = 10, + /// <summary> + /// 鍞竴绫诲瀷 + /// uniqueidentifier鏁版嵁绫诲瀷鍙瓨鍌�16瀛楄妭鐨勪簩杩涘埗鍊硷紝鍏朵綔鐢ㄤ笌鍏ㄥ眬鍞竴鏍囪绗�(GUID)涓�鏍枫�侴UID鏄敮涓�鐨勪簩杩涘埗鏁�:涓栫晫涓婄殑浠讳綍涓ゅ彴璁$畻鏈洪兘涓嶄細鐢熸垚閲嶅鐨凣UID鍊笺�侴UID涓昏鐢ㄤ簬鍦ㄧ敤浜庡涓妭鐐癸紝澶氬彴璁$畻鏈虹殑缃戠粶涓紝鍒嗛厤蹇呴』鍏锋湁鍞竴鎬х殑鏍囪瘑绗︺�� + /// </summary> + dt_uniqueidentifier = 11, + dt_float = 12, + + /// <summary> + /// 鏃ユ湡 + /// </summary> + dt_datetimeoffset = 13 + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/ListItem.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/ListItem.cs" new file mode 100644 index 0000000..fa7af4e --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/ListItem.cs" @@ -0,0 +1,32 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// ListItem鐢ㄤ簬ComboBox鎺т欢娣诲姞椤� + /// </summary> + public class ListItem + { + public string Text + { + get; + set; + } + public string Value + { + get; + set; + } + + + + public override string ToString() + { + return this.Text; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Proc.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Proc.cs" new file mode 100644 index 0000000..c9eae0a --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/Proc.cs" @@ -0,0 +1,52 @@ +锘�/* + * CLR Version锛�4.0.30319.42000 + * NameSpace锛欸enerateCode_GEBrilliantFactory.Model + * FileName锛歅roc + * CurrentYear锛�2018 + * CurrentTime锛�2018/8/31 16:46:26 + * Author锛歴haocx + * + * <鏇存柊璁板綍> + * ver 1.0.0.0 2018/8/31 16:46:26 鏂拌浣滄垚 (by shaocx) + */ + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 瀛樺偍杩囩▼鍚� + /// </summary> + public class ProcName + { + /// <summary> + /// 鏂板鐨勫瓨鍌ㄨ繃绋嬪悕 + /// </summary> + public string AddProc { get; set; } + + /// <summary> + /// 缂栬緫鐨勫瓨鍌ㄨ繃绋嬪悕 + /// </summary> + public string UpdateProc { get; set; } + + /// <summary> + /// 鍒楄〃鐨勫瓨鍌ㄨ繃绋嬪悕 + /// </summary> + public string ListProc { get; set; } + + /// <summary> + /// 鍒嗛〉鍒楄〃鐨勫瓨鍌ㄨ繃绋嬪悕 + /// </summary> + public string PageListProc { get; set; } + + /// <summary> + /// 寰楀埌涓�涓疄浣撶殑瀛樺偍杩囩▼鍚� + /// </summary> + public string GetSingleProc { get; set; } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/SystemCommonVar.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/SystemCommonVar.cs" new file mode 100644 index 0000000..8922f7c --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Model/SystemCommonVar.cs" @@ -0,0 +1,50 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_GEBrilliantFactory.Model +{ + public static class SystemCommonVar + { + //public const string c_Id = "Id"; + + //public const string c_creator = "creator"; + + //public const string c_createTime = "createTime"; + + //public const string c_lastModifier = "lastModifier"; + + //public const string c_ModifyTime = "ModifyTime"; + + //public const string c_lastModifyTime = "lastModifyTime"; + + //public const string c_delFlag = "delFlag"; + + //public const string c_CreateId = "CreateId"; + + //public const string c_ModifyId = "ModifyId"; + + + public const string c_Id = "Id"; + + public const string c_creator = "CreatedUserName"; + + public const string c_createTime = "CreatedTime"; + + public const string c_lastModifier = "UpdatedUserName"; + + public const string c_ModifyTime = "UpdatedTime"; + + public const string c_lastModifyTime = "UpdatedTime"; + + public const string c_delFlag = "IsDeleted"; + + public const string c_CreateId = "CreatedUserId"; + + public const string c_ModifyId = "UpdatedUserId"; + + + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Program.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Program.cs" new file mode 100644 index 0000000..29e887f --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Program.cs" @@ -0,0 +1,21 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace GenerateCode_GEBrilliantFactory +{ + static class Program + { + /// <summary> + /// 搴旂敤绋嬪簭鐨勪富鍏ュ彛鐐广�� + /// </summary> + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/AssemblyInfo.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/AssemblyInfo.cs" new file mode 100644 index 0000000..bba0906 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/AssemblyInfo.cs" @@ -0,0 +1,36 @@ +锘縰sing System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 鏈夊叧绋嬪簭闆嗙殑甯歌淇℃伅閫氳繃浠ヤ笅 +// 鐗规�ч泦鎺у埗銆傛洿鏀硅繖浜涚壒鎬у�煎彲淇敼 +// 涓庣▼搴忛泦鍏宠仈鐨勪俊鎭�� +[assembly: AssemblyTitle("GenerateModel")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("GenerateModel")] +[assembly: AssemblyCopyright("Copyright 漏 Microsoft 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 灏� ComVisible 璁剧疆涓� false 浣挎绋嬪簭闆嗕腑鐨勭被鍨� +// 瀵� COM 缁勪欢涓嶅彲瑙併�傚鏋滈渶瑕佷粠 COM 璁块棶姝ょ▼搴忛泦涓殑绫诲瀷锛� +// 鍒欏皢璇ョ被鍨嬩笂鐨� ComVisible 鐗规�ц缃负 true銆� +[assembly: ComVisible(false)] + +// 濡傛灉姝ら」鐩悜 COM 鍏紑锛屽垯涓嬪垪 GUID 鐢ㄤ簬绫诲瀷搴撶殑 ID +[assembly: Guid("9e79a0fb-3e1e-47cb-b0e0-4c969655489f")] + +// 绋嬪簭闆嗙殑鐗堟湰淇℃伅鐢变笅闈㈠洓涓�肩粍鎴�: +// +// 涓荤増鏈� +// 娆$増鏈� +// 鍐呴儴鐗堟湰鍙� +// 淇鍙� +// +// 鍙互鎸囧畾鎵�鏈夎繖浜涘�硷紝涔熷彲浠ヤ娇鐢ㄢ�滃唴閮ㄧ増鏈彿鈥濆拰鈥滀慨璁㈠彿鈥濈殑榛樿鍊硷紝 +// 鏂规硶鏄寜濡備笅鎵�绀轰娇鐢ㄢ��*鈥�: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Resources.Designer.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Resources.Designer.cs" new file mode 100644 index 0000000..5c70cdc --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Resources.Designer.cs" @@ -0,0 +1,63 @@ +锘�//------------------------------------------------------------------------------ +// <auto-generated> +// 姝や唬鐮佺敱宸ュ叿鐢熸垚銆� +// 杩愯鏃剁増鏈�:4.0.30319.42000 +// +// 瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋� +// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢浼氫涪澶便�� +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace GenerateCode_WeiBen_WMS.Properties { + using System; + + + /// <summary> + /// 涓�涓己绫诲瀷鐨勮祫婧愮被锛岀敤浜庢煡鎵炬湰鍦板寲鐨勫瓧绗︿覆绛夈�� + /// </summary> + // 姝ょ被鏄敱 StronglyTypedResourceBuilder + // 绫婚�氳繃绫讳技浜� ResGen 鎴� Visual Studio 鐨勫伐鍏疯嚜鍔ㄧ敓鎴愮殑銆� + // 鑻ヨ娣诲姞鎴栫Щ闄ゆ垚鍛橈紝璇风紪杈� .ResX 鏂囦欢锛岀劧鍚庨噸鏂拌繍琛� ResGen + // (浠� /str 浣滀负鍛戒护閫夐」)锛屾垨閲嶆柊鐢熸垚 VS 椤圭洰銆� + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// <summary> + /// 杩斿洖姝ょ被浣跨敤鐨勭紦瀛樼殑 ResourceManager 瀹炰緥銆� + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GenerateCode_WeiBen_WMS.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// 閲嶅啓褰撳墠绾跨▼鐨� CurrentUICulture 灞炴�э紝瀵� + /// 浣跨敤姝ゅ己绫诲瀷璧勬簮绫荤殑鎵�鏈夎祫婧愭煡鎵炬墽琛岄噸鍐欍�� + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Resources.resx" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Resources.resx" new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Resources.resx" @@ -0,0 +1,117 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Settings.Designer.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Settings.Designer.cs" new file mode 100644 index 0000000..9773c87 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Settings.Designer.cs" @@ -0,0 +1,26 @@ +锘�//------------------------------------------------------------------------------ +// <auto-generated> +// 姝や唬鐮佺敱宸ュ叿鐢熸垚銆� +// 杩愯鏃剁増鏈�:4.0.30319.42000 +// +// 瀵规鏂囦欢鐨勬洿鏀瑰彲鑳戒細瀵艰嚧涓嶆纭殑琛屼负锛屽苟涓斿鏋� +// 閲嶆柊鐢熸垚浠g爜锛岃繖浜涙洿鏀瑰皢浼氫涪澶便�� +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace GenerateCode_WeiBen_WMS.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Settings.settings" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Settings.settings" new file mode 100644 index 0000000..3964565 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Properties/Settings.settings" @@ -0,0 +1,7 @@ +锘�<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile> diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Robot.ico" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Robot.ico" new file mode 100644 index 0000000..f614194 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Robot.ico" Binary files differ diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/BLL\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/BLL\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..95ae98c --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/BLL\346\250\241\346\235\277.txt" @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using System.Data; +using WIP_common; +using WIP_DAL; +using WIP_Models; + +namespace WIP_BLL +{ + /// <summary> + /// $ChinaComment$业务处理类 + /// </summary> + public class $FilePrefixName$BLL + { + private readonly $FilePrefixName$DAL $TableAlias$DAL = new $FilePrefixName$DAL(); + + #region Add + + /// <summary> + /// 增加一条$ChinaComment$数据 + /// </summary> + /// <param name="param">要增加的$ChinaComment$参数类</param> + /// <param name="creator">创建人</param> + /// <returns>插入的最新主键值</returns> + public int Add($AddEntityParam$ param,string creator) + { + $EntityName$ model = null; + model = WIPCommon.T1ToT2<$AddEntityParam$, $EntityName$>(param); + model.creator = model.lastModifier = creator; + model.createTime = model.lastModifyTime = DateTime.Now; + model.delFlag=false; + return $TableAlias$DAL.Add(model); + } + + #endregion + + #region Edit + + /// <summary> + /// 更新一条$ChinaComment$数据 + /// </summary> + /// <param name="model">要更新的$ChinaComment$实体</param> + /// <param name="lastModifier">最后修改人</param> + /// <returns>更新是否成功</returns> + public bool Update($EntityName$ model,string lastModifier) + { + model.lastModifier = lastModifier; + model.lastModifyTime = DateTime.Now; + return $TableAlias$DAL.Update(model); + } + + #endregion + + #region Del + + /// <summary> + /// 删除一条$ChinaComment$数据 + /// </summary> + /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> + /// <returns>是否删除成功</returns> + public bool Delete(string $PrimaryKey$) + { + return $TableAlias$DAL.Delete($PrimaryKey$); + } + + #endregion + + #region Enable + + /// <summary> + /// 禁启用$ChinaComment$数据 + /// </summary> + /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> + /// <param name="delFlag">禁用1/启用0</param> + /// <param name="lastModifier">最后修改人</param> + /// <param name="transModel">事务类</param> + /// <returns>是否禁启用成功</returns> + public bool Enable(string $PrimaryKey$, string delFlag, string lastModifier) + { + return $TableAlias$DAL.Enable($PrimaryKey$,delFlag,lastModifier); + } + + #endregion + + #region QueryList(Page) + + /// <summary> + /// 获得$ChinaComment$数据列表(分页) + /// </summary> + /// <param name="pageParam">查询参数</param> + /// <returns>$ChinaComment$分页数据</returns> + public PageResultModel<$EntityName$> GetModelListForPage(Query$Modulelogo$Param pageParam) + { + DataSet ds = $TableAlias$DAL.GetModelListForPage(pageParam); + List<$EntityName$> list = DataTableToList(ds.Tables[0]); + int total = Convert.ToInt32(ds.Tables[1].Rows[0]["COUNT"]); + PageResultModel<$EntityName$> result = new PageResultModel<$EntityName$>(); + result.total = total; + result.rows = list; + return result; + } + + #endregion + + #region QueryList + + /// <summary> + /// 获得$ChinaComment$数据列表 + /// </summary> + /// <param name="strWhere">查询条件</param> + /// <returns>$ChinaComment$数据集合</returns> + public List<$EntityName$> GetModelList(string strWhere) + { + DataSet ds = $TableAlias$DAL.GetList(strWhere); + return DataTableToList(ds.Tables[0]); + } + + #endregion + + #region Query(Single) + + /// <summary> + /// 得到一个$ChinaComment$实体 + /// </summary> + /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> + /// <returns>$ChinaComment$实体</returns> + public $EntityName$ GetModel(string $PrimaryKey$) + { + + return $TableAlias$DAL.GetModel($PrimaryKey$); + } + + #endregion + + #region Other + + /// <summary> + /// 是否存在该$ChinaComment$记录 + /// </summary> + /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> + /// <returns></returns> + public bool Exists(string $PrimaryKey$, int? id = null) + { + return $TableAlias$DAL.Exists($PrimaryKey$,id); + } + + #endregion + + #region Common + + /// <summary> + /// 获得$ChinaComment$数据列表 + /// </summary> + private List<$EntityName$> DataTableToList(DataTable dt) + { + List<$EntityName$> modelList = new List<$EntityName$>(); + int rowsCount = dt.Rows.Count; + if (rowsCount > 0) + { + $EntityName$ model; + for (int n = 0; n < rowsCount; n++) + { + model = new $EntityName$(); + var dataRow = dt.Rows[n]; + + $ToSingleModel$ + + + modelList.Add(model); + } + } + return modelList; + } + + #endregion + + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Controller\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Controller\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..7a25ce1 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Controller\346\250\241\346\235\277.txt" @@ -0,0 +1,274 @@ +using $ProjectNamePrefix$.Core.Common.HttpContextUser; +using $ProjectNamePrefix$.Core.Extensions.Others; +using $ProjectNamePrefix$.Core.IServices; +using $ProjectNamePrefix$.Core.Model; +using $ProjectNamePrefix$.Core.Model.CommonModel; +using $ProjectNamePrefix$.Core.Model.Models; +using $ProjectNamePrefix$.Core.Model.ParamModels; +using $ProjectNamePrefix$.Core.Utility; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Threading.Tasks; +using System; + +namespace $ProjectNamePrefix$.Core.Api.Controllers +{ + /// <summary> + /// $ChinaComment$ + /// </summary> + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class $EntityName$Controller : ControllerBase + { + private readonly I$EntityName$Services _$EntityName$Services; + private readonly IUser _user; + private readonly ILogger<$EntityName$Controller> _logger; + + public $EntityName$Controller(I$EntityName$Services $EntityName$Services, IUser user, ILogger<$EntityName$Controller> logger) + { + _$EntityName$Services = $EntityName$Services; + _user = user; + _logger = logger; + } + + /// <summary> + /// 分页获取$ChinaComment$列表 + /// </summary> + /// <param name="param">筛选条件</param> + /// <returns>获取结果</returns> + [HttpPost] + public async Task<MessageModel<PageModel<$EntityName$>>> Get([FromBody] $EntityName$Param param) + { + if (string.IsNullOrEmpty(param.searchVal) || string.IsNullOrWhiteSpace(param.searchVal)) + { + param.searchVal = string.Empty; + } + + var whereConditions = WhereConditionsExtensions.GetWhereConditions<$EntityName$, $EntityName$Param>(param); + if (!whereConditions.IsSuccess) { + return new MessageModel<PageModel<$EntityName$>>() + { + msg = whereConditions.ErrMsg, + success = false, + response = null + }; + } + var data = await _$EntityName$Services.QueryPage(whereConditions.data, param.page, param.pageSize, " $OrderByName$ desc "); + return new MessageModel<PageModel<$EntityName$>>() + { + msg = "获取成功", + success = true, + response = data + }; + + } + + /// <summary> + /// 获取单个$ChinaComment$ + /// </summary> + /// <param name="id">主键</param> + /// <returns>获取结果</returns> + [HttpGet] + public async Task<MessageModel<$EntityName$>> Get(int id = 0) + { + return new MessageModel<$EntityName$>() + { + msg = "获取成功", + success = true, + response = await _$EntityName$Services.QueryById(id) + }; + } + + /// <summary> + /// 新增$ChinaComment$ + /// </summary> + /// <param name="request">要新增的$ChinaComment$对象</param> + /// <returns></returns> + [HttpPost] + public async Task<MessageModel<string>> Post([FromBody] $EntityName$ request) + { + try + { + #region 验证 + MessageModel<string> retBody = null; + retBody = ValidateDataHelper.CommonValidateIsNULL<$EntityName$, string>(request); + if (retBody != null) + { + return retBody; + } + + List<ValidateModel> columnsList = null; + columnsList = new List<ValidateModel>() { + $ValidateEmptyForInsert$ + }; + retBody = ValidateDataHelper.CommonValidate<$EntityName$, string>(request, columnsList); + if (retBody != null) + { + return retBody; + } + #endregion + + request.CreateTime = request.ModifyTime = DateTime.Now; + request.CreateBy = request.ModifyBy = _user.Name; + request.CreateId = request.ModifyId = _user.ID; + request.OperationRemark = "添加"; + var id = await _$EntityName$Services.Add(request); + var success = id > 0; + + if (success) + { + return MessageModel<string>.Success("添加成功", id.ObjToString()); + } + return MessageModel<string>.Fail("添加失败"); + } + catch (Exception ex) + { + _logger.LogError(ex,"新增$ChinaComment$出现异常:" + ex.Message); + return MessageModel<string>.Fail("新增$ChinaComment$出现异常:" + ex.Message); + } + } + + /// <summary> + /// 更新$ChinaComment$ + /// </summary> + /// <param name="request">要更新的$ChinaComment$对象</param> + /// <returns>更新结果</returns> + [HttpPut] + public async Task<MessageModel<string>> Put([FromBody] $EntityName$ request) + { + try + { + #region 验证 + MessageModel<string> retBody = null; + retBody = ValidateDataHelper.CommonValidateIsNULL<$EntityName$, string>(request); + if (retBody != null) + { + return retBody; + } + + List<ValidateModel> columnsList = null; + columnsList = new List<ValidateModel>() + { + $ValidateEmptyForUpdate$ + }; + retBody = ValidateDataHelper.CommonValidate<$EntityName$, string>(request, columnsList); + if (retBody != null) + { + return retBody; + } + #endregion + + var dbObj = await _$EntityName$Services.QueryById(request.Id); + if (dbObj == null) + { + return MessageModel<string>.Fail("数据不存在!"); + } + + request.ModifyTime = DateTime.Now; + request.ModifyBy = _user.Name; + request.ModifyId = _user.ID; + request.OperationRemark = "更新"; + var success = await _$EntityName$Services.Update(request); + + if (success) + { + return MessageModel<string>.Success("更新成功", request.Id.ObjToString()); + } + return MessageModel<string>.Fail("更新失败"); + } + catch (Exception ex) + { + _logger.LogError(ex,"更新$ChinaComment$出现异常:" + ex.Message); + return MessageModel<string>.Fail("更新$ChinaComment$出现异常:" + ex.Message); + } + } + + /// <summary> + /// 删除$ChinaComment$ + /// </summary> + /// <param name="id">主键</param> + /// <returns>删除结果</returns> + [HttpDelete] + public async Task<MessageModel<string>> Delete(int id = 0) + { + try + { + var data = new MessageModel<string>(); + if (id > 0) + { + var detail = await _$EntityName$Services.QueryById(id); + if (detail != null) + { + data.success = await _$EntityName$Services.DeleteById(detail.Id); + if (data.success) + { + data.msg = "删除成功"; + data.response = detail?.Id.ObjToString(); + } + } + else { + return MessageModel<string>.Fail("数据不存在!"); + } + } + else + { + data.success = false; + data.msg = "删除失败,$ChinaComment$不存在"; + } + return data; + } + catch (Exception ex) + { + _logger.LogError(ex,"删除$ChinaComment$出现异常:" + ex.Message); + return MessageModel<string>.Fail("删除$ChinaComment$出现异常:" + ex.Message); + } + } + + /// <summary> + /// 逻辑删除$ChinaComment$ + /// </summary> + /// <param name="id">主键</param> + /// <returns>删除结果</returns> + [HttpDelete] + public async Task<MessageModel<string>> LogicDelete(int id = 0) + { + try + { + var data = new MessageModel<string>(); + if (id > 0) + { + var detail = await _$EntityName$Services.QueryById(id); + if (detail != null) + { + detail.ModifyTime = DateTime.Now; + detail.ModifyBy = _user.Name; + detail.ModifyId = _user.ID; + detail.IsDeleted = true; + detail.OperationRemark = "删除"; + data.success = await _$EntityName$Services.Update(detail); + if (data.success) + { + data.msg = "删除成功"; + data.response = detail?.Id.ObjToString(); + } + } + } + else + { + data.success = false; + data.msg = "删除失败,数据不存在"; + } + return data; + } + catch (Exception ex) + { + _logger.LogError(ex,"逻辑删除$ChinaComment$出现异常:" + ex.Message); + return MessageModel<string>.Fail("逻辑删除$ChinaComment$出现异常:" + ex.Message); + } + } + } +} \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/DAL\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/DAL\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..90bb3f9 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/DAL\346\250\241\346\235\277.txt" @@ -0,0 +1,257 @@ +using System; +using System.Text; +using System.Data.SqlClient; +using System.Data; +using WIP_Models; + +namespace WIP_DAL +{ + /// <summary> + /// $ChinaComment$数据访问类 + /// </summary> + public class $FilePrefixName$DAL + { + #region Add + + /// <summary> + /// 增加一条$ChinaComment$数据 + /// </summary> + /// <param name="model">要插入的$ChinaComment$实体</param> + /// <param name="transModel">事务类</param> + /// <returns>插入生成的最新主键值</returns> + public int Add($EntityName$ model,TransactionModel transModel = null) + { + SqlParameter param_id = new SqlParameter(); + param_id.ParameterName = "@id"; + param_id.SqlDbType = SqlDbType.Int; + param_id.Direction = ParameterDirection.Output; + + $AddSqlParameter$ + + int rowsAffected; + if (transModel != null) + { + DbHelperSQL.RunProcedure(transModel.conn,transModel.trans, "$AddProcName$", parameters, out rowsAffected); + } + else + { + DbHelperSQL.RunProcedure("$AddProcName$", parameters, out rowsAffected); + } + return (int)parameters[parameters.Length - 1].Value; + } + + #endregion + + #region Edit + + /// <summary> + /// 更新一条$ChinaComment$数据 + /// </summary> + /// <param name="model">要更新的$ChinaComment$实体</param> + /// <param name="transModel">事务类</param> + /// <returns>是否更新成功</returns> + public bool Update($EntityName$ model,TransactionModel transModel = null) + { + $UpdateSqlParameter$ + + int rowsAffected = 0; + if (transModel != null) + { + DbHelperSQL.RunProcedure(transModel.conn,transModel.trans, "$UpdateProcName$", parameters, out rowsAffected); + } + else + { + DbHelperSQL.RunProcedure("$UpdateProcName$", parameters, out rowsAffected); + } + if (rowsAffected > 0) + { + return true; + } + else + { + return false; + } + } + + #endregion + + #region Del + + /// <summary> + /// 删除一条$ChinaComment$数据 + /// </summary> + /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> + /// <param name="transModel">事务类</param> + /// <returns>是否删除成功</returns> + public bool Delete(string $PrimaryKey$,TransactionModel transModel = null) + { + + StringBuilder strSql = new StringBuilder(); + strSql.Append("DELETE FROM $TableName$ "); + strSql.Append(" WHERE $PrimaryKey$=@$PrimaryKey$"); + SqlParameter[] parameters = { + new SqlParameter("@$PrimaryKey$", SqlDbType.NVarChar,50) + }; + parameters[0].Value = $PrimaryKey$; + + int rows = 0; + if (transModel != null) + { + rows = DbHelperSQL.ExecuteSql(transModel.conn, transModel.trans, strSql.ToString(), parameters); + } + else + { + rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); + } + if (rows > 0) + { + return true; + } + else + { + return false; + } + } + + #endregion + + #region Enable + + /// <summary> + /// 禁启用$ChinaComment$数据 + /// </summary> + /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> + /// <param name="delFlag">禁用1/启用0</param> + /// <param name="lastModifier">最后修改人</param> + /// <param name="transModel">事务类</param> + /// <returns>是否禁启用成功</returns> + public bool Enable(string $PrimaryKey$, string delFlag, string lastModifier, TransactionModel transModel = null) + { + StringBuilder strSql = new StringBuilder(); + strSql.Append(" UPDATE $TableName$ SET delflag=@delFlag "); + strSql.Append(" ,lastModifier=@lastModifier "); + strSql.Append(" ,lastModifyTime=@lastModifyTime "); + strSql.Append(" WHERE $PrimaryKey$=@$PrimaryKey$"); + SqlParameter[] parameters = { + new SqlParameter("@delFlag", SqlDbType.NVarChar,10) , + new SqlParameter("@lastModifier", SqlDbType.NVarChar,20) , + new SqlParameter("@lastModifyTime", SqlDbType.DateTime) , + new SqlParameter("@$PrimaryKey$", SqlDbType.NVarChar,50) + }; + parameters[0].Value = delFlag; + parameters[1].Value = lastModifier; + parameters[2].Value = DateTime.Now; + parameters[3].Value = $PrimaryKey$; + + int rows = 0; + if (transModel != null) + { + rows = DbHelperSQL.ExecuteSql(transModel.conn, transModel.trans, strSql.ToString(), parameters); + } + else + { + rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); + } + return rows > 0 ? true : false; + } + + #endregion + + #region QueryList(Page) + + /// <summary> + /// 获得$ChinaComment$数据列表(分页) + /// </summary> + /// <param name="pageParam">分页实体数据</param> + /// <returns>$ChinaComment$列表DataSet</returns> + public DataSet GetModelListForPage(Query$Modulelogo$Param pageParam) + { + $QueryPageSqlParameter$ + + return DbHelperSQL.RunProcedure("$GetPageListProcName$", parameters, "pagetable"); + } + + #endregion + + #region QueryList + + /// <summary> + /// 获得$ChinaComment$数据列表 + /// </summary> + /// <param name="strWhere">查询条件</param> + /// <returns>$ChinaComment$列表DataSet</returns> + public DataSet GetList(string strWhere) + { + SqlParameter[] parameters = { + new SqlParameter("@strWhere", SqlDbType.NVarChar,500) + }; + parameters[0].Value = strWhere; + return DbHelperSQL.RunProcedure("$GetListProcName$", parameters, "table"); + } + + #endregion + + #region Query(Single) + + /// <summary> + /// 得到一个$ChinaComment$实体 + /// </summary> + /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> + /// <returns>$ChinaComment$实体</returns> + public $EntityName$ GetModel(string $PrimaryKey$) + { + SqlParameter[] parameters = { + new SqlParameter("@$PrimaryKey$", SqlDbType.VarChar,50) + }; + parameters[0].Value = $PrimaryKey$; + + DataSet ds = DbHelperSQL.RunProcedure("$GetSingleProcName$", parameters, "pagetable"); + + $EntityName$ model = new $EntityName$(); + + if (ds.Tables[0].Rows.Count == 1) + { + var dataRow = ds.Tables[0].Rows[0]; + + $ToSingleModel$ + + return model; + } + else + { + return null; + } + } + + #endregion + + #region Other + + /// <summary> + /// 是否存在该$ChinaComment$记录 + /// </summary> + /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> + /// <returns>是否存在该$ChinaComment$记录</returns> + public bool Exists(string $PrimaryKey$, int? id = null) + { + StringBuilder strSql = new StringBuilder(); + strSql.Append("SELECT COUNT(1) FROM $TableName$"); + strSql.Append(" WHERE "); + strSql.Append(" $PrimaryKey$ = @$PrimaryKey$ "); + if (id != null) + { + strSql.Append(" AND id <> " + id.ToString()); + } + SqlParameter[] parameters = { + new SqlParameter("@$PrimaryKey$", SqlDbType.NVarChar,50) }; + parameters[0].Value = $PrimaryKey$; + + return DbHelperSQL.Exists(strSql.ToString(), parameters); + } + + #endregion + + } +} + + diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/AddModel\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/AddModel\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..411ea68 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/AddModel\346\250\241\346\235\277.txt" @@ -0,0 +1,14 @@ +using System; +using System.Runtime.Serialization; + +namespace WIP_Models +{ + /// <summary> + /// 新增$ChinaComment$参数类 + /// </summary> + [DataContract] + public class $AddEntityParam$ + { + $AddAttributes$ + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/InputModel\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/InputModel\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..b7f2a00 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/InputModel\346\250\241\346\235\277.txt" @@ -0,0 +1,48 @@ +using Furion.Extras.Admin.NET; +using Furion.Extras.Admin.NET.Extension; +using Furion.Extras.Admin.NET.Service; +using System.ComponentModel.DataAnnotations; + +namespace Admin.NET.Application +{ + /// <summary> + /// 分页查询$ChinaComment$输入参数 + /// </summary> + public class $EntityName$PageInput : PageInputCustomBase + { + $QueryAttributes$ + } + + /// <summary> + /// 新增$ChinaComment$输入参数 + /// </summary> + public class Add$EntityName$Input : BasicsDEntity + { + $AddAttributes$ + } + + /// <summary> + /// 更新$ChinaComment$输入参数 + /// </summary> + public class Update$EntityName$Input : Add$EntityName$Input + { + [Required(ErrorMessage = "Id主键不能为空")] + public virtual new long Id { get; set; } + } + + /// <summary> + /// 删除$ChinaComment$输入参数 + /// </summary> + public class Delete$EntityName$Input + { + public List<long> Id { get; set; } + } + + /// <summary> + /// 单个查询$ChinaComment$输入参数 + /// </summary> + public class Query$EntityName$Input : BaseId + { + + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/OutputModel\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/OutputModel\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..c09441d --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Entity/OutputModel\346\250\241\346\235\277.txt" @@ -0,0 +1,22 @@ +using Admin.NET.Core.Helper.ExcelHelper; +using Furion.Extras.Admin.NET; +using Microsoft.EntityFrameworkCore; + +namespace Admin.NET.Application +{ + /// <summary> + /// 查询$ChinaComment$输出参数 + /// </summary> + public class $EntityName$Output : BasicsDEntity + { + $QueryOutputAttributes$ + } + + /// <summary> + /// 导出$ChinaComment$输出参数 + /// </summary> + public class Export$EntityName$Output + { + $ExportOutputAttributes$ + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/InitSQL\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/InitSQL\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..f5de8a6 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/InitSQL\346\250\241\346\235\277.txt" @@ -0,0 +1,14 @@ +USE $DataBaseName$ +GO +------------------------------------ +--用途:初始化接口管理表-$ChinaComment$ +--说明: +--作者: $Author$ +--时间:$CurDate$ +------------------------------------ +INSERT INTO Modules ([IsDeleted], [Name], [LinkUrl], [Area], [Controller], [Action], [Icon], [Code], [OrderSort], [Description], [IsMenu], [Enabled], [CreateId], [CreateBy], [CreateTime], [ModifyId], [ModifyBy], [ModifyTime], [ParentId]) VALUES ('0', N'查询$ChinaComment$', N'/api/$TableName$/get', NULL, NULL, NULL, NULL, NULL, '0', NULL, '0', '1', '12', N'sys', GETDATE(), NULL, NULL,GETDATE(), '0'); +INSERT INTO Modules ([IsDeleted], [Name], [LinkUrl], [Area], [Controller], [Action], [Icon], [Code], [OrderSort], [Description], [IsMenu], [Enabled], [CreateId], [CreateBy], [CreateTime], [ModifyId], [ModifyBy], [ModifyTime], [ParentId]) VALUES ('0', N'新增$ChinaComment$', N'/api/$TableName$/post', NULL, NULL, NULL, NULL, NULL, '0', NULL, '0', '1', '12', N'sys', GETDATE(), NULL, NULL, GETDATE(), '0'); +INSERT INTO Modules ([IsDeleted], [Name], [LinkUrl], [Area], [Controller], [Action], [Icon], [Code], [OrderSort], [Description], [IsMenu], [Enabled], [CreateId], [CreateBy], [CreateTime], [ModifyId], [ModifyBy], [ModifyTime], [ParentId]) VALUES ('0', N'修改$ChinaComment$', N'/api/$TableName$/put', NULL, NULL, NULL, NULL, NULL, '0', NULL, '0', '1', '12', N'sys', GETDATE(), NULL, NULL, GETDATE(), '0'); +INSERT INTO Modules ([IsDeleted], [Name], [LinkUrl], [Area], [Controller], [Action], [Icon], [Code], [OrderSort], [Description], [IsMenu], [Enabled], [CreateId], [CreateBy], [CreateTime], [ModifyId], [ModifyBy], [ModifyTime], [ParentId]) VALUES ('0', N'删除$ChinaComment$', N'/api/$TableName$/delete', NULL, NULL, NULL, NULL, NULL, '0', NULL, '0', '1', '12', N'sys', GETDATE(), NULL, NULL, GETDATE(), '0'); +GO + diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\344\277\256\346\224\271\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\213.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\344\277\256\346\224\271\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\213.txt" new file mode 100644 index 0000000..57fe9c7 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\344\277\256\346\224\271\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\213.txt" @@ -0,0 +1,17 @@ +IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$UpdateProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) + DROP PROCEDURE [$UpdateProcName$] +GO +------------------------------------ +--用途:修改一条$ChinaComment$记录 +--说明: +--作者: $Author$ +--时间:$CurDate$ +------------------------------------ +CREATE PROCEDURE $UpdateProcName$ + $update_cols_params$ +AS + UPDATE [$TableName$] SET + $update_cols_assignment$ + WHERE $Primary$=@$Primary$ + +GO \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\344\277\256\346\224\271\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\2132.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\344\277\256\346\224\271\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\2132.txt" new file mode 100644 index 0000000..0a5a6b7 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\344\277\256\346\224\271\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\2132.txt" @@ -0,0 +1,17 @@ +IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$UpdateProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) + DROP PROCEDURE [$UpdateProcName$] +GO +------------------------------------ +--用途:修改一条$ChinaComment$记录 +--说明: +--作者: $Author$ +--时间:$CurDate$ +------------------------------------ +CREATE PROCEDURE $UpdateProcName$ + $update_cols_params$ +AS + UPDATE [$TableName$] SET + $update_cols_assignment2$ + WHERE $Primary$=@$Primary$ + +GO \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\210\206\351\241\265\345\255\230\345\202\250\350\277\207\347\250\213.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\210\206\351\241\265\345\255\230\345\202\250\350\277\207\347\250\213.txt" new file mode 100644 index 0000000..3c43c14 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\210\206\351\241\265\345\255\230\345\202\250\350\277\207\347\250\213.txt" @@ -0,0 +1,39 @@ +IF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$GetPageListProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) + DROP PROCEDURE [$GetPageListProcName$] +GO +------------------------------------ +--用途:获得$ChinaComment$数据列表(分页) +--说明: +--作者: $Author$ +--时间:$CurDate$ +------------------------------------ +CREATE PROCEDURE $GetPageListProcName$ + $page_cols_params$ + @pageIndex int, + @pageSize int +AS + DECLARE @startRow int, @endRow int + + SET nocount ON; + + SET @startRow = (@pageIndex - 1) * @pageSize +1 + SET @endRow = @startRow + @pageSize -1 + + -- 查询分页数据 + SELECT $strQueryCol_1$ + FROM + ( + SELECT ROW_NUMBER() Over(order by id desc ) AS row_num, + $strQueryCol_2$ + FROM $TableName$ AS $TableAlias$ WITH(NOLOCK) + WHERE $where_cols_params$ + ) AS tabledata + WHERE row_num BETWEEN cast(@startRow as nvarchar(20)) AND +cast(@endRow as nvarchar(20)) + + -- 查询总条数 + SELECT COUNT(1) AS COUNT FROM $TableName$ AS $TableAlias$ WITH(NOLOCK) + WHERE $where_cols_params$ + + SET nocount OFF; +GO + diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\210\227\350\241\250\345\255\230\345\202\250\350\277\207\347\250\213.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\210\227\350\241\250\345\255\230\345\202\250\350\277\207\347\250\213.txt" new file mode 100644 index 0000000..cb77c35 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\210\227\350\241\250\345\255\230\345\202\250\350\277\207\347\250\213.txt" @@ -0,0 +1,34 @@ +IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$GetListProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) + DROP PROCEDURE [$GetListProcName$] +GO +------------------------------------ +--用途:获得$ChinaComment$数据列表 +--说明: +--作者: $Author$ +--时间:$CurDate$ +------------------------------------ +CREATE PROCEDURE $GetListProcName$ + @strWhere nvarchar(500) -- 查询条件 +AS + DECLARE @strQueryCol nvarchar(max), + @strSql nvarchar(max) + + + SET nocount ON; + + SET @strQueryCol=' $strQueryCol$ ' + + SET @strSql= ' SELECT '+@strQueryCol + +' FROM $TableName$ AS $TableAlias$ WITH(NOLOCK) WHERE 1=1 ' + + IF(@strWhere <> '') + BEGIN + SET @strSql=@strSql+' AND '+@strWhere + END + + SET @strSql=@strSql+' ORDER BY $TableAlias$.$orderByName$ DESC ' + EXEC SP_EXECUTESQL @strSql + + SET nocount OFF; +GO + diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\242\236\345\212\240\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\213.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\242\236\345\212\240\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\213.txt" new file mode 100644 index 0000000..6960ec1 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\242\236\345\212\240\344\270\200\346\235\241\350\256\260\345\275\225\345\255\230\345\202\250\350\277\207\347\250\213.txt" @@ -0,0 +1,21 @@ +IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$AddProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) + DROP PROCEDURE [$AddProcName$] +GO +------------------------------------ +--用途:增加一条$ChinaComment$记录 +--说明: +--作者: $Author$ +--时间:$CurDate$ +------------------------------------ +CREATE PROCEDURE $AddProcName$ + @id int output, + $insert_cols_params$ +AS + INSERT INTO [$TableName$]( + $insert_cols$ + )VALUES( + $insert_cols_values$ + ) + SET @id = @@IDENTITY + RETURN @id +GO \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\276\227\345\210\260\344\270\200\344\270\252\345\256\236\344\275\223\345\255\230\345\202\250\350\277\207\347\250\213.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\276\227\345\210\260\344\270\200\344\270\252\345\256\236\344\275\223\345\255\230\345\202\250\350\277\207\347\250\213.txt" new file mode 100644 index 0000000..1322c15 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Proc/\345\276\227\345\210\260\344\270\200\344\270\252\345\256\236\344\275\223\345\255\230\345\202\250\350\277\207\347\250\213.txt" @@ -0,0 +1,19 @@ +IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$GetSingleProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) + DROP PROCEDURE [$GetSingleProcName$] +GO +------------------------------------ +--用途:得到一个$ChinaComment$实体 +--说明: +--作者: $Author$ +--时间:$CurDate$ +------------------------------------ +CREATE PROCEDURE $GetSingleProcName$ + @$Primary$ $DataType$ +AS + SET nocount ON; + + SELECT $strQueryCol$ + FROM $TableName$ AS $TableAlias$ WITH(NOLOCK) WHERE $Primary$=@$Primary$ + + SET nocount OFF; +GO \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Services\346\216\245\345\217\243\345\256\236\347\216\260\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Services\346\216\245\345\217\243\345\256\236\347\216\260\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..0cfb36c --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Services\346\216\245\345\217\243\345\256\236\347\216\260\346\250\241\346\235\277.txt" @@ -0,0 +1,192 @@ +using Admin.NET.Core.BasicInformation.Entity; +using Furion.DatabaseAccessor; +using Furion.DependencyInjection; +using Furion.DynamicApiController; +using Furion.Extras.Admin.NET; +using Furion.Extras.Admin.NET.Extension; +using Furion.FriendlyException; +using Mapster; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; +using PandaWork.Infrastructure; +using System.Data; +using System.Linq.Dynamic.Core; +using Furion.LinqBuilder; +using System.Linq.Expressions; +using Admin.NET.Core.Helper.ExcelHelper; + +namespace Admin.NET.Application +{ + /// <summary> + /// $ChinaComment$服务接口实现 + /// </summary> + [ApiDescriptionSettings("$GroupName$", Name = "$ChinaComment$", Order = 100)] + public class $EntityName$Service : ControllerBase, I$EntityName$Service, IDynamicApiController, ITransient + { + private readonly IRepository<$EntityName$, MasterDbContextLocator> _$EntityName_FirstLetterLower$Rep; + /// <summary> + /// $ChinaComment$服务构造函数 + /// </summary> + /// <param name="$EntityName_FirstLetterLower$Rep">$ChinaComment$服务仓储对象</param> + public $EntityName$Service(IRepository<$EntityName$, MasterDbContextLocator> $EntityName_FirstLetterLower$Rep) + { + _$EntityName_FirstLetterLower$Rep = $EntityName_FirstLetterLower$Rep; + } + + /// <summary> + /// 分页查询$ChinaComment$ + /// </summary> + /// <param name="input">分页查询参数</param> + /// <returns></returns> + [HttpGet("/$EntityName$/page")] + [DisableOpLog] + public async Task<PageResult<$EntityName$Output>> Page([FromQuery] $EntityName$PageInput input) + { + if (input == null) + { + throw Oops.Oh(ErrorCode.D4008); + } + + #region 动态构造查询条件 + + //动态构造查询条件 + var whereConditions = DynamicGetQueryParams(input); + + #endregion + + var pageList= await _$EntityName_FirstLetterLower$Rep.DetachedEntities + .Where(whereConditions.data) + .OrderBy(PageInputOrder.OrderBuilder<$EntityName$PageInput>(input)) + .ProjectToType<$EntityName$Output>() + .ToADPagedListAsync(input.PageNo, input.PageSize); + return pageList; + } + + /// <summary> + /// 增加$ChinaComment$ + /// </summary> + /// <param name="input">增加参数</param> + /// <returns></returns> + [HttpPost("/$EntityName$/add")] + public async Task<long> Add([FromBody] Add$EntityName$Input input) + { + if (input == null) + { + throw Oops.Oh(ErrorCode.D4008); + } + var $EntityName_FirstLetterLower$ = input.Adapt<$EntityName$>(); + EntityEntry<$EntityName$> entityEntry = await _$EntityName_FirstLetterLower$Rep.InsertAsync($EntityName_FirstLetterLower$); + return entityEntry.Entity.Id; + } + + /// <summary> + /// 更新$ChinaComment$ + /// </summary> + /// <param name="input">更新参数</param> + /// <returns></returns> + [HttpPost("/$EntityName$/update")] + public async Task<long> Update([FromBody] Update$EntityName$Input input) + { + if (input == null || (input.Id) <= 0) + { + throw Oops.Oh(ErrorCode.D1012); + } + var isExist = await _$EntityName_FirstLetterLower$Rep.AnyAsync(u => u.Id == input.Id, false); + if (!isExist) + { + throw Oops.Oh(ErrorCode.D1002); + } + var $EntityName_FirstLetterLower$ = input.Adapt<$EntityName$>(); + await _$EntityName_FirstLetterLower$Rep.UpdateAsync($EntityName_FirstLetterLower$, ignoreNullValues: true); + return input.Id; + } + + /// <summary> + /// 删除$ChinaComment$ + /// </summary> + /// <param name="input">删除参数</param> + /// <returns></returns> + [HttpPost("/$EntityName$/delete")] + public async Task<int> Delete([FromBody] Delete$EntityName$Input input) + { + if (input == null || input.Id.Count == 0) + { + throw Oops.Oh(ErrorCode.D4008); + } + List<$EntityName$> list = new(); + foreach (var item in input.Id) + { + list.Add(new $EntityName$() { Id = item }); + } + await _$EntityName_FirstLetterLower$Rep.DeleteAsync(list); + return input.Id.Count; + } + + /// <summary> + /// 获取$ChinaComment$ + /// </summary> + /// <param name="input">获取对象参数</param> + /// <returns></returns> + [HttpGet("/$EntityName$/detail")] + [DisableOpLog] + public async Task<$EntityName$Output> Get([FromQuery] Query$EntityName$Input input) + { + if (input == null || input.Id <= 0) + { + throw Oops.Oh(ErrorCode.D1012); + } + return (await _$EntityName_FirstLetterLower$Rep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id)).Adapt<$EntityName$Output>(); + } + + /// <summary> + /// 导出$ChinaComment$Excel + /// </summary> + /// <param name="input">筛选条件</param> + /// <returns></returns> + [HttpPost("/$EntityName$/export")] + [DisableOpLog] + public async Task<ActionResult> Export([FromQuery] $EntityName$PageInput input) + { + if (input == null) + { + throw Oops.Oh(ErrorCode.D4008); + } + + #region 动态构造查询条件 + + //动态构造查询条件 + var whereConditions = DynamicGetQueryParams(input); + + #endregion + + var deliveryOrderExportExcel = await _$EntityName_FirstLetterLower$Rep.DetachedEntities + .Where(whereConditions.data) + .ProjectToType<Export$EntityName$Output>() + .ToListAsync(); + var excelBaseResult = new Excel2003Result<Export$EntityName$Output>(deliveryOrderExportExcel, "$ChinaComment$记录" + DateTime.Now.ToString("yyyyMMdd"), false, "$ChinaComment$记录"); + return File(excelBaseResult.GetExcelStream(), "application/vnd.ms-excel"); + } + + /// <summary> + /// 动态构造查询条件 + /// </summary> + /// <param name="input">输入参数</param> + /// <returns></returns> + private FunReturnResultModel<Expression<Func<$EntityName$, bool>>> DynamicGetQueryParams($EntityName$PageInput input) + { + //动态构造查询条件 + var whereConditions = WhereConditionsExtensions.GetWhereConditions<$EntityName$, $EntityName$PageInput>(input); + if (!whereConditions.IsSuccess) + { + throw Oops.Oh("动态构造查询条件失败:" + whereConditions.ErrMsg); + } + + //也可再次自定义构建查询条件 + Expression<Func<$EntityName$, bool>> extendExpression = a => a.IsDeleted == false; + whereConditions.data = whereConditions.data.And(extendExpression); + + return whereConditions; + } + } +} \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Services\346\216\245\345\217\243\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Services\346\216\245\345\217\243\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..f7fcfde --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Services\346\216\245\345\217\243\346\250\241\346\235\277.txt" @@ -0,0 +1,59 @@ +using Furion.Extras.Admin.NET; +using Microsoft.AspNetCore.Mvc; + +namespace Admin.NET.Application +{ + /// <summary> + /// $ChinaComment$服务接口 + /// </summary> + public interface I$EntityName$Service + { + /// <summary> + /// 分页查询$ChinaComment$ + /// </summary> + /// <param name="input">分页查询参数</param> + /// <returns></returns> + Task<PageResult<$EntityName$Output>> Page([FromQuery] $EntityName$PageInput input); + + + /// <summary> + /// 增加$ChinaComment$ + /// </summary> + /// <param name="input">增加参数</param> + /// <returns></returns> + Task<long> Add([FromBody] Add$EntityName$Input input); + + + /// <summary> + /// 更新$ChinaComment$ + /// </summary> + /// <param name="input">更新参数</param> + /// <returns></returns> + Task<long> Update([FromBody] Update$EntityName$Input input); + + + /// <summary> + /// 删除$ChinaComment$ + /// </summary> + /// <param name="input">删除参数</param> + /// <returns></returns> + Task<int> Delete([FromBody] Delete$EntityName$Input input); + + + /// <summary> + /// 获取$ChinaComment$ + /// </summary> + /// <param name="input">获取对象参数</param> + /// <returns></returns> + Task<$EntityName$Output> Get([FromQuery] Query$EntityName$Input input); + + + /// <summary> + /// 导出$ChinaComment$Excel + /// </summary> + /// <param name="input">筛选条件</param> + /// <returns></returns> + Task<ActionResult> Export([FromQuery] $EntityName$PageInput input); + + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/VUE/VUE\346\226\207\344\273\266\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/VUE/VUE\346\226\207\344\273\266\346\250\241\346\235\277.txt" new file mode 100644 index 0000000..6dd3a7a --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/VUE/VUE\346\226\207\344\273\266\346\250\241\346\235\277.txt" @@ -0,0 +1,485 @@ +<template> + <section> + <!--工具条--> + <el-col :span="24" + class="toolbar" + style="padding-bottom: 0px;"> + <el-form :inline="true" + @submit.native.prevent> + <toolbar :buttonList="buttonList" + @callFunction="callFunction"> + </toolbar> + <!-- 搜索 --> + <SearchForm :commonSearchOptionSet="c_commonSearchOptionSet" + :searchValControlStyle="c_searchValControlStyle" + :searchFormInputPlaceholder="c_searchFormInputPlaceholder" + :searchFormInputAttrs="c_searchFormInputAttrs" + :formOptions="h_formOptions" + :drawerSize="h_drawerSize" + :labelWidth="h_labelWidth" + :controlStyle="h_controlStyle" + ref="ChildSearchForm" + @onSearch="_get$Modulelogo$s" /> + </el-form> + </el-col> + + <!--列表--> + <el-table :data="$Modulelogo$s" + :max-height="tableHeight" + highlight-current-row + size="small" + :height="tableHeight" + @current-change="selectCurrentRow" + v-loading="listLoading" + @selection-change="selsChange" + style="width: 99%;"> + <el-table-column type="index" + :index="indexMethod" + label="#" + align="center" + width="50"> + </el-table-column> + $el-table-column$ + <el-table-column label="操作" + fixed="right" + width="180" + v-if="isShowOperatorColumn"> + <template scope="scope"> + <el-button size="small" + icon="el-icon-edit" + type="primary" + v-if="isShowOperatorButton('edit')" + @click="handleEdit(scope.row)">编辑</el-button> + <el-button type="danger" + size="small" + icon="el-icon-delete" + v-if="isShowOperatorButton('del')" + @click="handleDel(scope.row)">删除</el-button> + </template> + </el-table-column> + </el-table> + + <!--工具条--> + <el-col :span="24" + style="margin:10px 10px 10px 0px;" + class="toolbar"> + <el-pagination @size-change="handleSizeChange" + @current-change="handleCurrentChange" + :current-page="page" + background + :page-sizes="[5,10,50,100, 200, 300, 400]" + :page-size="pageSize" + layout="total, sizes, prev, pager, next, jumper" + :total="total"> + </el-pagination> + </el-col> + <!--新增/编辑界面--> + <el-dialog :title="dialogTitle" + :visible.sync="addFormVisible" + :close-on-click-modal="false" + :before-close="cancelHandle"> + <el-form :model="addForm" + size="small" + label-width="120px" + ref="addForm"> + $el-item$ + </el-form> + <div slot="footer" + class="dialog-footer"> + <el-button @click.native="cancelHandle" icon="fa fa-power-off">取消</el-button> + <el-button type="primary" + @click.native="submitDataHandle" + :loading="addLoading" icon="fa fa-send">提交</el-button> + </div> + </el-dialog> + <!--查看界面--> + <el-dialog title="查看" + :visible.sync="viewDetailVisible" + :before-close="cancelHandle"> + <el-form :model="viewDetailForm" + size="small" + disabled="true" + label-width="120px" + ref="viewDetailForm"> + $el-item-view$ + </el-form> + <div slot="footer" + class="dialog-footer"> + <el-button @click.native="closeViewHandle" icon="fa fa-power-off">关闭</el-button> + </div> + </el-dialog> + <!-- 导出组件 --> + <ToolbarExport ref="cmToolbarExport" + :exportFileName="export_exportFileName" + :currentPageData="export_currentPageData" + :exportColumnHeader="export_columnHeader" /> + <!-- 导入Excel组件 --> + <ToolbarImportExcel ref="tbImportExcel" + :importExcelCategroy="emport_excelCategroy" + :templeteFileDownName="emport_templeteFileDownName"></ToolbarImportExcel> + </section> +</template> + +<script> +import util from '../../../util/date' +import { get$Modulelogo$ListPage, remove$Modulelogo$, edit$Modulelogo$, add$Modulelogo$ } from '../../api/api'; +import { getButtonList } from "../../promissionRouter"; +import Toolbar from "../../components/ToolbarButton"; +import SearchForm from "../../components/SearchForm"; +import ToolbarExport from "../../components/ToolbarExport"; +import ToolbarImportExcel from "../../components/ToolbarImportExcel"; +import { formatDate, setformOptionsNewValue } from '../../../util/tools' +import { isShowOperatorButtonCommon, isNeedShowOperatorColumn, isMobile } from '../../../util/common' + + +export default { + components: { Toolbar, SearchForm, ToolbarExport,ToolbarImportExcel },//注册子组件 + data () { + return { + //导入Excel数据相关 + emport_templeteFileDownName: '$emport_templeteFileDownName$.xlsx',//文件下载名字 + emport_excelCategroy: "$emport_excelCategroy$",//上传文件的请求分类 + //导出组件相关 + export_exportFileName: '$ChinaComment$信息',//要导出的文件名 + export_currentPageData: [],//当前页面的列表数据 + export_columnHeader: {$VueExportColumnHeaderStr$},//当前页面列表的表头汉字和属性数组,导出用 + + //搜索框相关 + c_commonSearchOptionSet: "模糊",//通用查询的默认配置,"模糊"或"精准" + c_searchValControlStyle: {//设置通用搜索框的长度等样式 + width: '300px', + }, + c_searchFormInputPlaceholder: '请输入$SearchFormInputPlaceholderStr$',//要给子搜索组件传递的值 + c_searchFormInputAttrs: [$SearchFormInputPlaceholderNameStr$],//要给子搜索组件传递的属性名 + h_controlStyle: {//设置高级搜索控件的长度等样式 + width: '350px', + }, + h_labelWidth: "100px",//显示Label的宽度 + h_drawerSize: "600px",//drawner宽度设置 + h_formOptions: [ + $FormOptionsStr$ + ], + + isShowOperatorColumn: true,// 是否显示【操作】列,true显示 false不显示 + tableHeight: window.innerHeight - 180, // 控制表格的高度 + + isAdd: false, // 是否是新增 + dialogTitle: '', + + //查看有关 + viewDetailVisible: false, + viewDetailForm: {}, + + filters: { + name: '' + }, + $Modulelogo$s: [], + total: 0, + buttonList: [], + currentRow: null, + page: 1, + pageSize: 10, + listLoading: false, + sels: [],//列表选中列 + + addFormVisible: false,//新增界面是否显示 + addLoading: false, + //新增或编辑界面数据 + addForm: { + //注意:这里不需要写初始值,初始值都写在 init_addForm中 + }, + init_addForm: { + //注意:这里写初始值 + } + } + }, + methods: { + //是否显示某个操作按钮 + isShowOperatorButton (flag) { + return isShowOperatorButtonCommon(this.isShowOperatorColumn, flag, this.buttonList) + }, + // 设置索引 + indexMethod (index) { + return (this.page - 1) * this.pageSize + 1 + index + }, + // 时间格式化 + formatterDateTime (row, column, cellValue, index) { + if (cellValue === null || cellValue === '') { + return '' + } + var NewDtime = new Date(Date.parse(cellValue)) + return formatDate(NewDtime, 'yyyy-MM-dd hh:mm:ss') + }, + selectCurrentRow (val) { + this.currentRow = val; + }, + callFunction (item) { + this.filters = { + name: item.search + }; + this[item.Func].apply(this, item); + }, + handleCurrentChange (val) { + this.page = val; + this.get$Modulelogo$s(); + }, + handleSizeChange (val) { + this.pageSize = val; + this.get$Modulelogo$s(); + }, + /** + * 获取请求参数 + * flag:标记,1代表普通分页查询,2代表不分页,获取全部数据 + */ + getPostParam (flag) { + let para = Object.assign({}, this.$refs.ChildSearchForm.getFormData()); + para.page = this.page + para.pageSize = this.pageSize + if (flag === '2') { // 全部导出 + para.page = 1 + para.pageSize = 10000 + } + return para + }, + //点击按钮【查询】 + _get$Modulelogo$s () { + this.page = 1 + this.get$Modulelogo$s() + }, + //获取列表 + get$Modulelogo$s (formValue) { + //this.total = 0 + //this.$Modulelogo$s = null + let para = this.getPostParam('1'); + this.listLoading = true; + get$Modulelogo$ListPage(para).then((res) => { + if (res.data.success) { + this.total = res.data.response.dataCount; + this.$Modulelogo$s = res.data.response.data; + } else { + this.$message({ + message: res.data.msg, + type: 'error' + }); + } + this.listLoading = false; + }); + }, + //获取全部列表 + exportAllData () { + let para = this.getPostParam('2'); + this.listLoading = true; + get$Modulelogo$ListPage(para).then((res) => { + var allData = res.data.response.data; + this.$refs.cmToolbarExport.export2Excel(allData); + this.listLoading = false; + }); + }, + //删除 + handleDel (selRow) { + let row = {}; + if (selRow && selRow != undefined) { + this.currentRow = selRow; + } + row = this.currentRow; + if (!row) { + this.$message({ + message: "请选择要删除的一行数据!", + type: "warning" + }); + return; + } + this.$confirm('确认删除该记录吗?', '提示', { + type: 'warning' + }).then(() => { + this.listLoading = true; + let para = { id: row.Id }; + remove$Modulelogo$(para).then((res) => { + + if (util.isEmt.format(res)) { + this.listLoading = false; + return; + } + this.listLoading = false; + if (res.data.success) { + this.$message({ + message: '删除成功', + type: 'success' + }); + + } else { + this.$message({ + message: res.data.msg, + type: 'error' + }); + } + + this._get$Modulelogo$s(); + }); + }).catch(() => { + + }); + }, + //显示编辑界面 + handleEdit (selRow) { + let row = {}; + if (selRow && selRow != undefined) { + this.currentRow = selRow; + } + row = this.currentRow; + if (!row) { + this.$message({ + message: "请选择要编辑的一行数据!", + type: "warning" + }); + + return; + } + this.isAdd = false + this.dialogTitle = '编辑' + this.addFormVisible = true; + this.addForm = Object.assign({}, row); + }, + //显示新增界面 + handleAdd () { + this.isAdd = true + this.dialogTitle = '新增' + this.addFormVisible = true; + this.setInitAddForm() + }, + //取消提交数据操作 + cancelHandle (done) { + this.setInitAddForm() + this.addFormVisible = false + + done() //done 用于关闭 Dialog + }, + // 提交数据 + submitDataHandle (formName) { + this.submitDisabled = true + + this.$refs.addForm.validate((valid) => { + if (valid) { + this.$confirm('确认提交吗?', '提示', {}).then(() => { + this.addLoading = true; + let para = Object.assign({}, this.addForm); + if (this.isAdd) {//新增 + add$Modulelogo$(para).then((res) => { + if (util.isEmt.format(res)) { + this.addLoading = false; + return; + } + + if (res.data.success) { + this.addLoading = false; + this.$message({ + message: res.data.msg, + type: 'success' + }); + this.$refs['addForm'].resetFields(); + this.addFormVisible = false; + this._get$Modulelogo$s(); + } + else { + this.addLoading = false; + this.$message({ + message: res.data.msg, + type: 'error' + }); + } + + }); + } else {//编辑 + edit$Modulelogo$(para).then((res) => { + if (util.isEmt.format(res)) { + this.addLoading = false; + return; + } + if (res.data.success) { + this.addLoading = false; + //NProgress.done(); + this.$message({ + message: res.data.msg, + type: 'success' + }); + this.$refs['addForm'].resetFields(); + this.addFormVisible = false; + this._get$Modulelogo$s(); + } + else { + this.addLoading = false; + this.$message({ + message: res.data.msg, + type: 'error' + }); + } + }); + } + }); + } + }); + }, + selsChange: function (sels) { + this.sels = sels; + }, + //导出 + handleExport () { + this.export_currentPageData = this.$Modulelogo$s + this.$refs.cmToolbarExport.showPrintPage() + }, + //导入 + handleImport () { + this.$refs.tbImportExcel.showPage() + }, + /******************************************[查看界面]开始*********************************************************** */ + //显示查看界面 + handleView (selRow) { + let row = {}; + if (selRow && selRow != undefined) { + this.currentRow = selRow; + } + row = this.currentRow; + if (!row) { + this.$message({ + message: "请选择要查看的一行数据!", + type: "warning" + }); + return; + } + this.viewDetailVisible = true + this.viewDetailForm = { + }; + this.viewDetailForm = Object.assign({}, row); + }, + //关闭查看界面 + closeViewHandle () { + this.viewDetailVisible = false + }, + /******************************************[查看界面]结束*********************************************************** */ + //addForm赋初始值 + setInitAddForm () { + this.addForm = Object.assign({}, this.init_addForm) + } + }, + mounted () { + if (isMobile()) { + this.h_drawerSize = "99%"//drawner宽度设置 + } else { + this.h_drawerSize = "600px"//drawner宽度设置 + } + this.setInitAddForm() + this._get$Modulelogo$s(); + + let routers = window.localStorage.router + ? JSON.parse(window.localStorage.router) + : []; + this.buttonList = getButtonList(this.$route.path, routers); + let isShow = isNeedShowOperatorColumn(this.buttonList);//控制是否要显示【操作】列 + this.isShowOperatorColumn = isShow; + } +} + +</script> + +<style lang="scss" scoped> +</style> diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/VUE/VUE\346\226\271\346\263\225\351\205\215\347\275\256.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/VUE/VUE\346\226\271\346\263\225\351\205\215\347\275\256.txt" new file mode 100644 index 0000000..d6cf257 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/VUE/VUE\346\226\271\346\263\225\351\205\215\347\275\256.txt" @@ -0,0 +1,17 @@ +// 配置$ChinaComment$方法 +//分页获取$ChinaComment$列表 +export const get$Modulelogo$ListPage = params => { + return axios.post(`${base}/api/$EntityName$/get`, params); +}; +//删除$ChinaComment$ +export const remove$Modulelogo$ = params => { + return axios.delete(`${base}/api/$EntityName$/delete`, { params: params }); +}; +//编辑$ChinaComment$ +export const edit$Modulelogo$ = params => { + return axios.put(`${base}/api/$EntityName$/put`, params); +}; +//添加$ChinaComment$ +export const add$Modulelogo$ = params => { + return axios.post(`${base}/api/$EntityName$/post`, params); +}; \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/CommonHelper.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/CommonHelper.cs" new file mode 100644 index 0000000..bbc2f09 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/CommonHelper.cs" @@ -0,0 +1,262 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鍏叡绫� + /// </summary> + public class CommonHelper + { + + + /// <summary> + /// 棣栧瓧姣嶅皬鍐� + /// </summary> + /// <param name="str"></param> + /// <returns></returns> + public static string FirstLowercase(string str) + { + if (string.IsNullOrEmpty(str)) + { + return str; + } + str = str.Substring(0, 1).ToLower() + str.Substring(1); + return str; + } + + + /// <summary> + /// 鑾峰彇瀛樺偍杩囩▼鍚� + /// </summary> + /// <param name="moduleName"></param> + /// <returns></returns> + public static ProcName GetProcName(string moduleName) + { + string procPrefix = "uspWip_"; + ProcName procName = new ProcName() + { + AddProc = procPrefix + "Add" + moduleName, + UpdateProc = procPrefix + "Update" + moduleName, + GetSingleProc = procPrefix + "GetSingle" + moduleName, + ListProc = procPrefix + "Get" + moduleName + "List", + PageListProc = procPrefix + "Get" + moduleName + "PageList", + }; + return procName; + } + + /// <summary> + /// 鍥炶溅绗� + /// </summary> + public const string enterStr = "\n"; + + /// <summary> + /// 鍗曚釜鍥炶溅绗︾殑瀛楃涓� + /// </summary> + /// <param name="content"></param> + /// <returns></returns> + public static string GetSinleEnterStr(string content) + { + return content + enterStr; + } + /// <summary> + /// 涓や釜鍥炶溅绗︾殑瀛楃涓� + /// </summary> + /// <param name="content"></param> + /// <returns></returns> + public static string GetDoubleEnterStr(string content) + { + return content + enterStr + enterStr; + } + + /// <summary> + /// 褰撳墠鏃堕棿瀛楃涓� + /// </summary> + /// <returns></returns> + public static string GetCurDate() + { + return DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + + " " + + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; + } + + /// <summary> + /// 棣栧瓧姣嶅ぇ鍐� + /// </summary> + /// <param name="str"></param> + /// <returns></returns> + public static string TitleToUpper(string str) + { + if (string.IsNullOrWhiteSpace(str)) + return string.Empty; + + char[] s = str.ToCharArray(); + char c = s[0]; + + if ('a' <= c && c <= 'z') + c = (char)(c & ~0x20); + + s[0] = c; + + return new string(s); + } + /// <summary> + /// 棣栧瓧姣嶅皬鍐� + /// </summary> + /// <param name="str"></param> + /// <returns></returns> + public static string TitleToLower(string str) + { + if (string.IsNullOrWhiteSpace(str)) + return string.Empty; + + char[] s = str.ToCharArray(); + char c = s[0]; + + if ('A' <= c && c <= 'Z') + c = char.ToLower(c); + + + s[0] = c; + + return new string(s); + } + + /// <summary> + /// 鑾峰彇鏁版嵁搴撹繛鎺ュ瓧绗︿覆鍒楄〃 + /// </summary> + /// <returns></returns> + public static List<ListItem> GetDataSources() + { + List<ListItem> list = new List<ListItem>(); + ConnectionStringSettingsCollection conn = ConfigurationManager.ConnectionStrings; + foreach (ConnectionStringSettings item in conn) + { + if (item.Name == "LocalSqlServer") + continue; + ListItem listItem = new ListItem() + { + Text = item.Name, + Value = item.ConnectionString + }; + list.Add(listItem); + } + return list; + } + + /// <summary> + /// 鑾峰彇鏁版嵁搴撶被鍨嬪垪琛� + /// </summary> + /// <returns></returns> + public static List<ListItem> GetDataBase() + { + List<ListItem> list = new List<ListItem>(); + + + ListItem listItem = new ListItem() + { + Text = DataBaseEnum.MySql.ToString(), + Value = DataBaseEnum.MySql.ToString() + }; + list.Add(listItem); + listItem = new ListItem() + { + Text = DataBaseEnum.SqlServer.ToString(), + Value = DataBaseEnum.SqlServer.ToString() + }; + list.Add(listItem); + + return list; + } + + } + + /// <summary> + /// 鏂囦欢绫诲瀷 + /// </summary> + public enum FileType + { + /// <summary> + /// 瀹炰綋绫绘枃浠� + /// </summary> + Model = 0, + /// <summary> + /// DAO鏂囦欢 + /// </summary> + DAO = 1, + /// <summary> + /// IBLL鏂囦欢 + /// </summary> + IBLL = 2, + /// <summary> + /// BLL鏂囦欢 + /// </summary> + BLL = 3, + /// <summary> + /// Controller鏂囦欢 + /// </summary> + Controller = 4, + /// <summary> + /// JS鏂囦欢 + /// </summary> + JS = 5, + /// <summary> + /// 鍒楄〃椤甸潰 + /// </summary> + CSHTML_List = 6, + /// <summary> + /// XML鏂囦欢 + /// </summary> + XML = 7, + /// <summary> + /// 璇︽儏椤甸潰 + /// </summary> + CSHTML_Detail = 8, + /// <summary> + /// 瀛樺偍杩囩▼鏂囦欢 + /// </summary> + Proc = 9, + /// <summary> + /// DAL 鏂囦欢 + /// </summary> + DAL = 10, + /// <summary> + /// InputModel + /// </summary> + InputModel = 11, + /// <summary> + /// WCF鎺ュ彛鏂囦欢 + /// </summary> + WCF_InterFace = 12, + /// <summary> + /// WCF鎺ュ彛瀹炵幇鏂囦欢 + /// </summary> + WCF_InterFaceRealize = 13, + /// <summary> + /// InsertSQL + /// </summary> + SQL_Insert = 14, + /// <summary> + /// VUE鏂规硶閰嶇疆 + /// </summary> + VUE_FunConfig = 15, + /// <summary> + /// VUE鏂囦欢 + /// </summary> + VUEFile = 16, + /// <summary> + /// 鏂板瀹炰綋鍙傛暟绫� + /// </summary> + AddModelParam = 17, + + /// <summary> + /// OutputModel + /// </summary> + OutputModel = 18, + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/ListHelper.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/ListHelper.cs" new file mode 100644 index 0000000..bef35a7 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/ListHelper.cs" @@ -0,0 +1,274 @@ +锘縰sing GenerateCode_GEBrilliantFactory.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_GEBrilliantFactory +{ + public class ListHelper + { + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(鍘绘帀 creator鍜宑reateTime) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> RemoveCreator(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + {//闇�瑕佸幓鎺� 鍒涘缓浜哄拰鍒涘缓鏃堕棿 + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper()) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(绉婚櫎鍏ㄩ儴) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> RemoveAll(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + {//闇�瑕佸幓鎺� 鍒涘缓浜哄拰鍒涘缓鏃堕棿 + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifier.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifyTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_delFlag.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() + ) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(CreatedTime銆乁pdatedTime銆丆reatedUserId銆丆reatedUserName銆乁pdatedUserId銆乁pdatedUserName) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> RemoveCreatedTimeUpdatedTimeCreatedUserIdCreatedUserNameUpdatedUserIdUpdatedUserName(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + {//闇�瑕佸幓鎺� 鍒涘缓浜哄拰鍒涘缓鏃堕棿 + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_CreateId.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyId.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifier.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifyTime.ToUpper() + ) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(鍘绘帀 delFlag銆乧reator銆乧reateTime銆乴astModifier銆乴astModifyTime) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> RemoveDelFlagCreatorModifier(List<ColumnModel> columnNameList) + { + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifier.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifyTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_delFlag.ToUpper() + ) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(鍘绘帀 Id锛孫perationRemark銆丆reateId锛孧odifyId) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> RemoveIdOperationRemarkCreateIdModifyId(List<ColumnModel> columnNameList) + { + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() + || columnModel.ColumnName.ToUpper() == "OperationRemark".ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_CreateId.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyId.ToUpper() + ) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(鍘绘帀 Id锛孋reateId锛孧odifyId) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> RemoveIdCreateIdModifyId(List<ColumnModel> columnNameList) + { + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_CreateId.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyId.ToUpper() + ) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(鍘绘帀 Id锛孋reateId锛孧odifyId,DelFlag) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> RemoveIdCreateIdModifyIdDelFlag(List<ColumnModel> columnNameList) + { + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_CreateId.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyId.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_delFlag.ToUpper() + ) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(鍙繚鐣� 瀛楃涓茬被鍨嬬殑瀛楁) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> OnlyStringProValue(List<ColumnModel> columnNameList) + { + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + //鑾峰彇鏁版嵁绫诲瀷 + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + newList.Add(columnModel); + break; + } + } + return newList; + } + + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(鍘绘帀 id銆乧reator銆乧reateTime銆乴astModifier銆乴astModifyTime) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> RemoveIdCreatorModifier(List<ColumnModel> columnNameList) + { + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifier.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifyTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyTime.ToUpper() + || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() + ) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + /// <summary> + /// 鑾峰彇鏈�鏂扮殑鍒桳ist闆嗗悎(鍘绘帀 ID) + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static List<ColumnModel> OnlyRemoveId(List<ColumnModel> columnNameList) + { + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper()) + { + continue; + } + newList.Add(columnModel); + } + return newList; + } + + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/MySqlHelper.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/MySqlHelper.cs" new file mode 100644 index 0000000..91f4eb7 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/MySqlHelper.cs" @@ -0,0 +1,262 @@ +//=============================================================================== +// This file is based on the Microsoft Data Access Application Block for .NET +// For more information please go to +// http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp +//=============================================================================== + +using System; +using System.Configuration; +using System.Data; +using MySqlConnector; +using System.Collections; + +/// <summary> +/// The MySqlHelper class is intended to encapsulate high performance, +/// scalable best practices for common uses of MySqlConnector. +/// </summary> +public abstract class MySqlHelper +{ + //Database connection strings + public static readonly string ConnectionString = ""; + + // Hashtable to store cached parameters + private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable()); + + /// <summary> + /// Execute a MySqlCommand (that returns no resultset) against the database specified in the connection string + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="connectionString">a valid connection string for a MySqlConnection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> + /// <returns>an int representing the number of rows affected by the command</returns> + public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) + { + MySqlCommand cmd = new MySqlCommand(); + + using (MySqlConnection conn = new MySqlConnection(connectionString)) + { + PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); + int val = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + return val; + } + } + + /// <summary> + /// Execute a MySqlCommand (that returns no resultset) against an existing database connection + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="conn">an existing database connection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> + /// <returns>an int representing the number of rows affected by the command</returns> + public static int ExecuteNonQuery(MySqlConnection connection, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) + { + MySqlCommand cmd = new MySqlCommand(); + + PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); + int val = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + return val; + } + + /// <summary> + /// Execute a MySqlCommand (that returns no resultset) using an existing SQL Transaction + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="trans">an existing sql transaction</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> + /// <returns>an int representing the number of rows affected by the command</returns> + public static int ExecuteNonQuery(MySqlTransaction trans, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) + { + MySqlCommand cmd = new MySqlCommand(); + PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters); + int val = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + return val; + } + + /// <summary> + /// Execute a MySqlCommand that returns a resultset against the database specified in the connection string + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// MySqlDataReader r = ExecuteReader(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="connectionString">a valid connection string for a MySqlConnection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> + /// <returns>A MySqlDataReader containing the results</returns> + public static MySqlDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) + { + MySqlCommand cmd = new MySqlCommand(); + MySqlConnection conn = new MySqlConnection(connectionString); + + // we use a try/catch here because if the method throws an exception we want to + // close the connection throw code, because no datareader will exist, hence the + // commandBehaviour.CloseConnection will not work + try + { + PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); + MySqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); + cmd.Parameters.Clear(); + return rdr; + } + catch + { + conn.Close(); + throw; + } + } + + /// <summary> + /// 执行查询语句,返回DataSet + /// </summary> + /// <param name="SQLString">查询语句</param> + /// <returns>DataSet</returns> + public static DataSet Query(string connectionString, string SQLString) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + DataSet ds = new DataSet(); + try + { + connection.Open(); + MySqlDataAdapter command = new MySqlDataAdapter(SQLString, connection); + command.Fill(ds, "ds"); + } + catch (MySqlException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + + /// <summary> + /// Execute a MySqlCommand that returns the first column of the first record against the database specified in the connection string + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="connectionString">a valid connection string for a MySqlConnection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> + /// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns> + public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) + { + MySqlCommand cmd = new MySqlCommand(); + + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); + object val = cmd.ExecuteScalar(); + cmd.Parameters.Clear(); + return val; + } + } + + /// <summary> + /// Execute a MySqlCommand that returns the first column of the first record against an existing database connection + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="conn">an existing database connection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> + /// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns> + public static object ExecuteScalar(MySqlConnection connection, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) + { + MySqlCommand cmd = new MySqlCommand(); + + PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); + object val = cmd.ExecuteScalar(); + cmd.Parameters.Clear(); + return val; + } + + /// <summary> + /// add parameter array to the cache + /// </summary> + /// <param name="cacheKey">Key to the parameter cache</param> + /// <param name="cmdParms">an array of MySqlParamters to be cached</param> + public static void CacheParameters(string cacheKey, params MySqlParameter[] commandParameters) + { + parmCache[cacheKey] = commandParameters; + } + + /// <summary> + /// Retrieve cached parameters + /// </summary> + /// <param name="cacheKey">key used to lookup parameters</param> + /// <returns>Cached MySqlParamters array</returns> + public static MySqlParameter[] GetCachedParameters(string cacheKey) + { + MySqlParameter[] cachedParms = (MySqlParameter[])parmCache[cacheKey]; + + if (cachedParms == null) + return null; + + MySqlParameter[] clonedParms = new MySqlParameter[cachedParms.Length]; + + for (int i = 0, j = cachedParms.Length; i < j; i++) + clonedParms[i] = (MySqlParameter)((ICloneable)cachedParms[i]).Clone(); + + return clonedParms; + } + + /// <summary> + /// Prepare a command for execution + /// </summary> + /// <param name="cmd">MySqlCommand object</param> + /// <param name="conn">MySqlConnection object</param> + /// <param name="trans">MySqlTransaction object</param> + /// <param name="cmdType">Cmd type e.g. stored procedure or text</param> + /// <param name="cmdText">Command text, e.g. Select * from Products</param> + /// <param name="cmdParms">MySqlParameters to use in the command</param> + private static void PrepareCommand(MySqlCommand cmd, MySqlConnection conn, MySqlTransaction trans, CommandType cmdType, string cmdText, MySqlParameter[] cmdParms) + { + if (conn.State != ConnectionState.Open) + conn.Open(); + + cmd.Connection = conn; + cmd.CommandText = cmdText; + + if (trans != null) + cmd.Transaction = trans; + + cmd.CommandType = cmdType; + + if (cmdParms != null) + { + foreach (MySqlParameter parm in cmdParms) + cmd.Parameters.Add(parm); + } + } +} \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/SQLHelper.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/SQLHelper.cs" new file mode 100644 index 0000000..0fe9de3 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/SQLHelper.cs" @@ -0,0 +1,254 @@ +//=============================================================================== +// This file is based on the Microsoft Data Access Application Block for .NET +// For more information please go to +// http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp +//=============================================================================== + +using System; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Data.Odbc; +using System.Collections; + + +/// <summary> +/// The SqlHelper class is intended to encapsulate high performance, +/// scalable best practices for common uses of SqlClient. +/// </summary> +public abstract class SqlHelper { + + //Database connection strings + public static readonly string ConnectionString = ""; + + // Hashtable to store cached parameters + private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable()); + + /// <summary> + /// Execute a SqlCommand (that returns no resultset) against the database specified in the connection string + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="connectionString">a valid connection string for a SqlConnection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> + /// <returns>an int representing the number of rows affected by the command</returns> + public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { + + SqlCommand cmd = new SqlCommand(); + + using (SqlConnection conn = new SqlConnection(connectionString)) { + PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); + int val = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + return val; + } + } + + /// <summary> + /// Execute a SqlCommand (that returns no resultset) against an existing database connection + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="conn">an existing database connection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> + /// <returns>an int representing the number of rows affected by the command</returns> + public static int ExecuteNonQuery(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { + + SqlCommand cmd = new SqlCommand(); + + PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); + int val = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + return val; + } + + /// <summary> + /// Execute a SqlCommand (that returns no resultset) using an existing SQL Transaction + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="trans">an existing sql transaction</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> + /// <returns>an int representing the number of rows affected by the command</returns> + public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { + SqlCommand cmd = new SqlCommand(); + PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters); + int val = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + return val; + } + + /// <summary> + /// Execute a SqlCommand that returns a resultset against the database specified in the connection string + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// SqlDataReader r = ExecuteReader(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="connectionString">a valid connection string for a SqlConnection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> + /// <returns>A SqlDataReader containing the results</returns> + public static SqlDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { + SqlCommand cmd = new SqlCommand(); + SqlConnection conn = new SqlConnection(connectionString); + + // we use a try/catch here because if the method throws an exception we want to + // close the connection throw code, because no datareader will exist, hence the + // commandBehaviour.CloseConnection will not work + try { + PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); + SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); + cmd.Parameters.Clear(); + return rdr; + } + catch { + conn.Close(); + throw; + } + } + + /// <summary> + /// 执行查询语句,返回DataSet + /// </summary> + /// <param name="SQLString">查询语句</param> + /// <returns>DataSet</returns> + public static DataSet Query(string connectionString, string SQLString) + { + using (SqlConnection connection = new SqlConnection(connectionString)) + { + DataSet ds = new DataSet(); + try + { + connection.Open(); + SqlDataAdapter command = new SqlDataAdapter(SQLString, connection); + command.Fill(ds, "ds"); + } + catch (System.Data.SqlClient.SqlException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + + /// <summary> + /// Execute a SqlCommand that returns the first column of the first record against the database specified in the connection string + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="connectionString">a valid connection string for a SqlConnection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> + /// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns> + public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { + SqlCommand cmd = new SqlCommand(); + + using (SqlConnection connection = new SqlConnection(connectionString)) { + PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); + object val = cmd.ExecuteScalar(); + cmd.Parameters.Clear(); + return val; + } + } + + /// <summary> + /// Execute a SqlCommand that returns the first column of the first record against an existing database connection + /// using the provided parameters. + /// </summary> + /// <remarks> + /// e.g.: + /// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); + /// </remarks> + /// <param name="conn">an existing database connection</param> + /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> + /// <param name="commandText">the stored procedure name or T-SQL command</param> + /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> + /// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns> + public static object ExecuteScalar(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { + + SqlCommand cmd = new SqlCommand(); + + PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); + object val = cmd.ExecuteScalar(); + cmd.Parameters.Clear(); + return val; + } + + /// <summary> + /// add parameter array to the cache + /// </summary> + /// <param name="cacheKey">Key to the parameter cache</param> + /// <param name="cmdParms">an array of SqlParamters to be cached</param> + public static void CacheParameters(string cacheKey, params SqlParameter[] commandParameters) { + parmCache[cacheKey] = commandParameters; + } + + /// <summary> + /// Retrieve cached parameters + /// </summary> + /// <param name="cacheKey">key used to lookup parameters</param> + /// <returns>Cached SqlParamters array</returns> + public static SqlParameter[] GetCachedParameters(string cacheKey) { + SqlParameter[] cachedParms = (SqlParameter[])parmCache[cacheKey]; + + if (cachedParms == null) + return null; + + SqlParameter[] clonedParms = new SqlParameter[cachedParms.Length]; + + for (int i = 0, j = cachedParms.Length; i < j; i++) + clonedParms[i] = (SqlParameter)((ICloneable)cachedParms[i]).Clone(); + + return clonedParms; + } + + /// <summary> + /// Prepare a command for execution + /// </summary> + /// <param name="cmd">SqlCommand object</param> + /// <param name="conn">SqlConnection object</param> + /// <param name="trans">SqlTransaction object</param> + /// <param name="cmdType">Cmd type e.g. stored procedure or text</param> + /// <param name="cmdText">Command text, e.g. Select * from Products</param> + /// <param name="cmdParms">SqlParameters to use in the command</param> + private static void PrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[] cmdParms) { + + if (conn.State != ConnectionState.Open) + conn.Open(); + + cmd.Connection = conn; + cmd.CommandText = cmdText; + + if (trans != null) + cmd.Transaction = trans; + + cmd.CommandType = cmdType; + + if (cmdParms != null) { + foreach (SqlParameter parm in cmdParms) + cmd.Parameters.Add(parm); + } + } +} \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/StructStrHelper.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/StructStrHelper.cs" new file mode 100644 index 0000000..d3075c3 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/StructStrHelper.cs" @@ -0,0 +1,1682 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Text; + +namespace GenerateCode_GEBrilliantFactory +{ + /// <summary> + /// 鏋勯�犲瓧绗︿覆甯姪绫� + /// </summary> + public class StructStrHelper + { + /// <summary> + /// 鏍规嵁琛ㄥ悕鑾峰彇鍒楅泦鍚� + /// </summary> + /// <param name="tableName"></param> + /// <returns></returns> + public static List<ColumnModel> GetColumnList(string tableName, string connStr) + { + string strSql = @" select +col.name as ColumnName, +t.name as DataType, +ep.value as Description, +col.max_length as DataLength, +col.is_nullable as IsNullable, + +( + select top 1 ind.is_primary_key from sys.index_columns ic + left join sys.indexes ind + on ic.object_id=ind.object_id + and ic.index_id=ind.index_id + and ind.name like 'PK_%' + where ic.object_id=obj.object_id + and ic.column_id=col.column_id +) as IsPrimaryKey, +col.Precision, +col.Scale +from sys.objects obj +inner join sys.columns col +on obj.object_id=col.object_id +left join sys.types t +on t.user_type_id=col.user_type_id +left join sys.extended_properties ep +on ep.major_id=obj.object_id +and ep.minor_id=col.column_id +and ep.name='MS_Description' +where obj.name='" + tableName + "' "; + + + List<ColumnModel> columnList = new List<ColumnModel>(); + try + { + DataSet ds = SqlHelper.Query(connStr, strSql); + columnList = DataTableToList(ds.Tables[0]); + } + catch + { + throw; + } + finally + { + } + return columnList; + } + + /// <summary> + /// 鑾峰緱鏁版嵁鍒楄〃 + /// </summary> + private static List<ColumnModel> DataTableToList(DataTable dt) + { + try + { + List<ColumnModel> modelList = new List<ColumnModel>(); + int rowsCount = dt.Rows.Count; + if (rowsCount > 0) + { + ColumnModel model; + for (int n = 0; n < rowsCount; n++) + { + model = new ColumnModel(); + if (dt.Rows[n]["Precision"].ToString() != "") + { + model.Precision = int.Parse(dt.Rows[n]["Precision"].ToString()); + } + if (dt.Rows[n]["Scale"].ToString() != "") + { + model.Scale = int.Parse(dt.Rows[n]["Scale"].ToString()); + } + model.ColumnName = dt.Rows[n]["ColumnName"].ToString(); + model.DataLength = dt.Rows[n]["DataLength"].ToString(); + model.DataType = dt.Rows[n]["DataType"].ToString(); + + if (model.DataType.ToUpper() == "nvarchar".ToUpper()) + { + if (model.DataLength != "-1") + { + model.DataLength = ((int)Convert.ToInt32(model.DataLength) / 2).ToString(); + } + } + + model.Description = dt.Rows[n]["Description"].ToString(); + if (dt.Rows[n]["IsNullable"].ToString() != "") + { + if ((dt.Rows[n]["IsNullable"].ToString() == "1") || (dt.Rows[n]["IsNullable"].ToString().ToLower() == "true")) + { + model.IsNullable = true; + } + else + { + model.IsNullable = false; + } + } + if (dt.Rows[n]["IsPrimaryKey"].ToString() != "") + { + if ((dt.Rows[n]["IsPrimaryKey"].ToString() == "1") || (dt.Rows[n]["IsPrimaryKey"].ToString().ToLower() == "true")) + { + model.IsPrimaryKey = true; + } + else + { + model.IsPrimaryKey = false; + } + } + + modelList.Add(model); + } + } + return modelList; + } + catch (Exception) + { + + throw; + } + } + + /// <summary> + /// 鐢熸垚灞炴�у瓧绗︿覆 + /// </summary> + /// <param name="columnModel"></param> + /// <returns></returns> + public static string GenerateAttribute(int index, ColumnModel columnModel, bool isShowExcelDataOptionAttribute = false) + { + try + { + string attr = columnModel.ColumnName; + string str_NullFlag = " "; + + //鑾峰彇鏁版嵁绫诲瀷 + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + string attrStr = ""; + + attrStr += " /// <summary>\n"; + attrStr += " /// " + columnModel.Description + "\n"; + attrStr += " /// </summary>\n"; + + if (isShowExcelDataOptionAttribute) + { + attrStr += " [ExcelDataOptionAttribute(DisplayName = \"" + columnModel.Description + "\", ColumnIndex = " + index + ")]\n"; + } + + switch (enumDT) + { + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_nvarchar: + attrStr += " public string" + str_NullFlag + attr + " { get; set; }\n"; + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public DateTime" + str_NullFlag + attr + " { get; set; }\n"; + break; + case DataTypeEnum.dt_datetimeoffset: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public DateTimeOffset" + str_NullFlag + attr + " { get; set; }\n"; + break; + case DataTypeEnum.dt_int: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public int" + str_NullFlag + attr + " { get; set; }\n"; + break; + case DataTypeEnum.dt_bigint: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public long" + str_NullFlag + attr + " { get; set; }\n"; + break; + case DataTypeEnum.dt_decimal: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public decimal" + str_NullFlag + attr + " { get; set; }\n"; + break; + case DataTypeEnum.dt_float: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public float" + str_NullFlag + attr + " { get; set; }\n"; + break; + case DataTypeEnum.dt_bit: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public bool" + str_NullFlag + attr + " { get; set; }\n"; + break; + } + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + return attrStr; + } + catch (Exception ex) + { + throw ex; + } + + } + + /// <summary> + /// 鐢熸垚灞炴�у瓧绗︿覆ForAddModel-鏂板瀹炰綋涓撶敤 + /// </summary> + /// <param name="columnModel"></param> + /// <returns></returns> + public static string GenerateAttributeForAddModel(ColumnModel columnModel) + { + try + { + string attr = columnModel.ColumnName; + //if (attr.ToUpper() == "DBId".ToUpper()) + //{ + // var bb = ""; + //} + string str_NullFlag = " "; + + string attrStr = ""; + attrStr += " /// <summary>\n"; + attrStr += " /// " + columnModel.Description + "\n"; + attrStr += " /// </summary>\n"; + + DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); + switch (myDataType) + { + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + attrStr += " //琛ㄧず鏄� 楂樼骇鏌ヨ鑼冨洿鏌ヨ鐗规�n"; + attrStr += " [HighSearchRangeAttribute]\n"; + attrStr += " public List<string>" + str_NullFlag + attr + " { get; set; }\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + case DataTypeEnum.dt_bigint: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public long" + str_NullFlag + attr + " { get; set; }\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + case DataTypeEnum.dt_int: + if (columnModel.IsNullable) { str_NullFlag = "? "; } + attrStr += " public int" + str_NullFlag + attr + " { get; set; }\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + default: + attrStr += " public string" + str_NullFlag + attr + " { get; set; }\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + } + + return attrStr; + } + catch (Exception ex) + { + throw ex; + } + + } + + /// <summary> + /// 鐢熸垚灞炴�у瓧绗︿覆ForQueryModel- 鏌ヨ瀹炰綋涓撶敤 + /// </summary> + /// <param name="columnModel"></param> + /// <returns></returns> + public static string GenerateAttributeForQueryModel(ColumnModel columnModel) + { + try + { + string attr = columnModel.ColumnName; + //if (attr.ToUpper() == "DBId".ToUpper()) + //{ + // var bb = ""; + //} + //娉ㄦ剰锛氭煡璇㈠疄浣撳氨涓嶈兘鎸夌収鏁版嵁搴撶殑鍙疦ULL闄愬埗浜嗭紝鍥犱负鏌ヨ鍐呭闅忔椂鍙互涓篘ULL鍝� + string str_NullFlag = " "; + str_NullFlag = "? "; + string emptyStr = " ";//绌烘牸 + + string attrStr = ""; + attrStr += " /// <summary>\n"; + attrStr += " /// " + columnModel.Description + "\n"; + attrStr += " /// </summary>\n"; + + DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); + switch (myDataType) + { + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + attrStr += " //琛ㄧず鏄� 楂樼骇鏌ヨ鑼冨洿鏌ヨ鐗规�n"; + attrStr += " [HighSearchRangeAttribute]\n"; + attrStr += " public List<string>" + emptyStr + attr + " { get; set; }\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + case DataTypeEnum.dt_bigint: + attrStr += " public long" + str_NullFlag + emptyStr + attr + " { get; set; }\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + case DataTypeEnum.dt_int: + attrStr += " public int" + str_NullFlag + emptyStr + attr + " { get; set; }\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + default: + attrStr += " public string" + emptyStr + attr + " { get; set; }\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + } + + return attrStr; + } + catch (Exception ex) + { + throw ex; + } + + } + + /// <summary> + /// 鐢熸垚灞炴�у瓧绗︿覆ForQueryModel + /// </summary> + /// <param name="columnModel"></param> + /// <returns></returns> + public static string GenerateAttributeForQueryModelMode(ColumnModel columnModel) + { + try + { + string attr = columnModel.ColumnName; + string attrStr = ""; + attrStr += " /// <summary>\n"; + attrStr += " /// " + columnModel.Description + "-鏌ヨ鍏崇郴杩愮畻绗� \n"; + attrStr += " /// </summary>\n"; + + string highSearchModeSuffix = "_FilterMode"; + + DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); + switch (myDataType) + { + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + return "\n"; + case DataTypeEnum.dt_bigint: + case DataTypeEnum.dt_int: + attrStr += " public SearchFilterModeEnum " + attr + highSearchModeSuffix + " { get; set; }= SearchFilterModeEnum.绮惧噯鏌ヨ;\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + default: + attrStr += " public SearchFilterModeEnum " + attr + highSearchModeSuffix + " { get; set; }= SearchFilterModeEnum.妯$硦鏌ヨ;\n"; + attrStr += "\n";//鏈�鍚庢槸鍔犱竴涓┖鏍� + break; + } + + return attrStr; + } + catch (Exception ex) + { + throw ex; + } + + } + + /// <summary> + /// 鑾峰彇鏌ヨ鍒楀瓧绗︿覆 + /// </summary> + /// <param name="columnNameList">鍒楅泦鍚�</param> + /// <param name="tableAlias">琛ㄥ埆鍚�</param> + /// <returns>瀛楃涓诧紝鏍煎紡濡� 鍒�1锛屽垪2锛屽垪3</returns> + public static string GetQueryColumnsStr(List<ColumnModel> columnNameList, string tableAlias = null) + { + StringBuilder selectSql = new StringBuilder(); + tableAlias = tableAlias == null ? "" : (tableAlias + "."); + ColumnModel columnModel = null; + string attrColumnName = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + attrColumnName = columnModel.ColumnName; + if (i == (columnNameList.Count - 1)) + selectSql.Append(" " + tableAlias + attrColumnName + "\n"); + else + selectSql.Append(" " + tableAlias + attrColumnName + ",\n"); + } + return selectSql.ToString(); + } + + /// <summary> + /// 鑾峰彇鍒楀瓧绗︿覆(涓嶅寘鎷琁D) 銆愭彃鍏ョ敤銆� + /// </summary> + /// <param name="columnNameList">鍒楅泦鍚�</param> + /// <param name="prefix">@鍓嶇紑</param> + /// <returns>瀛楃涓诧紝鏍煎紡濡� 鍒�1锛屽垪2锛屽垪3</returns> + public static string GetColumnsStrNoIDForAdd(List<ColumnModel> columnNameList, string prefix) + { + StringBuilder selectSql = new StringBuilder(); + ColumnModel columnModel = null; + string description = ""; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + description = " -- " + columnModel.ColumnName + " " + columnModel.Description; + string attrColumnName = columnModel.ColumnName; + if (attrColumnName.ToUpper() == "ID") + continue; + if (i == (columnNameList.Count - 1)) + selectSql.Append(" " + prefix + attrColumnName + description + "\n"); + else + selectSql.Append(" " + prefix + attrColumnName + "," + description + "\n"); + } + return selectSql.ToString(); + } + + /// <summary> + /// 鑾峰彇鍒楀瓧绗︿覆(涓嶅寘鎷琁D) 銆愮敓鎴怚nsertSQL鏂囨湰浣跨敤銆� + /// </summary> + /// <param name="columnNameList">鍒楅泦鍚�</param> + /// <returns>瀛楃涓诧紝鏍煎紡濡� 鍒�1锛屽垪2锛屽垪3</returns> + public static string GetColumnsStrNoIDForInsertSQL(List<ColumnModel> columnNameList) + { + StringBuilder selectSql = new StringBuilder(); + ColumnModel columnModel = null; + string description = ""; + string defaultValue = ""; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + description = " -- " + columnModel.ColumnName + " " + columnModel.Description; + string attrColumnName = columnModel.ColumnName; + if (attrColumnName.ToUpper() == "ID") + continue; + DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); + switch (myDataType) + { + case DataTypeEnum.dt_bigint: + case DataTypeEnum.dt_int: + defaultValue = "0"; + break; + case DataTypeEnum.dt_decimal: + case DataTypeEnum.dt_float: + defaultValue = "0.00"; + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + defaultValue = "getdate()"; + break; + case DataTypeEnum.dt_bit: + defaultValue = "0"; + break; + default: + defaultValue = "''"; + break; + } + if (i == (columnNameList.Count - 1)) + selectSql.Append(" " + defaultValue + description + "\n"); + else + selectSql.Append(" " + defaultValue + "," + description + "\n"); + } + return selectSql.ToString(); + } + + /// <summary> + /// 鑾峰彇澧炲姞浣跨敤鐨勫瓨鍌ㄨ繃绋嬪弬鏁板垪瀛楃涓诧紙瑕佹帓闄d锛� + /// </summary> + /// <param name="columnNameList">鍒楅泦鍚�</param> + /// <returns>瀛楃涓诧紝@processCardNumber nvarchar(50),@partNumber nvarchar(50), + ///</returns> + public static string GetInputParamColumnsStrForAdd(List<ColumnModel> columnNameList) + { + StringBuilder sql = new StringBuilder(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + string attrColumnName = columnModel.ColumnName; + if (attrColumnName.ToUpper() == "ID") + continue; + + var fuhao = ","; + if (i == columnNameList.Count - 1) + { + fuhao = ""; + } + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + var dataLength = columnModel.DataLength; + if (dataLength == "-1") + { + dataLength = "max"; + } + sql.Append("@" + attrColumnName + " " + columnModel.DataType + "(" + dataLength + ") " + fuhao + "\n"); + break; + case DataTypeEnum.dt_bigint: + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + case DataTypeEnum.dt_bit: + sql.Append("@" + attrColumnName + " " + columnModel.DataType + " " + fuhao + "\n"); + break; + case DataTypeEnum.dt_decimal: + case DataTypeEnum.dt_float: + sql.Append("@" + attrColumnName + " " + columnModel.DataType + + "(" + columnModel.Precision.ToString() + "," + columnModel.Scale.ToString() + ") " + fuhao + "\n"); + break; + default: + break; + } + } + return sql.ToString(); + } + + + /// <summary> + /// 鑾峰彇鏇存柊浣跨敤鐨勫瓨鍌ㄨ繃绋嬪弬鏁板垪瀛楃涓诧紙瑕佹帓闄d锛� + /// </summary> + /// <param name="columnNameList">鍒楅泦鍚�</param> + /// <returns>瀛楃涓诧紝@processCardNumber nvarchar(50),@partNumber nvarchar(50), + ///</returns> + public static string GetInputParamColumnsStrForUpdate(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + columnNameList = ListHelper.RemoveCreator(columnNameList); + + StringBuilder sql = new StringBuilder(); + ColumnModel columnModel = null; + string attrColumnName = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + attrColumnName = columnModel.ColumnName; + + var fuhao = ","; + if (i == columnNameList.Count - 1) + { + fuhao = ""; + } + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + var dataLength = columnModel.DataLength; + if (dataLength == "-1") + { + dataLength = "max"; + } + sql.Append("@" + attrColumnName + " " + columnModel.DataType + "(" + dataLength + ") " + fuhao + "\n"); + break; + case DataTypeEnum.dt_bigint: + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + case DataTypeEnum.dt_bit: + sql.Append("@" + attrColumnName + " " + columnModel.DataType + " " + fuhao + "\n"); + break; + case DataTypeEnum.dt_decimal: + case DataTypeEnum.dt_float: + sql.Append("@" + attrColumnName + " " + columnModel.DataType + + "(" + columnModel.Precision.ToString() + "," + columnModel.Scale.ToString() + ") " + fuhao + "\n"); + break; + default: + break; + } + } + return sql.ToString(); + } + + /// <summary> + /// 鑾峰彇鏌ヨ鍒嗛〉浣跨敤鐨勫瓨鍌ㄨ繃绋嬪弬鏁板垪瀛楃涓� + /// </summary> + /// <param name="columnNameList">鍒楅泦鍚�</param> + /// <returns>瀛楃涓诧紝@processCardNumber nvarchar(50),@partNumber nvarchar(50), + ///</returns> + public static string GetInputParamColumnsStrForQueryPage(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + columnNameList = ListHelper.RemoveAll(columnNameList); + + StringBuilder sql = new StringBuilder(); + ColumnModel columnModel = null; + string attrColumnName = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + attrColumnName = columnModel.ColumnName; + + var fuhao = "," + "\n"; + if (i == columnNameList.Count - 1) + { + fuhao = ","; + } + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + var dataLength = columnModel.DataLength; + if (dataLength == "-1") + { + dataLength = "max"; + } + sql.Append("@" + attrColumnName + " " + columnModel.DataType + "(" + dataLength + ") " + fuhao); + break; + case DataTypeEnum.dt_bigint: + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + case DataTypeEnum.dt_bit: + sql.Append("@" + attrColumnName + " " + columnModel.DataType + " " + fuhao); + break; + case DataTypeEnum.dt_decimal: + case DataTypeEnum.dt_float: + sql.Append("@" + attrColumnName + " " + columnModel.DataType + + "(" + columnModel.Precision.ToString() + "," + columnModel.Scale.ToString() + ") " + fuhao); + break; + default: + break; + } + } + return sql.ToString(); + } + + /// <summary> + /// 鐢熸垚璧嬪�約ql瀛楃涓诧紝鐢ㄤ簬淇敼 + /// </summary> + /// <param name="columnNameList"></param> + /// <param name="primaryKey"></param> + /// <returns></returns> + public static string GetCols_AssignmentStrForUpdate(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + columnNameList = ListHelper.RemoveCreator(columnNameList); + + StringBuilder sql = new StringBuilder(); + ColumnModel columnModel = null; + string attrColumnName = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + attrColumnName = columnModel.ColumnName; + if (columnModel.IsPrimaryKey) + continue; + + if (i == columnNameList.Count - 1) + { + sql.Append(attrColumnName + "=@" + attrColumnName + " \n"); + } + else + { + sql.Append(attrColumnName + "=@" + attrColumnName + ",\n"); + } + + } + return sql.ToString(); + } + + /// <summary> + /// 鐢熸垚璧嬪�約ql瀛楃涓诧紝鐢ㄤ簬鏌ヨ鍒嗛〉 + /// </summary> + /// <param name="columnNameList"></param> + /// <param name="primaryKey"></param> + /// <returns></returns> + public static string GetCols_AssignmentStrForWherePage(string TableAlias, List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + columnNameList = ListHelper.RemoveAll(columnNameList); + + StringBuilder sql = new StringBuilder(); + ColumnModel columnModel = null; + string attrColumnName = null; + sql.Append(" 1=1 \n"); + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + attrColumnName = columnModel.ColumnName; + sql.Append(" AND ( @" + attrColumnName + " IS NULL OR @" + attrColumnName + "='' OR " + TableAlias + "." + attrColumnName + "=@" + attrColumnName + " ) \n"); + + + } + return sql.ToString(); + } + + /// <summary> + /// 鐢熸垚璧嬪�約ql瀛楃涓诧紝鐢ㄤ簬淇敼 + /// </summary> + /// <param name="columnNameList"></param> + /// <param name="primaryKey"></param> + /// <returns></returns> + public static string GetCols_AssignmentStrForUpdate2(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + columnNameList = ListHelper.RemoveCreator(columnNameList); + + StringBuilder sql = new StringBuilder(); + ColumnModel columnModel = null; + string attrColumnName = null; + var updateSql = ""; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + attrColumnName = columnModel.ColumnName; + if (columnModel.IsPrimaryKey) + continue; + + if (attrColumnName.ToUpper() == "lastModifier".ToUpper() || attrColumnName.ToUpper() == "lastModifyTime".ToUpper()) + { + updateSql = " " + attrColumnName + "=@" + attrColumnName + " "; + } + else + { + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + updateSql = " " + attrColumnName + "= case ISNULL(@" + attrColumnName + ",'') when '' then " + + attrColumnName + " else @" + attrColumnName + " end "; + break; + case DataTypeEnum.dt_bigint: + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_decimal: + case DataTypeEnum.dt_float: + updateSql = " " + attrColumnName + "= case ISNULL(@" + attrColumnName + ",0) when 0 then " + + attrColumnName + " else @" + attrColumnName + " end "; + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + case DataTypeEnum.dt_bit: + updateSql = " " + attrColumnName + "= case @" + attrColumnName + " when NULL then " + attrColumnName + " else @" + attrColumnName + " end "; + break; + default: + updateSql = " " + attrColumnName + "=@" + attrColumnName + " "; + break; + } + } + + sql.Append(updateSql + ",\n"); + } + //鎴彇鎺夋渶鍚庝竴涓� ,\n + var strSql = sql.ToString().Substring(0, sql.ToString().Length - 2); + return strSql; + } + + /// <summary> + /// 鏋勯�犳柊澧濻QL鐨勫弬鏁癋orDAL鏂囦欢 + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static string GetParameterForAddDAL(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + List<ColumnModel> newList = new List<ColumnModel>(); + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + if (columnModel.IsPrimaryKey) + {//鏂板鐨勬椂鍊欙紝涓嶇敤涓婚敭 + continue; + } + newList.Add(columnModel); + } + + StringBuilder paramSql = new StringBuilder(); + paramSql.Append("SqlParameter[] parameters = { " + "\n"); + for (int i = 0; i < newList.Count; i++) + { + paramSql.Append(GetSqlParameterStr(newList[i])); + } + paramSql.Append(" param_id \n"); + paramSql.Append(" };\n"); + + for (int i = 0; i < newList.Count; i++) + { + paramSql.Append(" parameters[" + i.ToString() + "].Value = model." + newList[i].ColumnName + ";\n"); + } + + return paramSql.ToString(); + } + + /// <summary> + /// 鏋勯�犳洿鏂癝QL鐨勫弬鏁癋orDAL鏂囦欢 + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static string GetParameterForUpdateDAL(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + columnNameList = ListHelper.RemoveCreator(columnNameList); + + + StringBuilder paramSql = new StringBuilder(); + paramSql.Append("SqlParameter[] parameters = { " + "\n"); + string firstParam = "", secondParam = ""; + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + firstParam += GetSqlParameterStr(columnModel); + secondParam += " parameters[" + i.ToString() + "].Value = model." + columnModel.ColumnName + ";\n"; + } + paramSql.Append(firstParam); + paramSql.Append(" };\n"); + paramSql.Append(secondParam); + + return paramSql.ToString(); + } + + + /// <summary> + /// 鏋勯�犳煡璇㈠垎椤礢QL鐨勫弬鏁癋orDAL鏂囦欢 + /// </summary> + /// <param name="columnNameList"></param> + /// <returns></returns> + public static string GetParameterForQueryPageDAL(List<ColumnModel> columnNameList) + { + //鏋勯�犳柊鐨凩ist + columnNameList = ListHelper.RemoveAll(columnNameList); + + + StringBuilder paramSql = new StringBuilder(); + paramSql.Append("SqlParameter[] parameters = { " + "\n"); + string firstParam = "", secondParam = ""; + ColumnModel columnModel = null; + for (int i = 0; i < columnNameList.Count; i++) + { + columnModel = columnNameList[i]; + firstParam += GetSqlParameterStr(columnModel); + secondParam += " parameters[" + i.ToString() + "].Value = pageParam." + columnModel.ColumnName + ";\n"; + if (i == (columnNameList.Count - 1)) + { //澧炲姞鍒嗛〉鍙傛暟 + firstParam += " new SqlParameter(\"@pageIndex\", SqlDbType.Int) , \n"; + firstParam += " new SqlParameter(\"@pageSize\", SqlDbType.Int) \n"; + secondParam += " parameters[" + (i + 1).ToString() + "].Value = pageParam.pageIndex;\n"; + secondParam += " parameters[" + (i + 2).ToString() + "].Value = pageParam.pageSize;\n"; + } + } + paramSql.Append(firstParam); + paramSql.Append(" };\n"); + paramSql.Append(secondParam); + + + + return paramSql.ToString(); + } + + + + + private static string GetSqlParameterStr(ColumnModel columnModel) + { + string str = " new SqlParameter(\"@" + columnModel.ColumnName + "\","; + try + { + string attr = columnModel.ColumnName; + //鑾峰彇鏁版嵁绫诲瀷 + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + str += "SqlDbType.NChar," + columnModel.DataLength.ToString(); + break; + case DataTypeEnum.dt_varchar: + str += "SqlDbType.VarChar," + columnModel.DataLength.ToString(); + break; + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + str += "SqlDbType.NVarChar," + columnModel.DataLength.ToString(); + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + str += "SqlDbType.DateTime"; + break; + case DataTypeEnum.dt_int: + str += "SqlDbType.Int," + columnModel.DataLength.ToString(); + break; + case DataTypeEnum.dt_bigint: + str += "SqlDbType.BigInt," + columnModel.DataLength.ToString(); + break; + case DataTypeEnum.dt_decimal: + str += "SqlDbType.Decimal," + columnModel.DataLength.ToString(); + break; + case DataTypeEnum.dt_float: + str += "SqlDbType.Float," + columnModel.DataLength.ToString(); + break; + case DataTypeEnum.dt_bit: + str += "SqlDbType.Bit," + columnModel.DataLength.ToString(); + break; + } + str += "),\n";//鏈�鍚庢槸鍔犱竴涓洖杞� + return str; + } + catch (Exception ex) + { + throw ex; + } + } + + /// <summary> + /// 鐢熸垚璧嬪�煎疄浣撶被鐨勫瓧绗︿覆 + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetToModelStr(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + foreach (var columnModel in columnModelList) + { + string attr = columnModel.ColumnName; + //鑾峰彇鏁版嵁绫诲瀷 + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + sb.Append("model." + columnModel.ColumnName.ToString() + "=dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString();\n"); + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); + sb.Append("{ \n"); + sb.Append(" model." + columnModel.ColumnName.ToString() + " = DateTime.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); + sb.Append("} \n"); + break; + case DataTypeEnum.dt_int: + sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); + sb.Append("{ \n"); + sb.Append(" model." + columnModel.ColumnName.ToString() + " = int.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); + sb.Append("} \n"); + break; + case DataTypeEnum.dt_bigint: + sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); + sb.Append("{ \n"); + sb.Append(" model." + columnModel.ColumnName.ToString() + " = long.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); + sb.Append("} \n"); + break; + case DataTypeEnum.dt_decimal: + sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); + sb.Append("{ \n"); + sb.Append(" model." + columnModel.ColumnName.ToString() + " = decimal.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); + sb.Append("} \n"); + break; + case DataTypeEnum.dt_float: + sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); + sb.Append("{ \n"); + sb.Append(" model." + columnModel.ColumnName.ToString() + " = float.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); + sb.Append("} \n"); + break; + case DataTypeEnum.dt_bit: + sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); + sb.Append("{ \n"); + + sb.Append(" if ((dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() == \"1\") || (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString().ToLower() == \"true\")) \n"); + sb.Append("{ \n"); + sb.Append(" model." + columnModel.ColumnName.ToString() + " = true; \n"); + sb.Append("} \n"); + sb.Append("else \n"); + sb.Append("{ \n"); + sb.Append(" model." + columnModel.ColumnName.ToString() + " = false; \n"); + sb.Append("} \n"); + + sb.Append("} \n"); + break; + } + } + + return sb.ToString(); + } + catch (Exception ex) + { + throw ex; + } + } + + + #region WCF灞� + + /// <summary> + /// 鐢熸垚闇�瑕侀獙璇佷笉涓虹┖鐨勫瓧绗︿覆 + /// </summary> + /// <param name="columnModelList"></param> + /// <param name="isInsert">鏄惁鏄柊澧�</param> + /// <returns></returns> + public static string GetValidateEmptyStr(List<ColumnModel> columnModelList, bool isInsert = true) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = null; + if (isInsert) + {//鏂板 + newList = ListHelper.RemoveAll(columnModelList); + } + else + {//鏇存柊 + newList = ListHelper.RemoveDelFlagCreatorModifier(columnModelList); + } + + sb.Append(" List<ColumnsModel> columnsList = new List<ColumnsModel>() { \n"); + foreach (var columnModel in newList) + { + string attr = columnModel.ColumnName; + //鑾峰彇鏁版嵁绫诲瀷 + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + if (!columnModel.IsNullable) + { + sb.Append(" new ColumnsModel(){ ChinaName=\"" + columnModel.Description + "\",PropertyName=\"" + columnModel.ColumnName + "\" },\n"); + } + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + if (!columnModel.IsNullable) + {//鏃ユ湡蹇呰緭 + sb.Append(" new ColumnsModel(){ ChinaName=\"" + columnModel.Description + "\",PropertyName=\"" + columnModel.ColumnName + "\",DataType=typeof(DateTime) },\n"); + } + else + {//鏃ユ湡涓嶅繀杈� + sb.Append(" new ColumnsModel(){ ChinaName=\"" + columnModel.Description + "\",PropertyName=\"" + columnModel.ColumnName + "\",DataType=typeof(DateTime),IsNullable=true },\n"); + } + break; + default: + break; + } + + } + sb.Append(" };\n"); + return sb.ToString(); + } + catch (Exception ex) + { + throw ex; + } + } + + /// <summary> + /// 鏍规嵁涓婚敭绫诲瀷鑾峰彇楠岃瘉涓婚敭鐨勫瓧绗︿覆 + /// </summary> + /// <param name="columnModelList"></param> + /// <param name="primaryKey"></param> + /// <returns></returns> + public static string GetValidateEmptyStrForPrimaryKey(List<ColumnModel> columnModelList, string primaryKey) + { + if (primaryKey.ToUpper() == "ID".ToUpper()) + { + return " model.id == 0 "; + } + foreach (var item in columnModelList) + { + if (item.ColumnName.ToUpper() == primaryKey.ToUpper()) + { + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + item.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + return " string.IsNullOrEmpty(model.$PrimaryKey$) "; + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_bigint: + return " model.$PrimaryKey$ == 0 "; + default: + break; + } + } + } + return ""; + } + + + + #endregion + + #region Controller灞� + + #region Controller灞� + + /// <summary> + /// 鐢熸垚闇�瑕侀獙璇佷笉涓虹┖鐨勫瓧绗︿覆 + /// </summary> + /// <param name="columnModelList"></param> + /// <param name="isInsert">鏄惁鏄柊澧�</param> + /// <returns></returns> + public static string GetValidateEmptyStrForController(List<ColumnModel> columnModelList, bool isInsert = true) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = null; + if (isInsert) + {//鏂板 + newList = ListHelper.RemoveAll(columnModelList); + } + else + {//鏇存柊 + newList = ListHelper.RemoveDelFlagCreatorModifier(columnModelList); + } + var commonStr = string.Empty; + foreach (var columnModel in newList) + { + commonStr = " new ValidateModel(){ ChinaName=\"" + columnModel.Description + "\",PropertyName=\"" + columnModel.ColumnName + "\",DataValue=request." + columnModel.ColumnName; + string attr = columnModel.ColumnName; + //鑾峰彇鏁版嵁绫诲瀷 + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + if (!columnModel.IsNullable) + { + sb.Append(commonStr + " },\n"); + } + break; + case DataTypeEnum.dt_int: + if (!columnModel.IsNullable) + {//鏁板瓧蹇呰緭 + sb.Append(commonStr + ",DataType=typeof(int) },\n"); + } + else + {//鏁板瓧涓嶅繀杈� + sb.Append(commonStr + ",DataType=typeof(int),IsNullable=true },\n"); + } + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + if (!columnModel.IsNullable) + {//鏃ユ湡蹇呰緭 + sb.Append(commonStr + ",DataType=typeof(DateTime) },\n"); + } + else + {//鏃ユ湡涓嶅繀杈� + sb.Append(commonStr + ",DataType=typeof(DateTime),IsNullable=true },\n"); + } + break; + case DataTypeEnum.dt_datetimeoffset: + if (!columnModel.IsNullable) + {//鏃ユ湡蹇呰緭 + sb.Append(commonStr + ",DataType=typeof(DateTimeOffset) },\n"); + } + else + {//鏃ユ湡涓嶅繀杈� + sb.Append(commonStr + ",DataType=typeof(DateTimeOffset),IsNullable=true },\n"); + } + break; + default: + break; + } + + } + return sb.ToString(); + } + catch (Exception ex) + { + throw ex; + } + } + #endregion + #endregion + + #region VUE鏂囦欢 + + /// <summary> + /// 鑾峰彇VUE el-table-column + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetElTableColumnStr(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = ListHelper.RemoveIdOperationRemarkCreateIdModifyId(columnModelList); + foreach (var columnModel in newList) + { + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + sb.Append(" <el-table-column prop=\"" + columnModel.ColumnName + "\" label=\"" + columnModel.Description + "\" width=\"150\" align=\"center\" :formatter=\"formatterDateTime\" > \n"); + sb.Append(" </el-table-column> \n"); + break; + case DataTypeEnum.dt_bit: + sb.Append(" <el-table-column prop=\"" + columnModel.ColumnName + "\" label=\"" + columnModel.Description + "\" align=\"center\" > \n"); + sb.Append("<template slot-scope=\"scope\">"); + sb.Append("<el-tag :type=\"scope.row." + columnModel.ColumnName + " ? 'danger' : 'success'\""); + sb.Append("disable-transitions>{{scope.row." + columnModel.ColumnName + " ? \"鏄痋":\"鍚"}}</el-tag>"); + sb.Append(" </template>"); + sb.Append(" </el-table-column> \n"); + break; + default: + sb.Append(" <el-table-column prop=\"" + columnModel.ColumnName + "\" label=\"" + columnModel.Description + "\" align=\"center\" > \n"); + sb.Append(" </el-table-column> \n"); + break; + } + } + return sb.ToString(); + } + catch (Exception ex) + { + throw ex; + } + } + + + /// <summary> + /// 鑾峰彇VUE el-form-item (鏂板/缂栬緫鐣岄潰) + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetElFormItemStrForAddEditForm(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = ListHelper.RemoveIdCreatorModifier(columnModelList); + foreach (var columnModel in newList) + { + if (columnModel.IsNullable) + {//鍙互涓虹┖ + sb.Append(" <el-form-item label=\"" + columnModel.Description + "\" prop=\"" + columnModel.ColumnName + "\" > \n"); + } + else + { + sb.Append(" <el-form-item label=\"" + columnModel.Description + "\" prop=\"" + columnModel.ColumnName + "\" :rules=\"[{ required: true, message: '" + columnModel.Description + "涓嶈兘涓虹┖'}]\"> \n"); + } + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_bit: + sb.Append(" <el-switch v-model=\"addForm." + columnModel.ColumnName + "\"></el-switch> \n"); + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + sb.Append(" <el-date-picker placeholder=\"閫夋嫨鏃ユ湡鏃堕棿\" type=\"datetime\" v-model=\"addForm." + columnModel.ColumnName + "\"></el-date-picker> \n"); + break; + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_bigint: + case DataTypeEnum.dt_decimal: + case DataTypeEnum.dt_float: + sb.Append(" <el-input-number v-model=\"addForm." + columnModel.ColumnName + "\"></el-input-number> \n"); + break; + default: + sb.Append(" <el-input v-model=\"addForm." + columnModel.ColumnName + "\"></el-input> \n"); + break; + } + + sb.Append(" </el-form-item> \n"); + } + return sb.ToString(); + } + catch (Exception ex) + { + throw ex; + } + } + + + /// <summary> + /// 鑾峰彇VUE el-form-item (鏌ョ湅鐣岄潰) + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetElFormItemStrForViewForm(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = ListHelper.RemoveIdCreateIdModifyId(columnModelList); + foreach (var columnModel in newList) + { + sb.Append(" <el-form-item label=\"" + columnModel.Description + "\" prop=\"" + columnModel.ColumnName + "\" > \n"); + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_bit: + sb.Append(" <el-switch v-model=\"viewDetailForm." + columnModel.ColumnName + "\"></el-switch> \n"); + break; + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + sb.Append(" <el-date-picker placeholder=\"閫夋嫨鏃ユ湡鏃堕棿\" type=\"datetime\" v-model=\"viewDetailForm." + columnModel.ColumnName + "\"></el-date-picker> \n"); + break; + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_bigint: + case DataTypeEnum.dt_decimal: + case DataTypeEnum.dt_float: + sb.Append(" <el-input-number v-model=\"viewDetailForm." + columnModel.ColumnName + "\"></el-input-number> \n"); + break; + default: + sb.Append(" <el-input v-model=\"viewDetailForm." + columnModel.ColumnName + "\"></el-input> \n"); + break; + } + + sb.Append(" </el-form-item> \n"); + } + return sb.ToString(); + } + catch (Exception ex) + { + throw ex; + } + } + + + /// <summary> + /// 鑾峰彇VUE formOptions瀛楃涓�(楂樼骇鏌ヨ涓殑) + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetVueFormOptionsStr(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + /* + { + label: '浠g爜缂栫爜', + prop: 'code', + element: 'el-input' + }, + */ + List<ColumnModel> newList = ListHelper.RemoveIdOperationRemarkCreateIdModifyId(columnModelList); + foreach (var columnModel in newList) + { + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + var elment = "el-input"; + switch (enumDT) + { + case DataTypeEnum.dt_datetime: + elment = "el-date-picker"; + break; + case DataTypeEnum.dt_bit: + elment = "el-select"; + break; + default: + break; + } + sb.Append(" { \n"); + sb.Append(" label: '" + columnModel.Description + "', \n"); + sb.Append(" prop: '" + columnModel.ColumnName + "', \n"); + + //娣诲姞绫诲瀷 + switch (enumDT) + { + case DataTypeEnum.dt_datetime: + sb.Append(" type: 'datetimerange', \n"); + break; + default: + break; + } + + sb.Append(" element: '" + elment + "', \n"); + //娣诲姞绫诲瀷 + switch (enumDT) + { + case DataTypeEnum.dt_bit: + sb.Append(" options: [{label: '鏄�',value: 'true'}, {label: '鍚�',value: 'false'}] \n"); + break; + default: + break; + } + sb.Append(" }, \n"); + } + //鍘绘帀鏈�鍚庝竴涓�, + var res = sb.ToString(); + res = res.Substring(0, res.Length - 1); + return res; + } + catch (Exception ex) + { + throw ex; + } + } + + + /// <summary> + /// 鑾峰彇VUE 瀵煎嚭鏁扮粍瀛楃涓�-姹夊瓧+灞炴�� + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetVueExportTHeaderArrayStr(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = ListHelper.RemoveIdOperationRemarkCreateIdModifyId(columnModelList); + foreach (var columnModel in newList) + { + if (columnModel.IsPrimaryKey == false) + { + sb.Append("'" + columnModel.ColumnName + "':'" + columnModel.Description + "',"); + } + } + //鍘绘帀鏈�鍚庝竴涓�, + var res = sb.ToString(); + res = res.Substring(0, res.Length - 1); + return res; + } + catch (Exception ex) + { + throw ex; + } + } + + /// <summary> + /// 鑾峰彇VUE 鎼滅储妗嗚緭鍏ョ殑鎻愮ず鏂囨湰 + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetVueSearchFormInputPlaceholderStr(List<ColumnModel> columnModelList, ref string names) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = ListHelper.OnlyStringProValue(columnModelList); + foreach (var columnModel in newList) + { + if (columnModel.IsPrimaryKey == false) + { + sb.Append("" + columnModel.Description + "/"); + names += "'" + columnModel.ColumnName + "',"; + } + } + //鍘绘帀鏈�鍚庝竴涓�, + var res = sb.ToString(); + res = res.Substring(0, res.Length - 1); + + names = names.Substring(0, names.Length - 1); + + return res; + } + catch (Exception ex) + { + throw ex; + } + } + + + + + /// <summary> + /// 鑾峰彇VUE el-form-item 鏌ヨ鐢� + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetElFormItemForSearchStr(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = ListHelper.RemoveIdCreatorModifier(columnModelList); + foreach (var columnModel in newList) + { + sb.Append(" <el-form-item label=\"" + columnModel.Description + "\"> \n"); + + //鑾峰彇鏁版嵁绫诲瀷 + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + sb.Append("<el-input v-model=\"serachObj." + columnModel.ColumnName + "\" placeholder=\"璇疯緭鍏�" + columnModel.Description + "\"></el-input> \n"); + break; + case DataTypeEnum.dt_bit: + sb.Append("<el-checkbox-group v-model=\"ck_delflag\" @change=\"ckDelFlag\">\n"); + sb.Append(" <el-checkbox-button label=\"鍚敤\" name=\"ck_delflag\"></el-checkbox-button>\n"); + sb.Append(" <el-checkbox-button label=\"绂佺敤\" name=\"ck_delflag\"></el-checkbox-button>\n"); + sb.Append("</el-checkbox-group> \n"); + break; + default: + break; + } + + + sb.Append(" </el-form-item> \n"); + } + return sb.ToString(); + } + catch (Exception ex) + { + throw ex; + } + } + + #endregion + + + #region Controller + + /// <summary> + /// 鑾峰彇鍒嗛〉绛涢�夊瓧绗︿覆 + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetPageFilterStrForController(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + string mohuFilter = "&& (";//妯$硦鏌ヨ + string filter = "";//闈炴ā绯婃煡璇� + List<ColumnModel> newList = ListHelper.RemoveIdCreatorModifier(columnModelList); + + foreach (var columnModel in newList) + { + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_bit: + case DataTypeEnum.dt_datetime: + case DataTypeEnum.dt_datetime2: + case DataTypeEnum.dt_datetimeoffset: + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_decimal: + case DataTypeEnum.dt_float: + break; + default: + if (columnModel.IsPrimaryKey == false) + { + mohuFilter += "(a." + columnModel.ColumnName + " != null && a." + columnModel.ColumnName + ".Contains(param.searchVal))"; + mohuFilter += " ||"; + + filter += "&& (string.IsNullOrEmpty(param." + columnModel.ColumnName + ") || param." + columnModel.ColumnName + " == a." + columnModel.ColumnName + ") \n"; + } + else + { + } + break; + } + } + + + mohuFilter += "1==1)"; + filter += ";"; + return mohuFilter + filter; + } + catch (Exception ex) + { + throw ex; + } + } + + #endregion + + /// <summary> + /// 鐢熸垚Where鏌ヨ鏉′欢鐨勫瓧绗︿覆 + /// </summary> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static string GetStrForWhereQuery(List<ColumnModel> columnModelList) + { + StringBuilder sb = new StringBuilder(); + try + { + List<ColumnModel> newList = ListHelper.RemoveIdCreatorModifier(columnModelList); + foreach (var columnModel in newList) + { + string attr = columnModel.ColumnName; + //鑾峰彇鏁版嵁绫诲瀷 + DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); + switch (enumDT) + { + case DataTypeEnum.dt_char: + case DataTypeEnum.dt_varchar: + case DataTypeEnum.dt_Varchar_Desc: + case DataTypeEnum.dt_uniqueidentifier: + case DataTypeEnum.dt_Varchar_Ext_Link: + case DataTypeEnum.dt_nvarchar: + sb.Append(" if (!string.IsNullOrEmpty(queryModel." + columnModel.ColumnName + ")) \n"); + sb.Append(" { \n"); + sb.Append(" strWhere += \" AND $TableAlias$." + columnModel.ColumnName + " LIKE '%\" + queryModel." + columnModel.ColumnName + " + \"%'\"; \n"); + sb.Append(" } \n"); + break; + case DataTypeEnum.dt_bit: + sb.Append(" if (!string.IsNullOrEmpty(queryModel." + columnModel.ColumnName + ")) \n"); + sb.Append(" { \n"); + sb.Append(" strWhere += \" AND $TableAlias$." + columnModel.ColumnName + " = '\" + queryModel." + columnModel.ColumnName + " + \"'\"; \n"); + sb.Append(" } \n"); + break; + case DataTypeEnum.dt_int: + case DataTypeEnum.dt_bigint: + sb.Append(" if (queryModel." + columnModel.ColumnName + " !=0) \n"); + sb.Append(" { \n"); + sb.Append(" strWhere += \" AND $TableAlias$." + columnModel.ColumnName + " = \" + queryModel." + columnModel.ColumnName + " + \"\"; \n"); + sb.Append(" } \n"); + break; + default: + break; + } + } + return sb.ToString(); + } + catch (Exception ex) + { + throw ex; + } + } + + /// <summary> + /// 閫氳繃鍒楀悕鏌ユ壘鍒楀璞� + /// </summary> + /// <param name="columnName"></param> + /// <param name="columnModelList"></param> + /// <returns></returns> + public static ColumnModel GetColumnModelByName(string columnName, List<ColumnModel> columnModelList) + { + foreach (var item in columnModelList) + { + if (item.ColumnName.ToUpper() == columnName.ToUpper()) + { + return item; + } + } + return null; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/TextHelper.cs" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/TextHelper.cs" new file mode 100644 index 0000000..457ca48 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Utility/TextHelper.cs" @@ -0,0 +1,171 @@ +锘� +using GenerateCode_GEBrilliantFactory; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GenerateCode_GEBrilliantFactory +{ + public class TextHelper + { + + /// <summary> + /// 璇诲彇text鏂囨湰鍐呭 + /// </summary> + /// <param name="path"></param> + /// <returns></returns> + public static string ReadText(string path) + { + try + { + StreamReader sr = new StreamReader(path, Encoding.Default); + String line; + StringBuilder sb = new StringBuilder(); + while ((line = sr.ReadLine()) != null) + { + sb.Append(line.ToString() + " \n"); + } + sr.Close(); + sr.Dispose(); + return sb.ToString(); + } + catch + { + throw; + } + } + + /// <summary> + /// 鍐欏叆text鏂囨湰鍐呭 + /// </summary> + /// <param name="path"></param> + /// <param name="data"></param> + public static void WriteText(string path, string data) + { + //鍒ゆ柇璺緞鏄惁瀛樺湪 + if (!System.IO.File.Exists(path)) + { + throw new Exception("鏂囦欢涓嶅瓨鍦�"); + } + + //鏂囦欢瑕嗙洊鏂瑰紡娣诲姞鍐呭 + System.IO.StreamWriter file = new System.IO.StreamWriter(path, false); + //淇濆瓨鏁版嵁鍒版枃浠� + file.Write(data); + //鍏抽棴鏂囦欢 + file.Close(); + //閲婃斁瀵硅薄 + file.Dispose(); + } + + + /// <summary> + /// 鐢熸垚鏂囦欢 + /// </summary> + /// <param name="_strPath">璺緞</param> + /// <param name="_tableName">琛ㄥ悕</param> + /// <param name="_code">鐢熸垚鐨勪唬鐮佸瓧绗︿覆</param> + /// <param name="fileType">鐢熸垚鐨勬枃浠剁被鍨�</param> + /// <param name="filePrefixName">鍓嶇紑</param> + /// <param name="entityName">瀹炰綋绫诲悕</param> + /// <param name="modulelogo">妯″潡鍚嶅瓧</param> + /// <returns></returns> + public static bool Export2File(string _strPath, string _tableName, string _code, FileType fileType, + string filePrefixName, string entityName, string modulelogo) + { + string fileFolderPath = _strPath + "\\" + _tableName; + + string fileTypeName = ""; + switch (fileType) + { + case FileType.Model: + fileTypeName = ".cs"; + break; + case FileType.AddModelParam: + entityName = "Add" + modulelogo + "Param"; + fileTypeName = ".cs"; + break; + case FileType.IBLL: + entityName = "I" + filePrefixName + "BLL"; + fileTypeName = ".cs"; + break; + case FileType.Controller: + entityName = entityName + "Controller"; + fileTypeName = ".cs"; + break; + case FileType.JS: + entityName = filePrefixName; + fileTypeName = ".js"; + break; + case FileType.CSHTML_List: + entityName = filePrefixName; + fileTypeName = ".cshtml"; + break; + case FileType.CSHTML_Detail: + entityName = filePrefixName; + fileTypeName = "Detail.cshtml"; + break; + case FileType.XML: + entityName = filePrefixName; + fileTypeName = ".xml"; + break; + case FileType.Proc: + entityName = filePrefixName; + fileTypeName = "Proc.sql"; + break; + case FileType.DAL: + entityName = filePrefixName; + fileTypeName = "DAL.cs"; + break; + case FileType.BLL: + entityName = filePrefixName; + fileTypeName = "BLL.cs"; + break; + case FileType.InputModel: + entityName = entityName + "Input"; + fileTypeName = ".cs"; + fileFolderPath += "\\Dto"; + break; + case FileType.OutputModel: + entityName = entityName + "Output"; + fileTypeName = ".cs"; + fileFolderPath += "\\Dto"; + break; + case FileType.WCF_InterFace: + entityName = "I" + entityName + "Service"; + fileTypeName = ".cs"; + break; + case FileType.WCF_InterFaceRealize: + entityName = entityName + "Service"; + fileTypeName = ".cs"; + break; + case FileType.SQL_Insert: + entityName = _tableName + "InsertSQL"; + fileTypeName = ".txt"; + break; + case FileType.VUE_FunConfig: + entityName = _tableName + "VUE鏂规硶閰嶇疆"; + fileTypeName = ".txt"; + break; + case FileType.VUEFile: + entityName = modulelogo; + fileTypeName = ".vue"; + break; + } + if (!Directory.Exists(fileFolderPath)) + { + Directory.CreateDirectory(fileFolderPath); + } + string filePath = fileFolderPath + "\\" + entityName + fileTypeName; + using (StreamWriter outfile = new StreamWriter(filePath, false, Encoding.GetEncoding("UTF-8"))) + { + outfile.Write(_code); + } + + return true; + } + } +} diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/packages.config" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/packages.config" new file mode 100644 index 0000000..d58da6f --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/packages.config" @@ -0,0 +1,14 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" /> + <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.2" targetFramework="net48" /> + <package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.2" targetFramework="net48" /> + <package id="MySqlConnector" version="2.4.0" targetFramework="net48" /> + <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net451" /> + <package id="System.Buffers" version="4.5.1" targetFramework="net48" /> + <package id="System.Diagnostics.DiagnosticSource" version="8.0.1" targetFramework="net48" /> + <package id="System.Memory" version="4.5.5" targetFramework="net48" /> + <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" /> + <package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" /> + <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" /> +</packages> \ No newline at end of file diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/\347\211\210\346\234\254\350\257\264\346\230\216.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/\347\211\210\346\234\254\350\257\264\346\230\216.txt" new file mode 100644 index 0000000..f611249 --- /dev/null +++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/\347\211\210\346\234\254\350\257\264\346\230\216.txt" @@ -0,0 +1,5 @@ +Weben-CMS专用代码生成器 +V1.0 + 1、创建 2025-04-29 + + -- Gitblit v1.9.3