fix 优化sqlsugarpack

This commit is contained in:
2024-07-25 17:47:25 +08:00
parent 70edac18a3
commit 3d899371a1
8 changed files with 44 additions and 197 deletions

View File

@@ -1,12 +0,0 @@
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.Startup;
namespace Dlhis.Canteen;
public class SqlSugarPack : BaseAppPack
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddSqlSugar();
}
}

View File

@@ -1,35 +0,0 @@
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.Startup;
using SqlSugar;
namespace Dlhis.Common.Packs;
public class SqlSugarPack : BaseAppPack
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddSqlSugar(sp =>
{
var configuration = sp.GetService<IConfiguration>();
return new List<ConnectionConfig>
{
new()
{
ConfigId = "log",
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
},
};
});
}
}

View File

@@ -3,14 +3,16 @@ using Kurisu.AspNetCore;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Kurisu.AspNetCore.Startup;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace Dlhis.Basic.Packs;
namespace Dlhis.Entity;
public class SqlSugarPack : BaseAppPack
{
public override bool IsBeforeUseRouting { get; }
public override void ConfigureServices(IServiceCollection services)
{
services.AddSqlSugar(sp =>
@@ -19,6 +21,34 @@ public class SqlSugarPack : BaseAppPack
return new List<ConnectionConfig>
{
new()
{
ConfigId = "default",
ConnectionString = configuration.GetSection("SqlSugarOptions:DefaultConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
},
new()
{
ConfigId = "identity",
ConnectionString = configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
},
new()
{
ConfigId = "face",

View File

@@ -267,7 +267,7 @@ public class GainfoUpdateService : IGainfoUpdateService
EntryDate = item.createdate,
ResignationDate = item.ZLZRQ,
CardType = Convert.ToInt32(item.ZZ_KLX),
Workplace = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDJDNM)?.Code ?? item.ZZ_GZDJDNM,
Workplace = _tenants.LastOrDefault(x => x.Name == item.ZZ_GZDJDNM)?.Code ?? item.ZZ_GZDJDNM,
Factory = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM,
};
@@ -308,7 +308,7 @@ public class GainfoUpdateService : IGainfoUpdateService
if (gainfo != null)
{
var workplace = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDJDNM)?.Code ?? item.ZZ_GZDJDNM;
var factory = _tenants.FirstOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM;
var factory = _tenants.LastOrDefault(x => x.Name == item.ZZ_GZDCQNM)?.Code ?? item.ZZ_GZDCQNM;
await _dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
{
SapNo = item.PERNR,

View File

@@ -1,62 +0,0 @@
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.Startup;
using SqlSugar;
namespace Dlhis.ScheduledTask.Packs;
public class SqlSugarPack : BaseAppPack
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddSqlSugar(sp =>
{
var configuration = sp.GetService<IConfiguration>();
return new List<ConnectionConfig>
{
new()
{
ConfigId = "identity",
ConnectionString = configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
},
new()
{
ConfigId = "face",
ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
},
new()
{
ConfigId = "log",
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
},
};
});
}
}

View File

@@ -1,48 +0,0 @@
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.Startup;
using SqlSugar;
namespace Dlhis.Sys;
public class SqlSugarPack : BaseAppPack
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddSqlSugar(sp =>
{
var configuration = sp.GetService<IConfiguration>();
return new List<ConnectionConfig>
{
new()
{
ConfigId = "identity",
ConnectionString = configuration.GetSection("SqlSugarOptions:IdentityConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
},
new()
{
ConfigId = "default",
ConnectionString = configuration.GetSection("SqlSugarOptions:DefaultConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
}
};
});
}
}

View File

@@ -20,6 +20,14 @@
"yikatong": "yikatong"
}
},
"SqlSugarOptions": {
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
"IdentityConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=identity;charset=utf8mb4;",
"SlaveConnectionString": [],
"Timeout": 30,
"SlowSqlTime": 1,
"EnableSqlLog": true
},
"IdentityServerOptions": {
"Authority": "https://yikatong.isawesome.cn/oauth2",
"RequireHttpsMetadata": true,

View File

@@ -1,34 +0,0 @@
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.Startup;
using SqlSugar;
namespace Dlhis.Visitor.Packs;
public class SqlSugarPack : BaseAppPack
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddSqlSugar(sp =>
{
var configuration = sp.GetService<IConfiguration>();
return new List<ConnectionConfig>
{
new()
{
ConfigId = "face",
ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value,
DbType = DbType.MySqlConnector,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
MoreSettings = new ConnMoreSettings
{
DisableNvarchar = true,
}
}
};
});
}
}