fix:Oracle数据库代码生成获取不了数据库问题

This commit is contained in:
不做码农 2023-02-23 11:06:46 +08:00
parent ee4b7c17b2
commit a0f4afbe25
4 changed files with 13 additions and 3 deletions

View File

@ -54,7 +54,7 @@ namespace ZR.Admin.WebApi.Controllers
public IActionResult GetListDataBase() public IActionResult GetListDataBase()
{ {
var dbList = _CodeGeneraterService.GetAllDataBases(); var dbList = _CodeGeneraterService.GetAllDataBases();
var defaultDb = dbList.Count > 0 ? dbList[0] : null; var defaultDb = dbList?[0];
return SUCCESS(new { dbList, defaultDb }); return SUCCESS(new { dbList, defaultDb });
} }

View File

@ -48,7 +48,8 @@
"autoPre": true, // "autoPre": true, //
"author": "admin", "author": "admin",
"tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)", "tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)",
"vuePath": "" //egD:\Work\ZRAdmin-Vue3 "vuePath": "", //egD:\Work\ZRAdmin-Vue3
"oracle_db": ""
}, },
// //
"MailOptions": { "MailOptions": {

View File

@ -12,6 +12,7 @@ namespace ZR.CodeGenerator
public static string Gen_author = "gen:author"; public static string Gen_author = "gen:author";
public static string Gen_autoPre = "gen:autoPre"; public static string Gen_autoPre = "gen:autoPre";
public static string Gen_tablePrefix = "gen:tablePrefix"; public static string Gen_tablePrefix = "gen:tablePrefix";
public static string Gen_oracle_db = "gen:oracle_db";
/// <summary> /// <summary>
/// InputDto输入实体是不包含字段 /// InputDto输入实体是不包含字段

View File

@ -1,4 +1,5 @@
using SqlSugar; using Infrastructure;
using SqlSugar;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ZR.Model; using ZR.Model;
@ -14,6 +15,13 @@ namespace ZR.CodeGenerator.Service
public List<string> GetAllDataBases() public List<string> GetAllDataBases()
{ {
var db = GetSugarDbContext(); 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<string>() { defaultDb };
}
var templist = db.DbMaintenance.GetDataBaseList(db); var templist = db.DbMaintenance.GetDataBaseList(db);
return templist; return templist;