😎1、枚举转字典支持枚举新增枚举值的情况 2、调整控制台消息颜色 3、升级依赖
This commit is contained in:
parent
5ca30dfee7
commit
c6b703036e
@ -18,9 +18,9 @@
|
||||
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.15.7" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.5.12" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.5.12" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.5.12" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.5.13" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.5.13" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.5.13" />
|
||||
<PackageReference Include="Hardware.Info" Version="101.0.0" />
|
||||
<PackageReference Include="Hashids.net" Version="1.7.0" />
|
||||
<PackageReference Include="IPTools.China" Version="1.6.0" />
|
||||
@ -28,7 +28,7 @@
|
||||
<PackageReference Include="Magicodes.IE.Excel" Version="2.7.5.2" />
|
||||
<PackageReference Include="Magicodes.IE.Pdf" Version="2.7.5.2" />
|
||||
<PackageReference Include="Magicodes.IE.Word" Version="2.7.5.2" />
|
||||
<PackageReference Include="MailKit" Version="4.7.1.1" />
|
||||
<PackageReference Include="MailKit" Version="4.8.0" />
|
||||
<PackageReference Include="MQTTnet" Version="4.3.7.1207" />
|
||||
<PackageReference Include="MySqlBackup.NET.MySqlConnector" Version="2.3.8" />
|
||||
<PackageReference Include="NewLife.Redis" Version="5.7.2024.801" />
|
||||
@ -38,11 +38,11 @@
|
||||
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.2" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.8" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.5.0" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.7.0" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.8.0" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.169" />
|
||||
<PackageReference Include="SSH.NET" Version="2024.1.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.5" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1097" />
|
||||
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1099" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
//
|
||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
|
||||
using AngleSharp.Common;
|
||||
|
||||
namespace Admin.NET.Core;
|
||||
|
||||
/// <summary>
|
||||
@ -43,7 +41,7 @@ public class EnumToDictJob : IJob
|
||||
var updatedEnumCodes = sysDictTypeList.Select(u => u.Code);
|
||||
var updatedEnumType = enumTypeList.Where(u => updatedEnumCodes.Contains(u.TypeName)).ToList();
|
||||
var sysDictTypeDict = sysDictTypeList.ToDictionary(u => u.Code, u => u);
|
||||
var (updatedDictTypes, updatedDictDatas) = GetUpdatedDicts(updatedEnumType, sysDictTypeDict);
|
||||
var (updatedDictTypes, updatedDictDatas, newSysDictDatas) = GetUpdatedDicts(updatedEnumType, sysDictTypeDict);
|
||||
|
||||
// 新增的枚举转换字典
|
||||
var newEnumType = enumTypeList.Where(u => !updatedEnumCodes.Contains(u.TypeName)).ToList();
|
||||
@ -52,7 +50,7 @@ public class EnumToDictJob : IJob
|
||||
// 执行数据库操作
|
||||
try
|
||||
{
|
||||
db.BeginTran();
|
||||
await db.BeginTranAsync();
|
||||
|
||||
if (updatedDictTypes.Count > 0)
|
||||
await db.Updateable(updatedDictTypes).ExecuteCommandAsync(stoppingToken);
|
||||
@ -60,17 +58,20 @@ public class EnumToDictJob : IJob
|
||||
if (updatedDictDatas.Count > 0)
|
||||
await db.Updateable(updatedDictDatas).ExecuteCommandAsync(stoppingToken);
|
||||
|
||||
if (newSysDictDatas.Count > 0)
|
||||
await db.Insertable(newSysDictDatas).ExecuteCommandAsync(stoppingToken);
|
||||
|
||||
if (newDictTypes.Count > 0)
|
||||
await db.Insertable(newDictTypes).ExecuteCommandAsync(stoppingToken);
|
||||
|
||||
if (newDictDatas.Count > 0)
|
||||
await db.Insertable(newDictDatas).ExecuteCommandAsync(stoppingToken);
|
||||
|
||||
db.CommitTran();
|
||||
await db.CommitTranAsync();
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
db.RollbackTran();
|
||||
await db.RollbackTranAsync();
|
||||
Log.Error($"系统枚举转换字典操作错误:{error.Message}\n堆栈跟踪:{error.StackTrace}", error);
|
||||
throw;
|
||||
}
|
||||
@ -95,34 +96,35 @@ public class EnumToDictJob : IJob
|
||||
{
|
||||
var newDictType = new List<SysDictType>();
|
||||
var newDictData = new List<SysDictData>();
|
||||
if (addEnumType.Count > 0)
|
||||
if (addEnumType.Count <= 0)
|
||||
return (newDictType, newDictData);
|
||||
|
||||
// 新增字典类型
|
||||
newDictType = addEnumType.Select(u => new SysDictType
|
||||
{
|
||||
// 新增字典类型
|
||||
newDictType = addEnumType.Select(u => new SysDictType
|
||||
Id = YitIdHelper.NextId(),
|
||||
Code = u.TypeName,
|
||||
Name = u.TypeDescribe,
|
||||
Remark = u.TypeRemark,
|
||||
Status = StatusEnum.Enable
|
||||
}).ToList();
|
||||
|
||||
// 新增字典数据
|
||||
newDictData = addEnumType.Join(newDictType, t1 => t1.TypeName, t2 => t2.Code, (t1, t2) => new
|
||||
{
|
||||
Data = t1.EnumEntities.Select(u => new SysDictData
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
Code = u.TypeName,
|
||||
Name = u.TypeDescribe,
|
||||
Remark = u.TypeRemark,
|
||||
Status = StatusEnum.Enable
|
||||
}).ToList();
|
||||
DictTypeId = t2.Id,
|
||||
Name = u.Describe,
|
||||
Value = u.Value.ToString(),
|
||||
Code = u.Name,
|
||||
Remark = t2.Remark,
|
||||
OrderNo = u.Value + OrderOffset,
|
||||
TagType = u.Theme != "" ? u.Theme : DefaultTagType,
|
||||
}).ToList()
|
||||
}).SelectMany(x => x.Data).ToList();
|
||||
|
||||
// 新增字典数据
|
||||
newDictData = addEnumType.Join(newDictType, t1 => t1.TypeName, t2 => t2.Code, (t1, t2) => new
|
||||
{
|
||||
Data = t1.EnumEntities.Select(u => new SysDictData
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
DictTypeId = t2.Id,
|
||||
Name = u.Describe,
|
||||
Value = u.Value.ToString(),
|
||||
Code = u.Name,
|
||||
Remark = t2.Remark,
|
||||
OrderNo = u.Value + OrderOffset,
|
||||
TagType = u.Theme != "" ? u.Theme : DefaultTagType,
|
||||
}).ToList()
|
||||
}).SelectMany(x => x.Data).ToList();
|
||||
}
|
||||
return (newDictType, newDictData);
|
||||
}
|
||||
|
||||
@ -134,42 +136,70 @@ public class EnumToDictJob : IJob
|
||||
/// <returns>
|
||||
/// 一个元组,包含以下元素:
|
||||
/// <list type="table">
|
||||
/// <item><term>SysDictTypes</term><description>字典类型列表</description>
|
||||
/// <item><term>SysDictTypes</term><description>更新字典类型列表</description>
|
||||
/// </item>
|
||||
/// <item><term>SysDictDatas</term><description>字典数据列表</description>
|
||||
/// <item><term>SysDictDatas</term><description>更新字典数据列表</description>
|
||||
/// </item>
|
||||
/// <item><term>SysDictDatas</term><description>新增字典数据列表</description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </returns>
|
||||
private (List<SysDictType>, List<SysDictData>) GetUpdatedDicts(List<EnumTypeOutput> updatedEnumType, Dictionary<string, SysDictType> sysDictTypeDict)
|
||||
private (List<SysDictType>, List<SysDictData>, List<SysDictData>) GetUpdatedDicts(List<EnumTypeOutput> updatedEnumType, Dictionary<string, SysDictType> sysDictTypeDict)
|
||||
{
|
||||
var updatedSysDictTypes = new List<SysDictType>();
|
||||
var updatedSysDictData = new List<SysDictData>();
|
||||
var newSysDictData = new List<SysDictData>();
|
||||
foreach (var e in updatedEnumType)
|
||||
{
|
||||
if (sysDictTypeDict.TryGetValue(e.TypeName, out var value))
|
||||
{
|
||||
var updatedDictType = value;
|
||||
updatedDictType.Name = e.TypeDescribe;
|
||||
updatedDictType.Remark = e.TypeRemark;
|
||||
updatedSysDictTypes.Add(updatedDictType);
|
||||
var updatedDictData = updatedDictType.Children.Where(u => u.DictTypeId == updatedDictType.Id).ToList();
|
||||
if (!sysDictTypeDict.TryGetValue(e.TypeName, out var value))
|
||||
continue;
|
||||
|
||||
// 遍历需要更新的字典数据
|
||||
foreach (var dictData in updatedDictData)
|
||||
var updatedDictType = value;
|
||||
updatedDictType.Name = e.TypeDescribe;
|
||||
updatedDictType.Remark = e.TypeRemark;
|
||||
updatedSysDictTypes.Add(updatedDictType);
|
||||
var updatedDictData = updatedDictType.Children.Where(u => u.DictTypeId == updatedDictType.Id).ToList();
|
||||
|
||||
// 遍历需要更新的字典数据
|
||||
foreach (var dictData in updatedDictData)
|
||||
{
|
||||
var enumData = e.EnumEntities.FirstOrDefault(u => dictData.Code == u.Name);
|
||||
if (enumData != null)
|
||||
{
|
||||
var enumData = e.EnumEntities.Where(u => dictData.Code == u.Name).FirstOrDefault();
|
||||
if (enumData != null)
|
||||
{
|
||||
dictData.Value = enumData.Value.ToString();
|
||||
dictData.OrderNo = enumData.Value + OrderOffset;
|
||||
dictData.Name = enumData.Describe;
|
||||
dictData.TagType = enumData.Theme != "" ? enumData.Theme : dictData.TagType != "" ? dictData.TagType : DefaultTagType;
|
||||
updatedSysDictData.Add(dictData);
|
||||
}
|
||||
dictData.Value = enumData.Value.ToString();
|
||||
dictData.OrderNo = enumData.Value + OrderOffset;
|
||||
dictData.Name = enumData.Describe;
|
||||
dictData.TagType = enumData.Theme != "" ? enumData.Theme : dictData.TagType != "" ? dictData.TagType : DefaultTagType;
|
||||
updatedSysDictData.Add(dictData);
|
||||
}
|
||||
}
|
||||
|
||||
// 新增的枚举值名称列表
|
||||
var newEnumDataNameList = e.EnumEntities.Select(u => u.Name).Except(updatedDictData.Select(u => u.Code));
|
||||
foreach (var newEnumDataName in newEnumDataNameList)
|
||||
{
|
||||
var enumData = e.EnumEntities.FirstOrDefault(u => newEnumDataName == u.Name);
|
||||
if (enumData != null)
|
||||
{
|
||||
var dictData = new SysDictData
|
||||
{
|
||||
Id = YitIdHelper.NextId(),
|
||||
DictTypeId = updatedDictType.Id,
|
||||
Name = enumData.Describe,
|
||||
Value = enumData.Value.ToString(),
|
||||
Code = enumData.Name,
|
||||
Remark = updatedDictType.Remark,
|
||||
OrderNo = enumData.Value + OrderOffset,
|
||||
TagType = enumData.Theme != "" ? enumData.Theme : DefaultTagType,
|
||||
};
|
||||
dictData.TagType = enumData.Theme != "" ? enumData.Theme : dictData.TagType != "" ? dictData.TagType : DefaultTagType;
|
||||
newSysDictData.Add(dictData);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除的情况暂不处理
|
||||
}
|
||||
|
||||
return (updatedSysDictTypes, updatedSysDictData);
|
||||
return (updatedSysDictTypes, updatedSysDictData, newSysDictData);
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,7 @@ public class OnlineUserJob : IJob
|
||||
|
||||
string msg = $"【{DateTime.Now}】清理在线用户成功!服务已重启...";
|
||||
var originColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine(msg);
|
||||
Console.ForegroundColor = originColor;
|
||||
|
||||
|
||||
@ -28,7 +28,8 @@ public class SysEnumService : IDynamicApiController, ITransient
|
||||
{
|
||||
var enumTypeList = App.EffectiveTypes.Where(t => t.IsEnum)
|
||||
.Where(t => _enumOptions.EntityAssemblyNames.Contains(t.Assembly.GetName().Name) || _enumOptions.EntityAssemblyNames.Any(name => t.Assembly.GetName().Name.Contains(name)))
|
||||
.OrderBy(u => u.Name).OrderBy(u => u.FullName)
|
||||
.Where(t => t.GetCustomAttributes(typeof(ErrorCodeTypeAttribute), false).Length == 0) // 排除错误代码类型
|
||||
.OrderBy(u => u.Name).ThenBy(u => u.FullName)
|
||||
.ToList();
|
||||
|
||||
var result = new List<EnumTypeOutput>();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "admin.net.pro",
|
||||
"type": "module",
|
||||
"version": "2.4.33",
|
||||
"lastBuildTime": "2024.09.27",
|
||||
"lastBuildTime": "2024.09.30",
|
||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||
"author": "zuohuaijun",
|
||||
"license": "MIT",
|
||||
@ -59,7 +59,7 @@
|
||||
"splitpanes": "^3.1.5",
|
||||
"vcrontab-3": "^3.3.22",
|
||||
"vform3-builds": "^3.0.10",
|
||||
"vue": "^3.5.9",
|
||||
"vue": "^3.5.10",
|
||||
"vue-clipboard3": "^2.0.0",
|
||||
"vue-demi": "0.14.6",
|
||||
"vue-draggable-plus": "^0.5.3",
|
||||
@ -70,10 +70,10 @@
|
||||
"vue-router": "^4.4.5",
|
||||
"vue-signature-pad": "^3.0.2",
|
||||
"vue3-tree-org": "^4.2.2",
|
||||
"vxe-pc-ui": "^4.2.6",
|
||||
"vxe-pc-ui": "^4.2.10",
|
||||
"vxe-table": "^4.7.59",
|
||||
"vxe-table-plugin-element": "^4.0.4",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.5",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.6",
|
||||
"xe-utils": "^3.5.29",
|
||||
"xlsx-js-style": "^1.2.0"
|
||||
},
|
||||
@ -88,7 +88,7 @@
|
||||
"@typescript-eslint/parser": "^8.7.0",
|
||||
"@vitejs/plugin-vue": "^5.1.4",
|
||||
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
||||
"@vue/compiler-sfc": "^3.5.9",
|
||||
"@vue/compiler-sfc": "^3.5.10",
|
||||
"code-inspector-plugin": "^0.16.1",
|
||||
"eslint": "^9.11.1",
|
||||
"eslint-plugin-vue": "^9.28.0",
|
||||
@ -96,8 +96,8 @@
|
||||
"less": "^4.2.0",
|
||||
"prettier": "^3.3.3",
|
||||
"rollup-plugin-visualizer": "^5.12.0",
|
||||
"sass": "^1.79.3",
|
||||
"terser": "^5.34.0",
|
||||
"sass": "^1.79.4",
|
||||
"terser": "^5.34.1",
|
||||
"typescript": "^5.6.2",
|
||||
"vite": "^5.4.8",
|
||||
"vite-plugin-cdn-import": "^1.0.1",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user