feat: 枚举批量插入字典 MySql 支持,连接字符串需要加上 AllowUserVariables=true;

This commit is contained in:
写意 2025-04-18 10:57:41 +08:00
parent fe5211e5fa
commit 92cadfff95

View File

@ -31,7 +31,8 @@ public class SysEnumService : IDynamicApiController, ITransient
public List<EnumTypeOutput> GetEnumTypeList()
{
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)))
.Where(t => _enumOptions.EntityAssemblyNames.Contains(t.Assembly.GetName().Name) ||
_enumOptions.EntityAssemblyNames.Any(name => t.Assembly.GetName().Name.Contains(name)))
.Where(t => t.GetCustomAttributes(typeof(ErrorCodeTypeAttribute), false).Length == 0) // 排除错误代码类型
.OrderBy(u => u.Name).ThenBy(u => u.FullName)
.ToList();
@ -53,6 +54,7 @@ public class SysEnumService : IDynamicApiController, ITransient
var att = ((DescriptionAttribute[])attrs)[0];
description = att.Description;
}
var enumType = App.EffectiveTypes.FirstOrDefault(t => t.IsEnum && t.Name == type.Name);
return new EnumTypeOutput
{
@ -124,13 +126,11 @@ public class SysEnumService : IDynamicApiController, ITransient
var (newDictTypes, newDictDatas) = GetNewSysDicts(newEnumType);
// 若是Sqlite、PostgreSQL、SqlServer、MySql、GaussDB、Kdbndp则采用批量处理
bool enableBulk = _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.Sqlite
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.PostgreSQL
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.SqlServer;
//|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.MySql
//|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.MySqlConnector
//|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.GaussDB
//|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.Kdbndp;
bool enableBulk = _db.CurrentConnectionConfig.DbType is SqlSugar.DbType.Sqlite or SqlSugar.DbType.PostgreSQL
or SqlSugar.DbType.SqlServer or SqlSugar.DbType.MySql;
// or SqlSugar.DbType.MySqlConnector
// or SqlSugar.DbType.GaussDB
// or SqlSugar.DbType.Kdbndp;
// 执行数据库操作
if (updatedDictTypes.Count > 0)