diff --git a/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs b/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs index 37eb242..0206607 100644 --- a/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs +++ b/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs @@ -54,7 +54,7 @@ namespace ZR.Admin.WebApi.Controllers public IActionResult GetListDataBase() { var dbList = _CodeGeneraterService.GetAllDataBases(); - var defaultDb = dbList.Count > 0 ? dbList[0] : null; + var defaultDb = dbList?[0]; return SUCCESS(new { dbList, defaultDb }); } diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index a686451..1c57c98 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -48,7 +48,8 @@ "autoPre": true, //自动去除表前缀 "author": "admin", "tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)", - "vuePath": "" //前端代码存储路径eg:D:\Work\ZRAdmin-Vue3 + "vuePath": "", //前端代码存储路径eg:D:\Work\ZRAdmin-Vue3 + "oracle_db": "" }, //邮箱配置信息 "MailOptions": { diff --git a/ZR.CodeGenerator/GenConstants.cs b/ZR.CodeGenerator/GenConstants.cs index f9e5498..e7bfc94 100644 --- a/ZR.CodeGenerator/GenConstants.cs +++ b/ZR.CodeGenerator/GenConstants.cs @@ -12,6 +12,7 @@ namespace ZR.CodeGenerator public static string Gen_author = "gen:author"; public static string Gen_autoPre = "gen:autoPre"; public static string Gen_tablePrefix = "gen:tablePrefix"; + public static string Gen_oracle_db = "gen:oracle_db"; /// /// InputDto输入实体是不包含字段 diff --git a/ZR.CodeGenerator/Service/CodeGeneraterService.cs b/ZR.CodeGenerator/Service/CodeGeneraterService.cs index 52901ad..fd82340 100644 --- a/ZR.CodeGenerator/Service/CodeGeneraterService.cs +++ b/ZR.CodeGenerator/Service/CodeGeneraterService.cs @@ -1,4 +1,5 @@ -using SqlSugar; +using Infrastructure; +using SqlSugar; using System.Collections.Generic; using System.Linq; using ZR.Model; @@ -14,6 +15,13 @@ namespace ZR.CodeGenerator.Service public List GetAllDataBases() { var db = GetSugarDbContext(); + //Oracle库特殊处理 + var dbType = AppSettings.GetAppConfig(GenConstants.Gen_conn_dbType, 0); + if (dbType == 3) + { + var defaultDb = AppSettings.GetAppConfig(GenConstants.Gen_oracle_db, string.Empty); + return new List() { defaultDb }; + } var templist = db.DbMaintenance.GetDataBaseList(db); return templist;