【修复】修复上次调整DataExport引发的新的导出数据的bug

【调整】调整输出数据文件名为 <full_name>.replace('.','_').lower()
main
walon 2021-08-30 10:43:55 +08:00
parent 732297411c
commit 8069c6d7fe
10 changed files with 32 additions and 34 deletions

View File

@ -100,11 +100,15 @@ namespace Luban.Job.Cfg.DataExporters
x.WriteInt(type.ImplType.Id); x.WriteInt(type.ImplType.Id);
} }
var defFields = type.ImplType.HierarchyExportFields; var defFields = type.ImplType.HierarchyFields;
int index = 0; int index = 0;
foreach (var field in type.Fields) foreach (var field in type.Fields)
{ {
var defField = defFields[index++]; var defField = (DefField)defFields[index++];
if (!defField.NeedExport)
{
continue;
}
if (defField.CType.IsNullable) if (defField.CType.IsNullable)
{ {
if (field != null) if (field != null)

View File

@ -107,15 +107,15 @@ namespace Luban.Job.Cfg.DataExporters
x.WriteStringValue(type.ImplType.Name); x.WriteStringValue(type.ImplType.Name);
} }
var defFields = type.ImplType.HierarchyExportFields; var defFields = type.ImplType.HierarchyFields;
int index = 0; int index = 0;
foreach (var d in type.Fields) foreach (var d in type.Fields)
{ {
var defField = defFields[index++]; var defField = (DefField)defFields[index++];
// 特殊处理 bean 多态类型 // 特殊处理 bean 多态类型
// 另外,不生成 xxx:null 这样 // 另外,不生成 xxx:null 这样
if (d == null /*|| (d is DBean db && db.ImplType == null)*/) if (d == null || !defField.NeedExport)
{ {
//x.WriteNullValue(); //x.WriteNullValue();
} }

View File

@ -19,13 +19,11 @@ namespace Luban.Job.Cfg.DataVisitors
public override string Accept(DBean type) public override string Accept(DBean type)
{ {
var x = new StringBuilder(); var x = new StringBuilder();
bool prevProperty = false;
if (type.Type.IsAbstractType) if (type.Type.IsAbstractType)
{ {
x.Append($"{{ \"_name\":\"{type.ImplType.Name}\""); x.Append($"{{ \"_name\":\"{type.ImplType.Name}\"");
if (type.Fields.Count > 0) prevProperty = true;
{
x.Append(',');
}
} }
else else
{ {
@ -35,15 +33,19 @@ namespace Luban.Job.Cfg.DataVisitors
int index = 0; int index = 0;
foreach (var f in type.Fields) foreach (var f in type.Fields)
{ {
var defField = type.ImplType.HierarchyExportFields[index++]; var defField = (DefField)type.ImplType.HierarchyFields[index++];
if (f == null) if (f == null || !defField.NeedExport)
{ {
continue; continue;
} }
if (index > 1) if (prevProperty)
{ {
x.Append(','); x.Append(',');
} }
else
{
prevProperty = true;
}
x.Append('\"').Append(defField.Name).Append('\"').Append(':'); x.Append('\"').Append(defField.Name).Append('\"').Append(':');
x.Append(f.Apply(this)); x.Append(f.Apply(this));
} }

View File

@ -31,8 +31,8 @@ namespace Luban.Job.Cfg.DataVisitors
int index = 0; int index = 0;
foreach (var f in type.Fields) foreach (var f in type.Fields)
{ {
var defField = type.ImplType.HierarchyExportFields[index++]; var defField = (DefField)type.ImplType.HierarchyFields[index++];
if (f == null) if (f == null || !defField.NeedExport)
{ {
continue; continue;
} }

View File

@ -32,20 +32,14 @@ namespace Luban.Job.Cfg.DataVisitors
int index = 0; int index = 0;
foreach (var f in type.Fields) foreach (var f in type.Fields)
{ {
if (index >= 1) var defField = (DefField)type.ImplType.HierarchyFields[index++];
if (f == null || !defField.NeedExport)
{ {
x.Append(','); continue;
} }
var defField = type.ImplType.HierarchyExportFields[index++];
x.Append('\"').Append(defField.Name).Append('\"').Append(':'); x.Append('\"').Append(defField.Name).Append('\"').Append(':');
if (f != null) x.Append(f.Apply(this));
{ x.Append(',');
x.Append(f.Apply(this));
}
else
{
x.Append("None");
}
} }
x.Append('}'); x.Append('}');
return x.ToString(); return x.ToString();

View File

@ -31,7 +31,7 @@ namespace Luban.Job.Cfg.DataVisitors
int index = 0; int index = 0;
foreach (var f in type.Fields) foreach (var f in type.Fields)
{ {
var defField = type.ImplType.HierarchyExportFields[index++]; var defField = type.ImplType.HierarchyFields[index++];
x.Append(defField.Name).Append(':'); x.Append(defField.Name).Append(':');
if (f != null) if (f != null)
{ {

View File

@ -52,12 +52,10 @@ namespace Luban.Job.Cfg.Defs
public bool NeedExport => Assembly.NeedExport(this.Groups); public bool NeedExport => Assembly.NeedExport(this.Groups);
public string OutputDataFile => FullName; public string OutputDataFile => FullName.Replace('.', '_').ToLower();
public string InnerName => "_" + this.Name; public string InnerName => "_" + this.Name;
public string OutputDataFileEscapeDot => FullName.Replace('.', '_');
public List<string> GetBranchInputFiles(string branchName) public List<string> GetBranchInputFiles(string branchName)
{ {
return _branchInputFiles.GetValueOrDefault(branchName); return _branchInputFiles.GetValueOrDefault(branchName);

View File

@ -18,14 +18,14 @@ namespace Luban.Job.Cfg.Utils
public static string ToLocalizedText(DText type) public static string ToLocalizedText(DText type)
{ {
var ass = DefAssembly.LocalAssebmly as DefAssembly; var ass = DefAssembly.LocalAssebmly;
return type.GetText(ass.ExportTextTable, ass.NotConvertTextSet); return type.GetText(ass.ExportTextTable, ass.NotConvertTextSet);
} }
public static DType GetField(DBean bean, string fieldName) public static DType GetField(DBean bean, string fieldName)
{ {
int index = 0; int index = 0;
foreach (var f in bean.ImplType.HierarchyExportFields) foreach (var f in bean.ImplType.HierarchyFields)
{ {
if (f.Name == fieldName) if (f.Name == fieldName)
{ {

View File

@ -137,7 +137,7 @@ namespace Luban.Job.Common.Utils
public static string GetOutputFileName(string genType, string fileName) public static string GetOutputFileName(string genType, string fileName)
{ {
return $"{fileName.Replace('.', '_')}.{GetOutputFileSuffix(genType)}"; return $"{fileName}.{GetOutputFileSuffix(genType)}";
} }
} }
} }

View File

@ -39,9 +39,9 @@ local tables =
{ {
{{~for table in tables ~}} {{~for table in tables ~}}
{{~if table.is_map_table ~}} {{~if table.is_map_table ~}}
{ name='{{table.name}}', file='{{table.output_data_file_escape_dot}}', mode='map', index='{{table.index}}', value_type='{{table.value_ttype.bean.full_name}}' }, { name='{{table.name}}', file='{{table.output_data_file}}', mode='map', index='{{table.index}}', value_type='{{table.value_ttype.bean.full_name}}' },
{{~else~}} {{~else~}}
{ name='{{table.name}}', file='{{table.output_data_file_escape_dot}}', mode='one', value_type='{{table.value_ttype.bean.full_name}}'}, { name='{{table.name}}', file='{{table.output_data_file}}', mode='one', value_type='{{table.value_ttype.bean.full_name}}'},
{{end}} {{end}}
{{~end~}} {{~end~}}
} }