From ea30f8c2021fd2dd6e20949e423c836d0c89c7c1 Mon Sep 17 00:00:00 2001 From: walon Date: Fri, 6 Jan 2023 21:49:38 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8Ddb=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/Utils/TTypeTemplateExtends.cs | 22 ------------------ .../Source/Defs/TTypeTemplateCommonExtends.cs | 23 +++++++++++++++++++ .../Source/Generate/AsyncCsRender.cs | 2 +- .../TypeVisitors/DbCsDefineTypeVisitor.cs | 2 +- .../Templates/db/cs_async/bean.tpl | 2 +- .../Templates/db/cs_sync/bean.tpl | 2 +- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/Luban.Job.Cfg/Source/Utils/TTypeTemplateExtends.cs b/src/Luban.Job.Cfg/Source/Utils/TTypeTemplateExtends.cs index 3089b53..0e95234 100644 --- a/src/Luban.Job.Cfg/Source/Utils/TTypeTemplateExtends.cs +++ b/src/Luban.Job.Cfg/Source/Utils/TTypeTemplateExtends.cs @@ -339,27 +339,5 @@ namespace Luban.Job.Cfg.Utils { return type.Apply(CsEditorInitValueVisitor.Ins); } - public static string CsStartNameSpaceGrace(string np) - { - if (string.IsNullOrEmpty(np)) - { - return string.Empty; - } - else - { - return $"namespace {np}\n{{"; - } - } - public static string CsEndNameSpaceGrace(string np) - { - if (string.IsNullOrEmpty(np)) - { - return string.Empty; - } - else - { - return "}"; - } - } } } diff --git a/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs b/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs index 0c5e6bf..bba74d1 100644 --- a/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs +++ b/src/Luban.Job.Common/Source/Defs/TTypeTemplateCommonExtends.cs @@ -318,5 +318,28 @@ namespace Luban.Job.Common.Defs { return type is TDateTime && !type.IsNullable && ExternalTypeUtil.GetExternalTypeMappfer("datetime") == null; } + + public static string CsStartNameSpaceGrace(string np) + { + if (string.IsNullOrEmpty(np)) + { + return string.Empty; + } + else + { + return $"namespace {np}\n{{"; + } + } + public static string CsEndNameSpaceGrace(string np) + { + if (string.IsNullOrEmpty(np)) + { + return string.Empty; + } + else + { + return "}"; + } + } } } diff --git a/src/Luban.Job.Db/Source/Generate/AsyncCsRender.cs b/src/Luban.Job.Db/Source/Generate/AsyncCsRender.cs index 130f111..efc71c4 100644 --- a/src/Luban.Job.Db/Source/Generate/AsyncCsRender.cs +++ b/src/Luban.Job.Db/Source/Generate/AsyncCsRender.cs @@ -23,7 +23,7 @@ namespace Luban.Job.Db.Generate public string Render(DefEnum e) { var template = StringTemplateManager.Ins.GetTemplate("common/cs/enum"); - var result = template.Render(e); + var result = template.RenderCode(e); return result; } diff --git a/src/Luban.Job.Db/Source/TypeVisitors/DbCsDefineTypeVisitor.cs b/src/Luban.Job.Db/Source/TypeVisitors/DbCsDefineTypeVisitor.cs index fe9a695..c9b8dbc 100644 --- a/src/Luban.Job.Db/Source/TypeVisitors/DbCsDefineTypeVisitor.cs +++ b/src/Luban.Job.Db/Source/TypeVisitors/DbCsDefineTypeVisitor.cs @@ -25,7 +25,7 @@ namespace Luban.Job.Db.TypeVisitors public override string Accept(TMap type) { - return $"BrightDB.Transaction.Collections.{(type.ValueType is TBean ? " PMap2" : "PMap1")}<{type.KeyType.Apply(this)}, {type.ValueType.Apply(this)}>"; + return $"BrightDB.Transaction.Collections.{(type.ValueType is TBean ? "PMap2" : "PMap1")}<{type.KeyType.Apply(this)}, {type.ValueType.Apply(this)}>"; } } } diff --git a/src/Luban.Server/Templates/db/cs_async/bean.tpl b/src/Luban.Server/Templates/db/cs_async/bean.tpl index ff2dec7..dabb2c2 100644 --- a/src/Luban.Server/Templates/db/cs_async/bean.tpl +++ b/src/Luban.Server/Templates/db/cs_async/bean.tpl @@ -112,7 +112,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren public {{db_cs_define_type ctype}} {{field.convention_name}} => {{field.internal_name}}; {{~end~}} - {{~if ctype.bean || ctype.element_type ~}} + {{~if ctype.bean || (ctype.element_type && !ctype.is_map) ~}} {{~if field.comment != '' ~}} /// /// {{field.escape_comment}} diff --git a/src/Luban.Server/Templates/db/cs_sync/bean.tpl b/src/Luban.Server/Templates/db/cs_sync/bean.tpl index d0b4111..81c77b0 100644 --- a/src/Luban.Server/Templates/db/cs_sync/bean.tpl +++ b/src/Luban.Server/Templates/db/cs_sync/bean.tpl @@ -112,7 +112,7 @@ public {{x.cs_class_modifier}} class {{name}} : {{if parent_def_type}} {{x.paren public {{db_cs_define_type ctype}} {{field.convention_name}} => {{field.internal_name}}; {{~end~}} - {{~if ctype.bean || ctype.element_type ~}} + {{~if ctype.bean || (ctype.element_type && !ctype.is_map) ~}} {{~if field.comment != '' ~}} /// /// {{field.escape_comment}}