This commit is contained in:
zpc 2025-11-08 15:42:33 +08:00
parent 0ba9af398e
commit 3eff16f73b
8 changed files with 57 additions and 15 deletions

View File

@ -408,10 +408,12 @@ public class LowCodeTableService : ApplicationService<IRepository<LowCodeTable>>
clientIndexPath = targetTable.ClientIndexPath, clientIndexPath = targetTable.ClientIndexPath,
clientInfoPath = targetTable.ClientInfoPath, clientInfoPath = targetTable.ClientInfoPath,
clientServicePath = targetTable.ClientServicePath, clientServicePath = targetTable.ClientServicePath,
menuPath = targetTable.MenuPath,
routerPath = targetTable.RouterPath,
isCover = targetTable.IsCover ?? false isCover = targetTable.IsCover ?? false
}; };
res["menu"] = $"views/apps/{targetTable.TableName}s/Index.vue"; res["menu"] = targetTable.MenuPath ?? $"views/apps/{targetTable.TableName}s/Index.vue";
res["router"] = $"/apps/{targetTable.TableName?.ToLower()}s"; res["router"] = targetTable.RouterPath ?? $"/apps/{targetTable.TableName?.ToLower()}s";
return Task.FromResult(res); return Task.FromResult(res);
} }

View File

@ -50,6 +50,16 @@ public class DataSourceConfig
/// </summary> /// </summary>
public string ClientServicePathTemplate { get; set; } = string.Empty; public string ClientServicePathTemplate { get; set; } = string.Empty;
/// <summary>
/// 前端菜单路径模板(支持占位符:{TableName}, {TableNameLower}
/// </summary>
public string MenuPathTemplate { get; set; } = string.Empty;
/// <summary>
/// 前端路由路径模板(支持占位符:{TableName}, {TableNameLower}
/// </summary>
public string RouterPathTemplate { get; set; } = string.Empty;
/// <summary> /// <summary>
/// 代码生成模板目录 /// 代码生成模板目录
/// </summary> /// </summary>

View File

@ -33,6 +33,7 @@ public class PathResolver : IScopedDependency
var entityName = GetEntityName(tableName, config); var entityName = GetEntityName(tableName, config);
var entityNamePlural = config.UsesPluralPath ? entityName + "s" : entityName; var entityNamePlural = config.UsesPluralPath ? entityName + "s" : entityName;
var tableNameLower = string.IsNullOrWhiteSpace(tableName) ? string.Empty : tableName.ToLower();
return template return template
.Replace("{RootPath}", rootPath) .Replace("{RootPath}", rootPath)
@ -40,7 +41,8 @@ public class PathResolver : IScopedDependency
.Replace("{Namespace}", config.EntityNamespace) .Replace("{Namespace}", config.EntityNamespace)
.Replace("{EntityName}", entityName) .Replace("{EntityName}", entityName)
.Replace("{EntityNamePlural}", entityNamePlural) .Replace("{EntityNamePlural}", entityNamePlural)
.Replace("{TableName}", tableName); .Replace("{TableName}", tableName)
.Replace("{TableNameLower}", tableNameLower);
} }
/// <summary> /// <summary>

View File

@ -70,6 +70,16 @@ public class LowCodeTable
/// </summary> /// </summary>
public string? ClientServicePath { get; set; } public string? ClientServicePath { get; set; }
/// <summary>
/// 前端菜单路径
/// </summary>
public string? MenuPath { get; set; }
/// <summary>
/// 前端路由路径
/// </summary>
public string? RouterPath { get; set; }
/// <summary> /// <summary>
/// 是否覆盖生成 /// 是否覆盖生成
/// </summary> /// </summary>

View File

@ -177,19 +177,31 @@ public class CodeGenerationService : ICodeGenerationService, IScopedDependency
if (string.IsNullOrWhiteSpace(lowCodeTable.ClientIndexPath)) if (string.IsNullOrWhiteSpace(lowCodeTable.ClientIndexPath))
{ {
lowCodeTable.ClientIndexPath = _pathResolver.ResolvePath( lowCodeTable.ClientIndexPath = _pathResolver.ResolvePath(
config.ClientIndexPathTemplate, config, lowCodeTable.TableName); config.ClientIndexPathTemplate, config, lowCodeTable.TableName ?? string.Empty);
} }
if (string.IsNullOrWhiteSpace(lowCodeTable.ClientInfoPath)) if (string.IsNullOrWhiteSpace(lowCodeTable.ClientInfoPath))
{ {
lowCodeTable.ClientInfoPath = _pathResolver.ResolvePath( lowCodeTable.ClientInfoPath = _pathResolver.ResolvePath(
config.ClientInfoPathTemplate, config, lowCodeTable.TableName); config.ClientInfoPathTemplate, config, lowCodeTable.TableName ?? string.Empty);
} }
if (string.IsNullOrWhiteSpace(lowCodeTable.ClientServicePath)) if (string.IsNullOrWhiteSpace(lowCodeTable.ClientServicePath))
{ {
lowCodeTable.ClientServicePath = _pathResolver.ResolvePath( lowCodeTable.ClientServicePath = _pathResolver.ResolvePath(
config.ClientServicePathTemplate, config, lowCodeTable.TableName); config.ClientServicePathTemplate, config, lowCodeTable.TableName ?? string.Empty);
}
if (string.IsNullOrWhiteSpace(lowCodeTable.MenuPath))
{
lowCodeTable.MenuPath = _pathResolver.ResolvePath(
config.MenuPathTemplate, config, lowCodeTable.TableName ?? string.Empty);
}
if (string.IsNullOrWhiteSpace(lowCodeTable.RouterPath))
{
lowCodeTable.RouterPath = _pathResolver.ResolvePath(
config.RouterPathTemplate, config, lowCodeTable.TableName ?? string.Empty);
} }
return lowCodeTable; return lowCodeTable;

