From 0e043c571651c7bedd8f413657903543274ba91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Fri, 16 Jun 2023 19:35:34 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20fix=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs | 4 ++-- ZR.Admin.WebApi/appsettings.json | 3 ++- ZR.CodeGenerator/CodeGeneratorTool.cs | 4 ++-- ZR.CodeGenerator/GenConstants.cs | 1 - 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs b/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs index 8941c6a..dcfe5c7 100644 --- a/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs +++ b/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs @@ -153,7 +153,7 @@ namespace ZR.Admin.WebApi.Controllers { throw new CustomException("表不能为空"); } - var dbType = AppSettings.GetAppConfig(GenConstants.Gen_conn_dbType, 0); + var dbConfig = AppSettings.Get>("dbConfigs").FirstOrDefault(f => f.IsGenerateDb); string[] tableNames = tables.Split(',', StringSplitOptions.RemoveEmptyEntries); int result = 0; foreach (var tableName in tableNames) @@ -164,7 +164,7 @@ namespace ZR.Admin.WebApi.Controllers List seqs = new(); GenTable genTable = CodeGeneratorTool.InitTable(dbName, HttpContext.GetName(), tableName, tabInfo?.Description); genTable.TableId = GenTableService.ImportGenTable(genTable); - if (dbType == 3) + if (dbConfig.DbType == 3) { seqs = _CodeGeneraterService.GetAllOracleSeqs(dbName); } diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index 7c51eef..762a634 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -14,11 +14,12 @@ "IsAutoCloseConnection": true }, { + //代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名 "Conn": "Data Source=LAPTOP-STKF2M8H\\SQLEXPRESS;User ID=admin;Password=admin123;Initial Catalog={dbName};", "DbType": 1, "ConfigId": "0", "IsAutoCloseConnection": true, - "DbName": "ZrAdmin",//代码生成默认连接数据库 + "DbName": "ZrAdmin", //代码生成默认连接数据库 "IsGenerateDb": true //是否代码生成使用库,不要改动 } //...下面添加更多的数据库源 diff --git a/ZR.CodeGenerator/CodeGeneratorTool.cs b/ZR.CodeGenerator/CodeGeneratorTool.cs index d078fc6..26790b6 100644 --- a/ZR.CodeGenerator/CodeGeneratorTool.cs +++ b/ZR.CodeGenerator/CodeGeneratorTool.cs @@ -414,9 +414,9 @@ namespace ZR.CodeGenerator /// private static GenTableColumn InitColumnField(GenTable genTable, DbColumnInfo column, List seqs) { - var dbType = AppSettings.Get(GenConstants.Gen_conn_dbType); + var dbConfig = AppSettings.Get>("dbConfigs").FirstOrDefault(f => f.IsGenerateDb); var dataType = column.DataType; - if (dbType == 3) + if (dbConfig.DbType == 3) { dataType = column.OracleDataType; var seqName = $"SEQ_{genTable.TableName}_{column.DbColumnName}"; diff --git a/ZR.CodeGenerator/GenConstants.cs b/ZR.CodeGenerator/GenConstants.cs index c2563aa..fe5a8fc 100644 --- a/ZR.CodeGenerator/GenConstants.cs +++ b/ZR.CodeGenerator/GenConstants.cs @@ -7,7 +7,6 @@ namespace ZR.CodeGenerator /// public class GenConstants { - public static string Gen_conn_dbType = "gen:dbType"; public static string Gen_author = "gen:author"; public static string Gen_autoPre = "gen:autoPre"; public static string Gen_tablePrefix = "gen:tablePrefix";