From e5cb2ec6248dfb1a69dc74a1d3acff5bcf4b8bbd Mon Sep 17 00:00:00 2001 From: Damien Date: Fri, 20 Dec 2024 19:15:29 +0100 Subject: [PATCH] [tmdgen db] `classNameOverrides` --- TopModel.Core/schema.tmdgen.config.json | 10 +++++++++- .../Database/DatabaseTmdGenerator.cs | 5 +++++ .../Database/config/DatabaseConfig.cs | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/TopModel.Core/schema.tmdgen.config.json b/TopModel.Core/schema.tmdgen.config.json index 4a53b7c7..797283b3 100644 --- a/TopModel.Core/schema.tmdgen.config.json +++ b/TopModel.Core/schema.tmdgen.config.json @@ -91,6 +91,14 @@ "description": "Tag à ajouter aux fichiers générés" } }, + "classNameOverrides": { + "type": "object", + "description": "Surcharge de nom de classes à générer. N'a pas d'impact sur le nom SQL de la classe.", + "additionalProperties": { + "type": "string", + "description": "Surcharge à utiliser." + } + }, "modules": { "type": "array", "description": "Liste des modules et des classes qui devront en faire partie", @@ -157,7 +165,7 @@ "type": "object", "description": "Informations de connexion à la base de données", "additionalProperties": false, - "required": ["dbType"], + "required": [ "dbType" ], "properties": { "host": { "type": "string", diff --git a/TopModel.ModelGenerator/Database/DatabaseTmdGenerator.cs b/TopModel.ModelGenerator/Database/DatabaseTmdGenerator.cs index 169ead66..4e7ca5cf 100644 --- a/TopModel.ModelGenerator/Database/DatabaseTmdGenerator.cs +++ b/TopModel.ModelGenerator/Database/DatabaseTmdGenerator.cs @@ -397,6 +397,11 @@ private void InitClasses(IEnumerable> classGroups) className = group.Key; } + if (_config.ClassNameOverrides.TryGetValue(className, out var classNameOverride)) + { + className = classNameOverride; + } + _classes.Add(group.Key, new TmdClass() { Name = className, SqlName = group.Key }); } } diff --git a/TopModel.ModelGenerator/Database/config/DatabaseConfig.cs b/TopModel.ModelGenerator/Database/config/DatabaseConfig.cs index 360c07e7..5017c417 100644 --- a/TopModel.ModelGenerator/Database/config/DatabaseConfig.cs +++ b/TopModel.ModelGenerator/Database/config/DatabaseConfig.cs @@ -14,6 +14,8 @@ public class DatabaseConfig public List ExtractValues { get; set; } = []; + public Dictionary ClassNameOverrides { get; set; } = []; + public List Modules { get; set; } = []; public string ConnectionString => Source.DbType switch