View File

@ -21,9 +21,11 @@ public class AdminDataSourceProvider : IDataSourceProvider, IScopedDependency
ModelPathTemplate = "{RootPath}\\{Namespace}\\Entities\\Apps\\{EntityNamePlural}", ModelPathTemplate = "{RootPath}\\{Namespace}\\Entities\\Apps\\{EntityNamePlural}",
ServicePathTemplate = "{AppPath}\\ApplicationServices\\Apps\\{EntityNamePlural}", ServicePathTemplate = "{AppPath}\\ApplicationServices\\Apps\\{EntityNamePlural}",
ControllerPathTemplate = "{AppPath}\\Controllers\\Apps\\{EntityNamePlural}", ControllerPathTemplate = "{AppPath}\\Controllers\\Apps\\{EntityNamePlural}",
ClientIndexPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\{TableName}s", ClientIndexPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\{TableNameLower}s",
ClientInfoPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\{TableName}s", ClientInfoPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\{TableNameLower}s",
ClientServicePathTemplate = "{RootPath}\\admin-client\\src\\services\\apps\\{TableName}s", ClientServicePathTemplate = "{RootPath}\\admin-client\\src\\services\\apps\\{TableNameLower}s",
MenuPathTemplate = "views/apps/{TableNameLower}s/Index.vue",
RouterPathTemplate = "/apps/{TableNameLower}s",
TemplatePath = "/wwwroot/code_generation/template/", TemplatePath = "/wwwroot/code_generation/template/",
NamingStrategy = EntityNamingStrategy.ToPascalCase, NamingStrategy = EntityNamingStrategy.ToPascalCase,
Order = 1, Order = 1,

View File

@ -21,9 +21,11 @@ public class MiaoYuChatDataSourceProvider : IDataSourceProvider, IScopedDependen
ModelPathTemplate = "{RootPath}\\{Namespace}\\Entities\\Apps\\{EntityNamePlural}", ModelPathTemplate = "{RootPath}\\{Namespace}\\Entities\\Apps\\{EntityNamePlural}",
ServicePathTemplate = "{AppPath}\\ApplicationServices\\Apps\\ChatAI\\{EntityNamePlural}", ServicePathTemplate = "{AppPath}\\ApplicationServices\\Apps\\ChatAI\\{EntityNamePlural}",
ControllerPathTemplate = "{AppPath}\\Controllers\\Apps\\ChatAI\\{EntityNamePlural}", ControllerPathTemplate = "{AppPath}\\Controllers\\Apps\\ChatAI\\{EntityNamePlural}",
ClientIndexPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\chatai\\{TableName}s", ClientIndexPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\chatai\\{TableNameLower}s",
ClientInfoPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\chatai\\{TableName}s", ClientInfoPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\chatai\\{TableNameLower}s",
ClientServicePathTemplate = "{RootPath}\\admin-client\\src\\services\\apps\\chatai\\{TableName}s", ClientServicePathTemplate = "{RootPath}\\admin-client\\src\\services\\apps\\chatai\\{TableNameLower}s",
MenuPathTemplate = "views/apps/chatai/{TableNameLower}s/Index.vue",
RouterPathTemplate = "/apps/chatai/{TableNameLower}s",
TemplatePath = "/wwwroot/code_generation/template/", TemplatePath = "/wwwroot/code_generation/template/",
NamingStrategy = EntityNamingStrategy.ToPascalCase, NamingStrategy = EntityNamingStrategy.ToPascalCase,
Order = 2, Order = 2,

View File

@ -21,9 +21,11 @@ public class LiveForumDataSourceProvider : IDataSourceProvider, IScopedDependenc
ModelPathTemplate = "{RootPath}\\{Namespace}\\Entities\\Apps\\{EntityNamePlural}", ModelPathTemplate = "{RootPath}\\{Namespace}\\Entities\\Apps\\{EntityNamePlural}",
ServicePathTemplate = "{AppPath}\\ApplicationServices\\Apps\\LiveForum\\{EntityNamePlural}", ServicePathTemplate = "{AppPath}\\ApplicationServices\\Apps\\LiveForum\\{EntityNamePlural}",
ControllerPathTemplate = "{AppPath}\\Controllers\\Apps\\LiveForum\\{EntityNamePlural}", ControllerPathTemplate = "{AppPath}\\Controllers\\Apps\\LiveForum\\{EntityNamePlural}",
ClientIndexPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\liveforum\\{TableName}", ClientIndexPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\liveforum\\{TableNameLower}",
ClientInfoPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\liveforum\\{TableName}", ClientInfoPathTemplate = "{RootPath}\\admin-client\\src\\views\\apps\\liveforum\\{TableNameLower}",
ClientServicePathTemplate = "{RootPath}\\admin-client\\src\\services\\apps\\liveforum\\{TableName}", ClientServicePathTemplate = "{RootPath}\\admin-client\\src\\services\\apps\\liveforum\\{TableNameLower}",
MenuPathTemplate = "views/apps/liveforum/{TableNameLower}/Index.vue",
RouterPathTemplate = "/apps/liveforum/{TableNameLower}",
TemplatePath = "/wwwroot/code_generation/template/", TemplatePath = "/wwwroot/code_generation/template/",
NamingStrategy = EntityNamingStrategy.KeepOriginal, NamingStrategy = EntityNamingStrategy.KeepOriginal,
Order = 3, Order = 3,