【修复】修复一些将field拼成filed的错误
【优化】当table从xlsx中读取定义时,如果value不包含命名空间,则使用table所在的命名空间;如果包含,则使用它的命名空间 【修复】修复从xlsx读取的table定义,未检查table名唯一的bug。main
parent
6bcc8e74ce
commit
8b0f607f4a
|
|
@ -8,6 +8,7 @@ using Luban.Job.Cfg.Utils;
|
|||
using Luban.Job.Common.Defs;
|
||||
using Luban.Job.Common.RawDefs;
|
||||
using Luban.Job.Common.Types;
|
||||
using Luban.Job.Common.Utils;
|
||||
using Luban.Server.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -312,7 +313,12 @@ namespace Luban.Job.Cfg.Defs
|
|||
ExcelTableValueTypeDefInfoCacheManager.Instance.AddTableDefInfoToCache(file.MD5, file.SheetName, tableDefInfo);
|
||||
}
|
||||
|
||||
var cb = new CfgBean() { Namespace = table.Namespace, Name = table.ValueType, Comment = "" };
|
||||
var ns = TypeUtil.GetNamespace(table.ValueType);
|
||||
|
||||
string valueTypeNamespace = string.IsNullOrEmpty(ns) ? table.Namespace : ns;
|
||||
string valueTypeName = TypeUtil.GetName(table.ValueType);
|
||||
|
||||
var cb = new CfgBean() { Namespace = valueTypeNamespace, Name = valueTypeName, Comment = "" };
|
||||
#if !LUBAN_LITE
|
||||
foreach (var (name, f) in tableDefInfo.FieldInfos)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,7 +57,8 @@ namespace Luban.Job.Cfg.Defs
|
|||
|
||||
private readonly ConcurrentDictionary<string, TableDataInfo> _recordsByTables = new();
|
||||
|
||||
public Dictionary<string, DefTable> CfgTables { get; } = new Dictionary<string, DefTable>();
|
||||
public Dictionary<string, DefTable> CfgTablesByName = new();
|
||||
public Dictionary<string, DefTable> CfgTablesByFullName { get; } = new Dictionary<string, DefTable>();
|
||||
|
||||
#if !LUBAN_LITE
|
||||
public RawTextTable RawTextTable { get; } = new RawTextTable();
|
||||
|
|
@ -83,15 +84,19 @@ namespace Luban.Job.Cfg.Defs
|
|||
|
||||
public void AddCfgTable(DefTable table)
|
||||
{
|
||||
if (!CfgTables.TryAdd(table.FullName, table))
|
||||
if (!CfgTablesByFullName.TryAdd(table.FullName, table))
|
||||
{
|
||||
throw new Exception($"table:'{table.FullName}' duplicated");
|
||||
}
|
||||
if (!CfgTablesByName.TryAdd(table.Name, table))
|
||||
{
|
||||
throw new Exception($"table:'{table.FullName} 与 table:'{CfgTablesByName[table.Name].FullName}' 的表名重复(不同模块下也不允许定义同名表,将来可能会放开限制)");
|
||||
}
|
||||
}
|
||||
|
||||
public DefTable GetCfgTable(string name)
|
||||
{
|
||||
return CfgTables.TryGetValue(name, out var t) ? t : null;
|
||||
return CfgTablesByFullName.TryGetValue(name, out var t) ? t : null;
|
||||
}
|
||||
|
||||
public void AddDataTable(DefTable table, List<Record> mainRecords, List<Record> patchRecords)
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
if (!IgnoreNameValidation && !TypeUtil.IsValidName(Name))
|
||||
{
|
||||
throw new Exception($"type:'{HostType.FullName}' filed name:'{Name}' is reserved");
|
||||
throw new Exception($"type:'{HostType.FullName}' field name:'{Name}' is reserved");
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -120,12 +120,12 @@ namespace Luban.Job.Common.Defs
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception($"type:'{HostType.FullName}' filed:'{Name}' type:'{Type}' is invalid", e);
|
||||
throw new Exception($"type:'{HostType.FullName}' field:'{Name}' type:'{Type}' is invalid", e);
|
||||
}
|
||||
|
||||
//if (IsNullable && (CType.IsCollection || (CType is TBean)))
|
||||
//{
|
||||
// throw new Exception($"type:{HostType.FullName} filed:{Name} type:{Type} is collection or bean. not support nullable");
|
||||
// throw new Exception($"type:{HostType.FullName} field:{Name} type:{Type} is collection or bean. not support nullable");
|
||||
//}
|
||||
|
||||
switch (CType)
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ namespace Luban.Job.Common.Defs
|
|||
return type.Apply(JavaBoxDefineTypeName.Ins);
|
||||
}
|
||||
|
||||
public static string JavaToString(string filedName, TType type)
|
||||
public static string JavaToString(string fieldName, TType type)
|
||||
{
|
||||
return $"{filedName}";
|
||||
return $"{fieldName}";
|
||||
}
|
||||
|
||||
public static string JavaConstValue(TType type, string value)
|
||||
|
|
@ -128,9 +128,9 @@ namespace Luban.Job.Common.Defs
|
|||
return type.Apply(TypescriptDefineTypeNameVisitor.Ins);
|
||||
}
|
||||
|
||||
public static string TsToString(string filedName, TType type)
|
||||
public static string TsToString(string fieldName, TType type)
|
||||
{
|
||||
return filedName;
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public static string TsCtorDefaultValue(TType type)
|
||||
|
|
|
|||
Loading…
Reference in New Issue