😎代码优化
This commit is contained in:
parent
4fad9e5f15
commit
8525434149
@ -27,7 +27,7 @@
|
||||
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.4.0" />
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.5.1" Aliases="BouncyCastleV2" />
|
||||
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.17.4" />
|
||||
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="9.0.0" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="4.9.7.43" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.7.43" />
|
||||
<PackageReference Include="Furion.Pure" Version="4.9.7.43" />
|
||||
|
||||
@ -123,29 +123,31 @@ public class SysEnumService : IDynamicApiController, ITransient
|
||||
var newEnumType = enumTypeList.Where(u => !updatedEnumCodes.Contains(u.TypeName)).ToList();
|
||||
var (newDictTypes, newDictDatas) = GetNewSysDicts(newEnumType);
|
||||
|
||||
// 若是sqlite、pg、mysql、sqlserver则采用批量处理
|
||||
bool useBulk = _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.Sqlite
|
||||
// 若是Sqlite、PostgreSQL、MySql、SqlServer、GaussDB、Kdbndp则采用批量处理
|
||||
bool enableBulk = _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.Sqlite
|
||||
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.PostgreSQL
|
||||
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.MySql
|
||||
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.MySqlConnector
|
||||
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.SqlServer;
|
||||
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.SqlServer
|
||||
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.GaussDB
|
||||
|| _db.CurrentConnectionConfig.DbType == SqlSugar.DbType.Kdbndp;
|
||||
|
||||
// 执行数据库操作
|
||||
if (updatedDictTypes.Count > 0)
|
||||
{
|
||||
if (useBulk) await _db.Fastest<SysDictType>().PageSize(300).BulkMergeAsync(updatedDictTypes);
|
||||
if (enableBulk) await _db.Fastest<SysDictType>().PageSize(300).BulkMergeAsync(updatedDictTypes);
|
||||
else await _db.Updateable(updatedDictTypes).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (updatedDictDatas.Count > 0)
|
||||
{
|
||||
if (useBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(updatedDictDatas);
|
||||
if (enableBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(updatedDictDatas);
|
||||
else await _db.Updateable(updatedDictDatas).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (newSysDictDatas.Count > 0)
|
||||
{
|
||||
if (useBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(newSysDictDatas);
|
||||
if (enableBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(newSysDictDatas);
|
||||
else
|
||||
{
|
||||
// 达梦:用db.Insertable(newSysDictDatas).ExecuteCommandAsync(stoppingToken);插入400条以上会内容溢出错误,所以改用逐条插入
|
||||
@ -157,13 +159,13 @@ public class SysEnumService : IDynamicApiController, ITransient
|
||||
|
||||
if (newDictTypes.Count > 0)
|
||||
{
|
||||
if (useBulk) await _db.Fastest<SysDictType>().PageSize(300).BulkMergeAsync(newDictTypes);
|
||||
if (enableBulk) await _db.Fastest<SysDictType>().PageSize(300).BulkMergeAsync(newDictTypes);
|
||||
else await _db.Insertable(newDictTypes).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (newDictDatas.Count > 0)
|
||||
{
|
||||
if (useBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(newDictDatas);
|
||||
if (enableBulk) await _db.Fastest<SysDictData>().PageSize(300).BulkMergeAsync(newDictDatas);
|
||||
else
|
||||
{
|
||||
// 达梦:用db.Insertable(newDictDatas).ExecuteCommandAsync(stoppingToken);插入400条以上会内容溢出错误,所以改用逐条插入
|
||||
|
||||
Loading…
Reference in New Issue
Block a user