diff --git a/src/Luban.Job.Cfg/Source/DataConverts/FillSheetVisitor.cs b/src/Luban.Job.Cfg/Source/DataConverts/FillSheetVisitor.cs index 9ec5971..096486a 100644 --- a/src/Luban.Job.Cfg/Source/DataConverts/FillSheetVisitor.cs +++ b/src/Luban.Job.Cfg/Source/DataConverts/FillSheetVisitor.cs @@ -2,6 +2,7 @@ using Luban.Job.Cfg.DataSources.Excel; using Luban.Job.Cfg.DataVisitors; using Luban.Job.Cfg.Defs; +using Luban.Job.Common.Types; using System; using System.Collections.Generic; using System.Linq; @@ -125,7 +126,6 @@ namespace Luban.Job.Cfg.DataConverts public int Accept(DBean type, Title x) { - if (x.SubTitleList.Count > 0) { if (type.Type.IsAbstractType) @@ -179,6 +179,10 @@ namespace Luban.Job.Cfg.DataConverts // (_cells[_startRowIndex, fieldTitle.FromIndex] as Range).Value = data.Apply(ToExcelStringVisitor.Ins, fieldTitle.Sep); //} } + else if (field.CType is TText) + { + SetTitleValue(fieldTitle, $"null{fieldTitle.Sep}null"); + } } } return rowCount; diff --git a/src/Luban.Job.Cfg/Source/DataConverts/TitleCreator.cs b/src/Luban.Job.Cfg/Source/DataConverts/TitleCreator.cs index 05f38ab..58b71a9 100644 --- a/src/Luban.Job.Cfg/Source/DataConverts/TitleCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataConverts/TitleCreator.cs @@ -157,9 +157,12 @@ namespace Luban.Job.Cfg.DataConverts { title.FromIndex = column; title.ToIndex = column; - if (!title.Tags.ContainsKey("sep")) + if (type.Bean is DefBean dbean && string.IsNullOrWhiteSpace(dbean.Sep)) { - title.Tags.Add("sep", "|"); + if (!title.Tags.ContainsKey("sep")) + { + title.Tags.Add("sep", "|"); + } } //int lastColumn = column - 1; diff --git a/src/Luban.Job.Cfg/Source/DataConverts/ToExcelStringVisitor.cs b/src/Luban.Job.Cfg/Source/DataConverts/ToExcelStringVisitor.cs index 5ad0361..bf1519d 100644 --- a/src/Luban.Job.Cfg/Source/DataConverts/ToExcelStringVisitor.cs +++ b/src/Luban.Job.Cfg/Source/DataConverts/ToExcelStringVisitor.cs @@ -93,11 +93,19 @@ namespace Luban.Job.Cfg.DataConverts public string Accept(DBean type, string sep) { + if (!string.IsNullOrWhiteSpace(type.Type.Sep)) + { + sep = type.Type.Sep; + } var sb = new List(); if (type.Type.IsAbstractType) { sb.Add(type.ImplType != null ? type.ImplType.Name : DefBean.BEAN_NULL_STR); } + else if (type.TType.IsNullable) + { + sb.Add(type.ImplType != null ? type.ImplType.Name : DefBean.BEAN_NULL_STR); + } foreach (var field in type.Fields) { diff --git a/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs index 3ac271d..655f6fe 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/ExcelStreamDataCreator.cs @@ -351,7 +351,7 @@ namespace Luban.Job.Cfg.DataCreators { throw new InvalidExcelDataException($"type:{fullType} 不是bean类型"); } - return new DBean(originBean, implType, CreateBeanFields(implType, x)); + return new DBean(type, implType, CreateBeanFields(implType, x)); } else { @@ -367,7 +367,7 @@ namespace Luban.Job.Cfg.DataCreators throw new Exception($"type:'{type.Bean.FullName}' 可空标识:'{subType}' 不合法(只能为{DefBean.BEAN_NOT_NULL_STR}或{DefBean.BEAN_NULL_STR}或{originBean.Name})"); } } - return new DBean(originBean, originBean, CreateBeanFields(originBean, x)); + return new DBean(type, originBean, CreateBeanFields(originBean, x)); } } diff --git a/src/Luban.Job.Cfg/Source/DataCreators/JsonDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/JsonDataCreator.cs index bf53be2..a8879ae 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/JsonDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/JsonDataCreator.cs @@ -174,7 +174,7 @@ namespace Luban.Job.Cfg.DataCreators throw new Exception($"结构:'{implBean.FullName}' 字段:'{f.Name}' 缺失"); } } - return new DBean(bean, implBean, fields); + return new DBean(type, implBean, fields); } private List ReadList(TType type, JsonElement e, DefAssembly ass) diff --git a/src/Luban.Job.Cfg/Source/DataCreators/LuaDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/LuaDataCreator.cs index a6f959f..7cacfab 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/LuaDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/LuaDataCreator.cs @@ -205,7 +205,7 @@ namespace Luban.Job.Cfg.DataCreators throw new Exception($"结构:{implBean.FullName} 字段:{f.Name} 缺失"); } } - return new DBean(bean, implBean, fields); + return new DBean(type, implBean, fields); } private List ReadList(TType type, LuaTable e, DefAssembly ass) diff --git a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs index bbc1b35..e9da915 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/SheetDataCreator.cs @@ -345,7 +345,7 @@ namespace Luban.Job.Cfg.DataCreators { throw new Exception($"type:'{fullType}' 不是 bean 类型"); } - return new DBean(originBean, implType, CreateBeanFields(implType, sheet, row)); + return new DBean(type, implType, CreateBeanFields(implType, sheet, row)); } else { @@ -362,7 +362,7 @@ namespace Luban.Job.Cfg.DataCreators } } - return new DBean(originBean, originBean, CreateBeanFields(originBean, sheet, row)); + return new DBean(type, originBean, CreateBeanFields(originBean, sheet, row)); } } else if (row.Elements != null) diff --git a/src/Luban.Job.Cfg/Source/DataCreators/XmlDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/XmlDataCreator.cs index 943cc76..061c277 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/XmlDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/XmlDataCreator.cs @@ -145,7 +145,7 @@ namespace Luban.Job.Cfg.DataCreators } } - return new DBean(bean, implBean, fields); + return new DBean(type, implBean, fields); } private List ReadList(TType type, XElement x, DefAssembly ass) diff --git a/src/Luban.Job.Cfg/Source/DataCreators/YamlDataCreator.cs b/src/Luban.Job.Cfg/Source/DataCreators/YamlDataCreator.cs index 9af8d09..cb8bfbc 100644 --- a/src/Luban.Job.Cfg/Source/DataCreators/YamlDataCreator.cs +++ b/src/Luban.Job.Cfg/Source/DataCreators/YamlDataCreator.cs @@ -155,7 +155,7 @@ namespace Luban.Job.Cfg.DataCreators } } - return new DBean(bean, implBean, fields); + return new DBean(type, implBean, fields); } private List ReadList(TType type, YamlSequenceNode x, DefAssembly ass) diff --git a/src/Luban.Job.Cfg/Source/Datas/DBean.cs b/src/Luban.Job.Cfg/Source/Datas/DBean.cs index ed4ff81..f8de771 100644 --- a/src/Luban.Job.Cfg/Source/Datas/DBean.cs +++ b/src/Luban.Job.Cfg/Source/Datas/DBean.cs @@ -1,13 +1,16 @@ using Luban.Job.Cfg.DataVisitors; using Luban.Job.Cfg.Defs; using Luban.Job.Cfg.Utils; +using Luban.Job.Common.Types; using System.Collections.Generic; namespace Luban.Job.Cfg.Datas { public class DBean : DType { - public DefBean Type { get; } + public TBean TType { get; } + + public DefBean Type => (DefBean)TType.Bean; public DefBean ImplType { get; } @@ -15,9 +18,9 @@ namespace Luban.Job.Cfg.Datas public override string TypeName => "bean"; - public DBean(DefBean defType, DefBean implType, List fields) + public DBean(TBean defType, DefBean implType, List fields) { - this.Type = defType; + this.TType = defType; this.ImplType = implType; this.Fields = fields; }