fix 优化apilog和设备上传log

This commit is contained in:
2024-02-26 16:17:59 +08:00
parent d341f43009
commit 3bf049a51e
13 changed files with 207 additions and 200 deletions

View File

@@ -57,7 +57,6 @@ public class EnumsController : ControllerBase
})
.ToList();
//todo cache 速度
var dbTypes = _dbContext.Queryable<BasicTypeEntity>().OrderBy(x => x.Sequence).ToList();
var dbResult = dbTypes.GroupBy(x => x.Type).Select(g =>
{
@@ -77,6 +76,29 @@ public class EnumsController : ControllerBase
result.AddRange(dbResult);
result.Add(GetCurrentEnums("LogLevel", "日志级别", typeof(LogLevel)));
return result;
}
private static CommonEnumResponse GetCurrentEnums(string code, string name, Type enumType)
{
return new CommonEnumResponse
{
Code = code,
Name = name,
Data = enumType.GetFields(BindingFlags.Public | BindingFlags.Static).Select(item =>
{
var e = (Enum)Enum.Parse(item.FieldType, item.GetValue(null).ToString());
var fd = e.GetDescription();
return new KeyValueDto
{
Key = fd,
Value = (int)item.GetValue(null)
};
})
.ToList()
};
}
}