😎1、统一sqlsugar子库对象应用 2、代码优化
This commit is contained in:
parent
3346150bdd
commit
4b0fd6400c
@ -284,195 +284,4 @@ public class SysCommonService : IDynamicApiController, ITransient
|
|||||||
.SetJsonContent(input.JsonContent));
|
.SetJsonContent(input.JsonContent));
|
||||||
return stressTestHarnessResult;
|
return stressTestHarnessResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 从 china.sqlite 中获取区划数据
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="code">区划编码</param>
|
|
||||||
/// <param name="level">级数(从当前code所在级别往下级数)</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[DisplayName("从 china.sqlite 中获取区划数据")]
|
|
||||||
public async Task GetRegionTree(string code, int level)
|
|
||||||
{
|
|
||||||
level = level > 5 ? 5 : level;
|
|
||||||
|
|
||||||
var sqlitePath = "C:\\china.sqlite";
|
|
||||||
var db = new SqlSugarScope(new ConnectionConfig()
|
|
||||||
{
|
|
||||||
ConnectionString = $"Data Source={sqlitePath};Cache=Shared",
|
|
||||||
DbType = SqlSugar.DbType.Sqlite,
|
|
||||||
IsAutoCloseConnection = true,
|
|
||||||
InitKeyType = InitKeyType.Attribute
|
|
||||||
});
|
|
||||||
|
|
||||||
var regionList = new List<SysRegion>();
|
|
||||||
|
|
||||||
// 判断编码所属层级
|
|
||||||
int startLevel = 1; // 省
|
|
||||||
switch (code.Length)
|
|
||||||
{
|
|
||||||
case 4:
|
|
||||||
startLevel = 2; // 市
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
startLevel = 3; // 区县
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 9:
|
|
||||||
startLevel = 4; // 街道
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 12:
|
|
||||||
startLevel = 5; // 社区/村
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var region1List = GetRegionList(code, startLevel, db);
|
|
||||||
if (region1List.Count == 0)
|
|
||||||
return;
|
|
||||||
region1List.ForEach(u => u.Pid = 0);
|
|
||||||
regionList.AddRange(region1List);
|
|
||||||
|
|
||||||
if (level == 1 || startLevel == 5)
|
|
||||||
goto result;
|
|
||||||
startLevel++;
|
|
||||||
|
|
||||||
var region2List = new List<SysRegion>();
|
|
||||||
foreach (var item in region1List)
|
|
||||||
{
|
|
||||||
region2List.AddRange(GetRegionList(item.Code, startLevel, db));
|
|
||||||
}
|
|
||||||
regionList.AddRange(region2List);
|
|
||||||
|
|
||||||
if (level == 2 || startLevel == 5 || region2List.Count == 0)
|
|
||||||
goto result;
|
|
||||||
startLevel++;
|
|
||||||
|
|
||||||
var region3List = new List<SysRegion>();
|
|
||||||
foreach (var item in region2List)
|
|
||||||
{
|
|
||||||
region3List.AddRange(GetRegionList(item.Code, startLevel, db));
|
|
||||||
}
|
|
||||||
regionList.AddRange(region3List);
|
|
||||||
|
|
||||||
if (level == 3 || startLevel == 5 || region3List.Count == 0)
|
|
||||||
goto result;
|
|
||||||
startLevel++;
|
|
||||||
|
|
||||||
var region4List = new List<SysRegion>();
|
|
||||||
foreach (var item in region3List)
|
|
||||||
{
|
|
||||||
region4List.AddRange(GetRegionList(item.Code, startLevel, db));
|
|
||||||
}
|
|
||||||
regionList.AddRange(region4List);
|
|
||||||
|
|
||||||
if (level == 4 || startLevel == 5 || region4List.Count == 0)
|
|
||||||
goto result;
|
|
||||||
startLevel++;
|
|
||||||
|
|
||||||
var region5List = new List<SysRegion>();
|
|
||||||
region5List.AddRange(GetVillageList(region4List.Select(u => u.Code).ToList(), db));
|
|
||||||
regionList.AddRange(region5List);
|
|
||||||
|
|
||||||
result:
|
|
||||||
|
|
||||||
// 保存行政区划树
|
|
||||||
var defaultDbConfig = App.GetOptions<DbConnectionOptions>().ConnectionConfigs[0];
|
|
||||||
db = new SqlSugarScope(new ConnectionConfig()
|
|
||||||
{
|
|
||||||
ConnectionString = defaultDbConfig.ConnectionString,
|
|
||||||
DbType = defaultDbConfig.DbType,
|
|
||||||
IsAutoCloseConnection = true,
|
|
||||||
InitKeyType = InitKeyType.Attribute
|
|
||||||
});
|
|
||||||
await db.Deleteable<SysRegion>().ExecuteCommandAsync();
|
|
||||||
await db.Insertable(regionList).ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据层级及父级编码获取区域集合
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pCode"></param>
|
|
||||||
/// <param name="level"></param>
|
|
||||||
/// <param name="db"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static List<SysRegion> GetRegionList(string pCode, int level, SqlSugarScope db)
|
|
||||||
{
|
|
||||||
string table = "";
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
table = "province";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
table = "city";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
table = "area";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
table = "street";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
table = "village";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrWhiteSpace(table))
|
|
||||||
return [];
|
|
||||||
|
|
||||||
var condition = string.IsNullOrWhiteSpace(pCode) || pCode == "0" ? "" : $" and code like '{pCode}%'";
|
|
||||||
var sql = $"select * from {table} where 1=1 {condition}";
|
|
||||||
var regions = db.Ado.SqlQuery<SysRegion>(sql);
|
|
||||||
if (regions.Count == 0)
|
|
||||||
return [];
|
|
||||||
|
|
||||||
foreach (var item in regions)
|
|
||||||
{
|
|
||||||
item.Pid = string.IsNullOrWhiteSpace(pCode) || item.Code == pCode || level == 1 ? 0 : Convert.ToInt64(pCode);
|
|
||||||
item.Level = level;
|
|
||||||
item.Id = Convert.ToInt64(item.Code);
|
|
||||||
}
|
|
||||||
|
|
||||||
return regions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取社区/村集合
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pCodes"></param>
|
|
||||||
/// <param name="db"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static List<SysRegion> GetVillageList(List<string> pCodes, SqlSugarScope db)
|
|
||||||
{
|
|
||||||
var condition = pCodes == null || pCodes.Count == 0 ? "" : $" and streetCode in ('{pCodes.Join("','")}')";
|
|
||||||
var sql = $"select * from village where 1=1 {condition}";
|
|
||||||
var regions = db.Ado.SqlQuery<dynamic>(sql);
|
|
||||||
if (regions.Count == 0)
|
|
||||||
return [];
|
|
||||||
|
|
||||||
var regionList = new List<SysRegion>();
|
|
||||||
foreach (var item in regions)
|
|
||||||
{
|
|
||||||
var region = new SysRegion
|
|
||||||
{
|
|
||||||
Name = item.name,
|
|
||||||
Code = item.code,
|
|
||||||
Pid = Convert.ToInt64(item.streetCode),
|
|
||||||
Level = 5,
|
|
||||||
Id = Convert.ToInt64(item.code)
|
|
||||||
};
|
|
||||||
regionList.Add(region);
|
|
||||||
}
|
|
||||||
return regionList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -538,4 +538,195 @@ public class SysRegionService : IDynamicApiController, ITransient
|
|||||||
}
|
}
|
||||||
return regionList;
|
return regionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从 china.sqlite 中获取区划数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code">区划编码</param>
|
||||||
|
/// <param name="level">级数(从当前code所在级别往下级数)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[DisplayName("从 china.sqlite 中获取区划数据")]
|
||||||
|
public async Task GetRegionTree(string code, int level)
|
||||||
|
{
|
||||||
|
level = level > 5 ? 5 : level;
|
||||||
|
|
||||||
|
var sqlitePath = "C:\\china.sqlite";
|
||||||
|
var db = new SqlSugarScope(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = $"Data Source={sqlitePath};Cache=Shared",
|
||||||
|
DbType = SqlSugar.DbType.Sqlite,
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
InitKeyType = InitKeyType.Attribute
|
||||||
|
});
|
||||||
|
|
||||||
|
var regionList = new List<SysRegion>();
|
||||||
|
|
||||||
|
// 判断编码所属层级
|
||||||
|
int startLevel = 1; // 省
|
||||||
|
switch (code.Length)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
startLevel = 2; // 市
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
startLevel = 3; // 区县
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 9:
|
||||||
|
startLevel = 4; // 街道
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 12:
|
||||||
|
startLevel = 5; // 社区/村
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var region1List = GetRegionList(code, startLevel, db);
|
||||||
|
if (region1List.Count == 0)
|
||||||
|
return;
|
||||||
|
region1List.ForEach(u => u.Pid = 0);
|
||||||
|
regionList.AddRange(region1List);
|
||||||
|
|
||||||
|
if (level == 1 || startLevel == 5)
|
||||||
|
goto result;
|
||||||
|
startLevel++;
|
||||||
|
|
||||||
|
var region2List = new List<SysRegion>();
|
||||||
|
foreach (var item in region1List)
|
||||||
|
{
|
||||||
|
region2List.AddRange(GetRegionList(item.Code, startLevel, db));
|
||||||
|
}
|
||||||
|
regionList.AddRange(region2List);
|
||||||
|
|
||||||
|
if (level == 2 || startLevel == 5 || region2List.Count == 0)
|
||||||
|
goto result;
|
||||||
|
startLevel++;
|
||||||
|
|
||||||
|
var region3List = new List<SysRegion>();
|
||||||
|
foreach (var item in region2List)
|
||||||
|
{
|
||||||
|
region3List.AddRange(GetRegionList(item.Code, startLevel, db));
|
||||||
|
}
|
||||||
|
regionList.AddRange(region3List);
|
||||||
|
|
||||||
|
if (level == 3 || startLevel == 5 || region3List.Count == 0)
|
||||||
|
goto result;
|
||||||
|
startLevel++;
|
||||||
|
|
||||||
|
var region4List = new List<SysRegion>();
|
||||||
|
foreach (var item in region3List)
|
||||||
|
{
|
||||||
|
region4List.AddRange(GetRegionList(item.Code, startLevel, db));
|
||||||
|
}
|
||||||
|
regionList.AddRange(region4List);
|
||||||
|
|
||||||
|
if (level == 4 || startLevel == 5 || region4List.Count == 0)
|
||||||
|
goto result;
|
||||||
|
startLevel++;
|
||||||
|
|
||||||
|
var region5List = new List<SysRegion>();
|
||||||
|
region5List.AddRange(GetVillageList(region4List.Select(u => u.Code).ToList(), db));
|
||||||
|
regionList.AddRange(region5List);
|
||||||
|
|
||||||
|
result:
|
||||||
|
|
||||||
|
// 保存行政区划树
|
||||||
|
var defaultDbConfig = App.GetOptions<DbConnectionOptions>().ConnectionConfigs[0];
|
||||||
|
db = new SqlSugarScope(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = defaultDbConfig.ConnectionString,
|
||||||
|
DbType = defaultDbConfig.DbType,
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
InitKeyType = InitKeyType.Attribute
|
||||||
|
});
|
||||||
|
await db.Deleteable<SysRegion>().ExecuteCommandAsync();
|
||||||
|
await db.Insertable(regionList).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据层级及父级编码获取区域集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pCode"></param>
|
||||||
|
/// <param name="level"></param>
|
||||||
|
/// <param name="db"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static List<SysRegion> GetRegionList(string pCode, int level, SqlSugarScope db)
|
||||||
|
{
|
||||||
|
string table = "";
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
table = "province";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
table = "city";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
table = "area";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
table = "street";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
table = "village";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(table))
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var condition = string.IsNullOrWhiteSpace(pCode) || pCode == "0" ? "" : $" and code like '{pCode}%'";
|
||||||
|
var sql = $"select * from {table} where 1=1 {condition}";
|
||||||
|
var regions = db.Ado.SqlQuery<SysRegion>(sql);
|
||||||
|
if (regions.Count == 0)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
foreach (var item in regions)
|
||||||
|
{
|
||||||
|
item.Pid = string.IsNullOrWhiteSpace(pCode) || item.Code == pCode || level == 1 ? 0 : Convert.ToInt64(pCode);
|
||||||
|
item.Level = level;
|
||||||
|
item.Id = Convert.ToInt64(item.Code);
|
||||||
|
}
|
||||||
|
|
||||||
|
return regions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取社区/村集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pCodes"></param>
|
||||||
|
/// <param name="db"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static List<SysRegion> GetVillageList(List<string> pCodes, SqlSugarScope db)
|
||||||
|
{
|
||||||
|
var condition = pCodes == null || pCodes.Count == 0 ? "" : $" and streetCode in ('{pCodes.Join("','")}')";
|
||||||
|
var sql = $"select * from village where 1=1 {condition}";
|
||||||
|
var regions = db.Ado.SqlQuery<dynamic>(sql);
|
||||||
|
if (regions.Count == 0)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var regionList = new List<SysRegion>();
|
||||||
|
foreach (var item in regions)
|
||||||
|
{
|
||||||
|
var region = new SysRegion
|
||||||
|
{
|
||||||
|
Name = item.name,
|
||||||
|
Code = item.code,
|
||||||
|
Pid = Convert.ToInt64(item.streetCode),
|
||||||
|
Level = 5,
|
||||||
|
Id = Convert.ToInt64(item.code)
|
||||||
|
};
|
||||||
|
regionList.Add(region);
|
||||||
|
}
|
||||||
|
return regionList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ public static class SqlSugarExtension
|
|||||||
{
|
{
|
||||||
var attr = typeof(TEntity).GetCustomAttribute<TenantAttribute>();
|
var attr = typeof(TEntity).GetCustomAttribute<TenantAttribute>();
|
||||||
var tenantId = attr != null ? GetConfigIdFromAttribute(attr) : SqlSugarConst.DefaultTenantId;
|
var tenantId = attr != null ? GetConfigIdFromAttribute(attr) : SqlSugarConst.DefaultTenantId;
|
||||||
return db.AsTenant().GetConnection(tenantId ?? SqlSugarConst.DefaultTenantId);
|
return db.AsTenant().GetConnectionScope(tenantId ?? SqlSugarConst.DefaultTenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static object GetConfigIdFromAttribute(TenantAttribute attr)
|
private static object GetConfigIdFromAttribute(TenantAttribute attr)
|
||||||
@ -361,7 +361,7 @@ public static class SqlSugarExtension
|
|||||||
/// <param name="db"></param>
|
/// <param name="db"></param>
|
||||||
/// <param name="handleBefore"></param>
|
/// <param name="handleBefore"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static (int, int, int)? InitTableSeedData<T>(this SqlSugarScope db, Action<object> handleBefore = null)
|
public static (int, int, int)? InitTableSeedData<T>(this SqlSugarScopeProvider db, Action<object> handleBefore = null)
|
||||||
{
|
{
|
||||||
return InitTableSeedData(db, typeof(T), handleBefore);
|
return InitTableSeedData(db, typeof(T), handleBefore);
|
||||||
}
|
}
|
||||||
@ -369,14 +369,13 @@ public static class SqlSugarExtension
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化表种子数据
|
/// 初始化表种子数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="db"></param>
|
/// <param name="dbProvider"></param>
|
||||||
/// <param name="seedType"></param>
|
/// <param name="seedType"></param>
|
||||||
/// <param name="handleBefore"></param>
|
/// <param name="handleBefore"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static (int, int, int)? InitTableSeedData(this SqlSugarScope db, Type seedType, Action<object> handleBefore = null)
|
public static (int, int, int)? InitTableSeedData(this SqlSugarScopeProvider dbProvider, Type seedType, Action<object> handleBefore = null)
|
||||||
{
|
{
|
||||||
var config = db.CurrentConnectionConfig;
|
var config = dbProvider.CurrentConnectionConfig;
|
||||||
var dbProvider = db.GetConnectionScope(config.ConfigId);
|
|
||||||
|
|
||||||
// 获取表实体类型
|
// 获取表实体类型
|
||||||
var entityType = seedType.GetInterfaces().First().GetGenericArguments().First();
|
var entityType = seedType.GetInterfaces().First().GetGenericArguments().First();
|
||||||
@ -426,7 +425,7 @@ public static class SqlSugarExtension
|
|||||||
// 拆分表的操作需要实体类型,而通过反射很难实现
|
// 拆分表的操作需要实体类型,而通过反射很难实现
|
||||||
// 所以,这里将Init方法写在“种子数据类”内部,再传入 db 反射调用
|
// 所以,这里将Init方法写在“种子数据类”内部,再传入 db 反射调用
|
||||||
var hasInitMethod = seedType.GetMethod("Init");
|
var hasInitMethod = seedType.GetMethod("Init");
|
||||||
var parameters = new object[] { db };
|
var parameters = new object[] { dbProvider };
|
||||||
var result = hasInitMethod?.Invoke(instance, parameters) as (int, int, int)?;
|
var result = hasInitMethod?.Invoke(instance, parameters) as (int, int, int)?;
|
||||||
total = result?.Item1 ?? 0;
|
total = result?.Item1 ?? 0;
|
||||||
insertCount = result?.Item2 ?? 0;
|
insertCount = result?.Item2 ?? 0;
|
||||||
|
|||||||
@ -34,6 +34,7 @@ public static class SqlSugarSetup
|
|||||||
var dbOptions = App.GetConfig<DbConnectionOptions>("DbConnection", true);
|
var dbOptions = App.GetConfig<DbConnectionOptions>("DbConnection", true);
|
||||||
dbOptions.ConnectionConfigs.ForEach(SetDbConfig);
|
dbOptions.ConnectionConfigs.ForEach(SetDbConfig);
|
||||||
|
|
||||||
|
// 初始化SqlSugar
|
||||||
SqlSugarScope sqlSugar = new(dbOptions.ConnectionConfigs.Adapt<List<ConnectionConfig>>(), db =>
|
SqlSugarScope sqlSugar = new(dbOptions.ConnectionConfigs.Adapt<List<ConnectionConfig>>(), db =>
|
||||||
{
|
{
|
||||||
dbOptions.ConnectionConfigs.ForEach(config =>
|
dbOptions.ConnectionConfigs.ForEach(config =>
|
||||||
@ -139,15 +140,15 @@ public static class SqlSugarSetup
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 配置Aop
|
/// 配置Aop
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="db"></param>
|
/// <param name="dbProvider"></param>
|
||||||
/// <param name="enableConsoleSql"></param>
|
/// <param name="enableConsoleSql"></param>
|
||||||
public static void SetDbAop(SqlSugarScopeProvider db, bool enableConsoleSql)
|
public static void SetDbAop(SqlSugarScopeProvider dbProvider, bool enableConsoleSql)
|
||||||
{
|
{
|
||||||
// 设置超时时间
|
// 设置超时时间
|
||||||
db.Ado.CommandTimeOut = 30;
|
dbProvider.Ado.CommandTimeOut = 30;
|
||||||
|
|
||||||
// 打印SQL语句
|
// 打印SQL语句
|
||||||
db.Aop.OnError = ex =>
|
dbProvider.Aop.OnError = ex =>
|
||||||
{
|
{
|
||||||
if (ex.Parametres == null) return;
|
if (ex.Parametres == null) return;
|
||||||
var log = $"【{DateTime.Now}——错误SQL】\r\n{UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres)}\r\n";
|
var log = $"【{DateTime.Now}——错误SQL】\r\n{UtilMethods.GetNativeSql(ex.Sql, (SugarParameter[])ex.Parametres)}\r\n";
|
||||||
@ -156,7 +157,7 @@ public static class SqlSugarSetup
|
|||||||
};
|
};
|
||||||
if (enableConsoleSql)
|
if (enableConsoleSql)
|
||||||
{
|
{
|
||||||
db.Aop.OnLogExecuting = (sql, pars) =>
|
dbProvider.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
{
|
{
|
||||||
//// 若参数值超过100个字符则进行截取
|
//// 若参数值超过100个字符则进行截取
|
||||||
//foreach (var par in pars)
|
//foreach (var par in pars)
|
||||||
@ -179,7 +180,7 @@ public static class SqlSugarSetup
|
|||||||
App.PrintToMiniProfiler("SqlSugar", "Info", log);
|
App.PrintToMiniProfiler("SqlSugar", "Info", log);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
db.Aop.OnLogExecuted = (sql, pars) =>
|
dbProvider.Aop.OnLogExecuted = (sql, pars) =>
|
||||||
{
|
{
|
||||||
//// 若参数值超过100个字符则进行截取
|
//// 若参数值超过100个字符则进行截取
|
||||||
//foreach (var par in pars)
|
//foreach (var par in pars)
|
||||||
@ -190,18 +191,18 @@ public static class SqlSugarSetup
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
// 执行时间超过5秒时
|
// 执行时间超过5秒时
|
||||||
if (db.Ado.SqlExecutionTime.TotalSeconds <= 5) return;
|
if (dbProvider.Ado.SqlExecutionTime.TotalSeconds <= 5) return;
|
||||||
|
|
||||||
var fileName = db.Ado.SqlStackTrace.FirstFileName; // 文件名
|
var fileName = dbProvider.Ado.SqlStackTrace.FirstFileName; // 文件名
|
||||||
var fileLine = db.Ado.SqlStackTrace.FirstLine; // 行号
|
var fileLine = dbProvider.Ado.SqlStackTrace.FirstLine; // 行号
|
||||||
var firstMethodName = db.Ado.SqlStackTrace.FirstMethodName; // 方法名
|
var firstMethodName = dbProvider.Ado.SqlStackTrace.FirstMethodName; // 方法名
|
||||||
var log = $"【{DateTime.Now}——超时SQL】\r\n【所在文件名】:{fileName}\r\n【代码行数】:{fileLine}\r\n【方法名】:{firstMethodName}\r\n" + $"【SQL语句】:{UtilMethods.GetNativeSql(sql, pars)}";
|
var log = $"【{DateTime.Now}——超时SQL】\r\n【所在文件名】:{fileName}\r\n【代码行数】:{fileLine}\r\n【方法名】:{firstMethodName}\r\n" + $"【SQL语句】:{UtilMethods.GetNativeSql(sql, pars)}";
|
||||||
Log.Warning(log);
|
Log.Warning(log);
|
||||||
App.PrintToMiniProfiler("SqlSugar", "Slow", log);
|
App.PrintToMiniProfiler("SqlSugar", "Slow", log);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 数据审计
|
// 数据审计
|
||||||
db.Aop.DataExecuting = (oldValue, entityInfo) =>
|
dbProvider.Aop.DataExecuting = (oldValue, entityInfo) =>
|
||||||
{
|
{
|
||||||
// 新增/插入 操作
|
// 新增/插入 操作
|
||||||
if (entityInfo.OperationType == DataFilterType.InsertByObject)
|
if (entityInfo.OperationType == DataFilterType.InsertByObject)
|
||||||
@ -281,30 +282,30 @@ public static class SqlSugarSetup
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// 配置假删除过滤器
|
// 配置假删除过滤器
|
||||||
db.QueryFilter.AddTableFilter<IDeletedFilter>(u => u.IsDelete == false);
|
dbProvider.QueryFilter.AddTableFilter<IDeletedFilter>(u => u.IsDelete == false);
|
||||||
|
|
||||||
// 配置租户过滤器
|
// 配置租户过滤器
|
||||||
var tenantId = App.User?.FindFirst(ClaimConst.TenantId)?.Value;
|
var tenantId = App.User?.FindFirst(ClaimConst.TenantId)?.Value;
|
||||||
if (!string.IsNullOrWhiteSpace(tenantId))
|
if (!string.IsNullOrWhiteSpace(tenantId))
|
||||||
db.QueryFilter.AddTableFilter<ITenantIdFilter>(u => u.TenantId == long.Parse(tenantId));
|
dbProvider.QueryFilter.AddTableFilter<ITenantIdFilter>(u => u.TenantId == long.Parse(tenantId));
|
||||||
|
|
||||||
// 配置用户机构(数据范围)过滤器
|
// 配置用户机构(数据范围)过滤器
|
||||||
SqlSugarFilter.SetOrgEntityFilter(db);
|
SqlSugarFilter.SetOrgEntityFilter(dbProvider);
|
||||||
|
|
||||||
// 配置自定义过滤器
|
// 配置自定义过滤器
|
||||||
SqlSugarFilter.SetCustomEntityFilter(db);
|
SqlSugarFilter.SetCustomEntityFilter(dbProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开启库表差异化日志
|
/// 开启库表差异化日志
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="db"></param>
|
/// <param name="dbProvider"></param>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
private static void SetDbDiffLog(SqlSugarScopeProvider db, DbConnectionConfig config)
|
private static void SetDbDiffLog(SqlSugarScopeProvider dbProvider, DbConnectionConfig config)
|
||||||
{
|
{
|
||||||
if (!config.DbSettings.EnableDiffLog) return;
|
if (!config.DbSettings.EnableDiffLog) return;
|
||||||
|
|
||||||
db.Aop.OnDiffLogEvent = async u =>
|
dbProvider.Aop.OnDiffLogEvent = async u =>
|
||||||
{
|
{
|
||||||
// 记录差异数据
|
// 记录差异数据
|
||||||
var diffData = new List<dynamic>();
|
var diffData = new List<dynamic>();
|
||||||
@ -359,7 +360,7 @@ public static class SqlSugarSetup
|
|||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
private static void InitDatabase(SqlSugarScope db, DbConnectionConfig config)
|
private static void InitDatabase(SqlSugarScope db, DbConnectionConfig config)
|
||||||
{
|
{
|
||||||
SqlSugarScopeProvider dbProvider = db.GetConnectionScope(config.ConfigId);
|
var dbProvider = db.GetConnectionScope(config.ConfigId);
|
||||||
|
|
||||||
// 若第一次启动系统则强制初始化数据库表和种子数据
|
// 若第一次启动系统则强制初始化数据库表和种子数据
|
||||||
bool isFirstRun = false;
|
bool isFirstRun = false;
|
||||||
@ -374,7 +375,7 @@ public static class SqlSugarSetup
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化表结构之前——系统版本号
|
// 初始化表结构之前——系统版本号
|
||||||
var (startups, oldVerion, currentVersion) = BeforeInitTable(dbProvider, config);
|
var (startups, oldVerion, currentVersion) = BeforeInitTable(dbProvider);
|
||||||
|
|
||||||
// 初始化表结构
|
// 初始化表结构
|
||||||
if (config.TableSettings.EnableInitTable || isFirstRun)
|
if (config.TableSettings.EnableInitTable || isFirstRun)
|
||||||
@ -407,22 +408,21 @@ public static class SqlSugarSetup
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化视图
|
// 初始化视图
|
||||||
if (config.DbSettings.EnableInitView || isFirstRun) InitView(dbProvider, config);
|
if (config.DbSettings.EnableInitView || isFirstRun) InitView(dbProvider);
|
||||||
|
|
||||||
// 初始化种子数据
|
// 初始化种子数据
|
||||||
if (config.SeedSettings.EnableInitSeed || isFirstRun) InitSeedData(db, config);
|
if (config.SeedSettings.EnableInitSeed || isFirstRun) InitSeedData(dbProvider, config.SeedSettings.EnableIncreSeed);
|
||||||
|
|
||||||
// 初始化种子数据之后——系统版本号
|
// 初始化种子数据之后——系统版本号
|
||||||
AfterInitSeed(dbProvider, config, startups, oldVerion, currentVersion);
|
AfterInitSeed(dbProvider, startups, oldVerion, currentVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化表结构之前(版本号)
|
/// 初始化表结构之前(版本号)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbProvider"></param>
|
/// <param name="dbProvider"></param>
|
||||||
/// <param name="config"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static (IOrderedEnumerable<Type> startups, long oldVerion, long currentVersion) BeforeInitTable(SqlSugarScopeProvider dbProvider, DbConnectionConfig config)
|
private static (IOrderedEnumerable<Type> startups, long oldVerion, long currentVersion) BeforeInitTable(SqlSugarScopeProvider dbProvider)
|
||||||
{
|
{
|
||||||
// 扫描所有继承 AppStartup 的类(排序执行顺序)
|
// 扫描所有继承 AppStartup 的类(排序执行顺序)
|
||||||
var startups = App.EffectiveTypes
|
var startups = App.EffectiveTypes
|
||||||
@ -454,7 +454,7 @@ public static class SqlSugarSetup
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Information($"数据库初始化表结构之前有错 {config.DbType} - {config.ConfigId} : {ex.Message}");
|
Log.Information($"数据库初始化表结构之前有错 {dbProvider.CurrentConnectionConfig.DbType} - {dbProvider.CurrentConnectionConfig.ConfigId} : {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (startups, oldVerion, currentVersion);
|
return (startups, oldVerion, currentVersion);
|
||||||
@ -464,11 +464,10 @@ public static class SqlSugarSetup
|
|||||||
/// 初始化种子数据之后(版本号)
|
/// 初始化种子数据之后(版本号)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbProvider"></param>
|
/// <param name="dbProvider"></param>
|
||||||
/// <param name="config"></param>
|
|
||||||
/// <param name="startups"></param>
|
/// <param name="startups"></param>
|
||||||
/// <param name="oldVerion"></param>
|
/// <param name="oldVerion"></param>
|
||||||
/// <param name="currentVersion"></param>
|
/// <param name="currentVersion"></param>
|
||||||
private static void AfterInitSeed(SqlSugarScopeProvider dbProvider, DbConnectionConfig config, IOrderedEnumerable<Type> startups, long oldVerion, long currentVersion)
|
private static void AfterInitSeed(SqlSugarScopeProvider dbProvider, IOrderedEnumerable<Type> startups, long oldVerion, long currentVersion)
|
||||||
{
|
{
|
||||||
if (startups == null || !startups.Any()) return;
|
if (startups == null || !startups.Any()) return;
|
||||||
|
|
||||||
@ -485,7 +484,7 @@ public static class SqlSugarSetup
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
string errr = $"数据库初始化种子数据之后有错 {config.DbType} - {config.ConfigId} : {ex.Message}";
|
string errr = $"数据库初始化种子数据之后有错 {dbProvider.CurrentConnectionConfig.DbType} - {dbProvider.CurrentConnectionConfig.ConfigId} : {ex.Message}";
|
||||||
Log.Information(errr);
|
Log.Information(errr);
|
||||||
Console.WriteLine(errr);
|
Console.WriteLine(errr);
|
||||||
Console.WriteLine(ex.StackTrace);
|
Console.WriteLine(ex.StackTrace);
|
||||||
@ -509,14 +508,14 @@ public static class SqlSugarSetup
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化种子数据
|
/// 初始化种子数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="db"></param>
|
/// <param name="dbProvider"></param>
|
||||||
/// <param name="config"></param>
|
/// <param name="enableIncreSeed"></param>
|
||||||
private static void InitSeedData(SqlSugarScope db, DbConnectionConfig config)
|
private static void InitSeedData(SqlSugarScopeProvider dbProvider, bool enableIncreSeed)
|
||||||
{
|
{
|
||||||
Log.Information($"初始化种子数据 {config.DbType} - {config.ConfigId}");
|
Log.Information($"初始化种子数据 {dbProvider.CurrentConnectionConfig.DbType} - {dbProvider.CurrentConnectionConfig.ConfigId}");
|
||||||
var seedDataTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>))))
|
var seedDataTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>))))
|
||||||
.Where(u => !u.IsDefined(typeof(TenantSeedAttribute), false))
|
.Where(u => !u.IsDefined(typeof(TenantSeedAttribute), false))
|
||||||
.WhereIF(config.SeedSettings.EnableIncreSeed, u => u.IsDefined(typeof(IncreSeedAttribute), false))
|
.WhereIF(enableIncreSeed, u => u.IsDefined(typeof(IncreSeedAttribute), false))
|
||||||
.OrderBy(u => u.GetCustomAttributes(typeof(SeedDataAttribute), false).Length > 0 ? ((SeedDataAttribute)u.GetCustomAttributes(typeof(SeedDataAttribute), false)[0]).Order : 0).ToList();
|
.OrderBy(u => u.GetCustomAttributes(typeof(SeedDataAttribute), false).Length > 0 ? ((SeedDataAttribute)u.GetCustomAttributes(typeof(SeedDataAttribute), false)[0]).Order : 0).ToList();
|
||||||
|
|
||||||
// 由于种子数据在应用层存在重写,必须保证应用层种子最后执行(多线程顺序会乱)
|
// 由于种子数据在应用层存在重写,必须保证应用层种子最后执行(多线程顺序会乱)
|
||||||
@ -526,13 +525,13 @@ public static class SqlSugarSetup
|
|||||||
var stopWatch = Stopwatch.StartNew(); // 开始计时
|
var stopWatch = Stopwatch.StartNew(); // 开始计时
|
||||||
|
|
||||||
// 初始化种子数据
|
// 初始化种子数据
|
||||||
var tuple = db.InitTableSeedData(seedType);
|
var tuple = dbProvider.InitTableSeedData(seedType);
|
||||||
if (tuple == null) return;
|
if (tuple == null) return;
|
||||||
|
|
||||||
stopWatch.Stop(); // 停止计时
|
stopWatch.Stop(); // 停止计时
|
||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.WriteLine($"初始化种子数据 {seedType.FullName,-58} ({config.ConfigId} - {Interlocked.Increment(ref taskIndex):D003}/{size:D003},数据量:{tuple.Value.Item1:D003},新增 {tuple.Value.Item2:D003} 条记录,更新 {tuple.Value.Item3:D003} 条记录,耗时:{stopWatch.ElapsedMilliseconds:N0} ms)");
|
Console.WriteLine($"初始化种子数据 {seedType.FullName,-58} ({dbProvider.CurrentConnectionConfig.ConfigId} - {Interlocked.Increment(ref taskIndex):D003}/{size:D003},数据量:{tuple.Value.Item1:D003},新增 {tuple.Value.Item2:D003} 条记录,更新 {tuple.Value.Item3:D003} 条记录,耗时:{stopWatch.ElapsedMilliseconds:N0} ms)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,10 +539,9 @@ public static class SqlSugarSetup
|
|||||||
/// 初始化视图
|
/// 初始化视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbProvider"></param>
|
/// <param name="dbProvider"></param>
|
||||||
/// <param name="config"></param>
|
private static void InitView(SqlSugarScopeProvider dbProvider)
|
||||||
private static void InitView(SqlSugarScopeProvider dbProvider, DbConnectionConfig config)
|
|
||||||
{
|
{
|
||||||
Log.Information($"初始化视图 {config.DbType} - {config.ConfigId}");
|
Log.Information($"初始化视图 {dbProvider.CurrentConnectionConfig.DbType} - {dbProvider.CurrentConnectionConfig.ConfigId}");
|
||||||
var viewTypeList = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarView)))).ToList();
|
var viewTypeList = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarView)))).ToList();
|
||||||
|
|
||||||
int taskIndex = 0, size = viewTypeList.Count;
|
int taskIndex = 0, size = viewTypeList.Count;
|
||||||
@ -569,7 +567,7 @@ public static class SqlSugarSetup
|
|||||||
// 停止计时
|
// 停止计时
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.WriteLine($"初始化视图 {viewType.FullName,-58} ({config.ConfigId} - {Interlocked.Increment(ref taskIndex):D003}/{size:D003},耗时:{stopWatch.ElapsedMilliseconds:N0} ms)");
|
Console.WriteLine($"初始化视图 {viewType.FullName,-58} ({dbProvider.CurrentConnectionConfig.ConfigId} - {Interlocked.Increment(ref taskIndex):D003}/{size:D003},耗时:{stopWatch.ElapsedMilliseconds:N0} ms)");
|
||||||
}));
|
}));
|
||||||
Task.WaitAll(taskList.ToArray());
|
Task.WaitAll(taskList.ToArray());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -325,61 +325,6 @@ export const SysCommonApiAxiosParamCreator = function (configuration?: Configura
|
|||||||
options: localVarRequestOptions,
|
options: localVarRequestOptions,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @summary 从 china.sqlite 中获取区划数据
|
|
||||||
* @param {string} code 区划编码
|
|
||||||
* @param {number} level 级数(从当前code所在级别往下级数)
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
apiSysCommonRegionTreeCodeLevelGet: async (code: string, level: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
||||||
// verify required parameter 'code' is not null or undefined
|
|
||||||
if (code === null || code === undefined) {
|
|
||||||
throw new RequiredError('code','Required parameter code was null or undefined when calling apiSysCommonRegionTreeCodeLevelGet.');
|
|
||||||
}
|
|
||||||
// verify required parameter 'level' is not null or undefined
|
|
||||||
if (level === null || level === undefined) {
|
|
||||||
throw new RequiredError('level','Required parameter level was null or undefined when calling apiSysCommonRegionTreeCodeLevelGet.');
|
|
||||||
}
|
|
||||||
const localVarPath = `/api/sysCommon/regionTree/{code}/{level}`
|
|
||||||
.replace(`{${"code"}}`, encodeURIComponent(String(code)))
|
|
||||||
.replace(`{${"level"}}`, encodeURIComponent(String(level)));
|
|
||||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
||||||
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
|
||||||
let baseOptions;
|
|
||||||
if (configuration) {
|
|
||||||
baseOptions = configuration.baseOptions;
|
|
||||||
}
|
|
||||||
const localVarRequestOptions :AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
|
|
||||||
const localVarHeaderParameter = {} as any;
|
|
||||||
const localVarQueryParameter = {} as any;
|
|
||||||
|
|
||||||
// authentication Bearer required
|
|
||||||
// http bearer authentication required
|
|
||||||
if (configuration && configuration.accessToken) {
|
|
||||||
const accessToken = typeof configuration.accessToken === 'function'
|
|
||||||
? await configuration.accessToken()
|
|
||||||
: await configuration.accessToken;
|
|
||||||
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = new URLSearchParams(localVarUrlObj.search);
|
|
||||||
for (const key in localVarQueryParameter) {
|
|
||||||
query.set(key, localVarQueryParameter[key]);
|
|
||||||
}
|
|
||||||
for (const key in options.params) {
|
|
||||||
query.set(key, options.params[key]);
|
|
||||||
}
|
|
||||||
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
|
||||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
||||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
|
||||||
|
|
||||||
return {
|
|
||||||
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
|
||||||
options: localVarRequestOptions,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 国密SM2解密字符串 🔖
|
* @summary 国密SM2解密字符串 🔖
|
||||||
@ -663,21 +608,6 @@ export const SysCommonApiFp = function(configuration?: Configuration) {
|
|||||||
return axios.request(axiosRequestArgs);
|
return axios.request(axiosRequestArgs);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @summary 从 china.sqlite 中获取区划数据
|
|
||||||
* @param {string} code 区划编码
|
|
||||||
* @param {number} level 级数(从当前code所在级别往下级数)
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
async apiSysCommonRegionTreeCodeLevelGet(code: string, level: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
|
|
||||||
const localVarAxiosArgs = await SysCommonApiAxiosParamCreator(configuration).apiSysCommonRegionTreeCodeLevelGet(code, level, options);
|
|
||||||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
||||||
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
|
||||||
return axios.request(axiosRequestArgs);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 国密SM2解密字符串 🔖
|
* @summary 国密SM2解密字符串 🔖
|
||||||
@ -803,17 +733,6 @@ export const SysCommonApiFactory = function (configuration?: Configuration, base
|
|||||||
async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultString>> {
|
async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultString>> {
|
||||||
return SysCommonApiFp(configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(axios, basePath));
|
return SysCommonApiFp(configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @summary 从 china.sqlite 中获取区划数据
|
|
||||||
* @param {string} code 区划编码
|
|
||||||
* @param {number} level 级数(从当前code所在级别往下级数)
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
*/
|
|
||||||
async apiSysCommonRegionTreeCodeLevelGet(code: string, level: number, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
|
|
||||||
return SysCommonApiFp(configuration).apiSysCommonRegionTreeCodeLevelGet(code, level, options).then((request) => request(axios, basePath));
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 国密SM2解密字符串 🔖
|
* @summary 国密SM2解密字符串 🔖
|
||||||
@ -930,18 +849,6 @@ export class SysCommonApi extends BaseAPI {
|
|||||||
public async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultString>> {
|
public async apiSysCommonMachineSerialKeyGet(options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultString>> {
|
||||||
return SysCommonApiFp(this.configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(this.axios, this.basePath));
|
return SysCommonApiFp(this.configuration).apiSysCommonMachineSerialKeyGet(options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @summary 从 china.sqlite 中获取区划数据
|
|
||||||
* @param {string} code 区划编码
|
|
||||||
* @param {number} level 级数(从当前code所在级别往下级数)
|
|
||||||
* @param {*} [options] Override http request option.
|
|
||||||
* @throws {RequiredError}
|
|
||||||
* @memberof SysCommonApi
|
|
||||||
*/
|
|
||||||
public async apiSysCommonRegionTreeCodeLevelGet(code: string, level: number, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
|
|
||||||
return SysCommonApiFp(this.configuration).apiSysCommonRegionTreeCodeLevelGet(code, level, options).then((request) => request(this.axios, this.basePath));
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 国密SM2解密字符串 🔖
|
* @summary 国密SM2解密字符串 🔖
|
||||||
|
|||||||
@ -433,6 +433,61 @@ export const SysRegionApiAxiosParamCreator = function (configuration?: Configura
|
|||||||
options: localVarRequestOptions,
|
options: localVarRequestOptions,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 从 china.sqlite 中获取区划数据
|
||||||
|
* @param {string} code 区划编码
|
||||||
|
* @param {number} level 级数(从当前code所在级别往下级数)
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
apiSysRegionRegionTreeCodeLevelGet: async (code: string, level: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
// verify required parameter 'code' is not null or undefined
|
||||||
|
if (code === null || code === undefined) {
|
||||||
|
throw new RequiredError('code','Required parameter code was null or undefined when calling apiSysRegionRegionTreeCodeLevelGet.');
|
||||||
|
}
|
||||||
|
// verify required parameter 'level' is not null or undefined
|
||||||
|
if (level === null || level === undefined) {
|
||||||
|
throw new RequiredError('level','Required parameter level was null or undefined when calling apiSysRegionRegionTreeCodeLevelGet.');
|
||||||
|
}
|
||||||
|
const localVarPath = `/api/sysRegion/regionTree/{code}/{level}`
|
||||||
|
.replace(`{${"code"}}`, encodeURIComponent(String(code)))
|
||||||
|
.replace(`{${"level"}}`, encodeURIComponent(String(level)));
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions :AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
// authentication Bearer required
|
||||||
|
// http bearer authentication required
|
||||||
|
if (configuration && configuration.accessToken) {
|
||||||
|
const accessToken = typeof configuration.accessToken === 'function'
|
||||||
|
? await configuration.accessToken()
|
||||||
|
: await configuration.accessToken;
|
||||||
|
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = new URLSearchParams(localVarUrlObj.search);
|
||||||
|
for (const key in localVarQueryParameter) {
|
||||||
|
query.set(key, localVarQueryParameter[key]);
|
||||||
|
}
|
||||||
|
for (const key in options.params) {
|
||||||
|
query.set(key, options.params[key]);
|
||||||
|
}
|
||||||
|
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 同步行政区划(高德) 🔖
|
* @summary 同步行政区划(高德) 🔖
|
||||||
@ -795,6 +850,21 @@ export const SysRegionApiFp = function(configuration?: Configuration) {
|
|||||||
return axios.request(axiosRequestArgs);
|
return axios.request(axiosRequestArgs);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 从 china.sqlite 中获取区划数据
|
||||||
|
* @param {string} code 区划编码
|
||||||
|
* @param {number} level 级数(从当前code所在级别往下级数)
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysRegionRegionTreeCodeLevelGet(code: string, level: number, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
|
||||||
|
const localVarAxiosArgs = await SysRegionApiAxiosParamCreator(configuration).apiSysRegionRegionTreeCodeLevelGet(code, level, options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 同步行政区划(高德) 🔖
|
* @summary 同步行政区划(高德) 🔖
|
||||||
@ -955,6 +1025,17 @@ export const SysRegionApiFactory = function (configuration?: Configuration, base
|
|||||||
async apiSysRegionQueryPost(body?: QueryRegionInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultListSysRegion>> {
|
async apiSysRegionQueryPost(body?: QueryRegionInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultListSysRegion>> {
|
||||||
return SysRegionApiFp(configuration).apiSysRegionQueryPost(body, options).then((request) => request(axios, basePath));
|
return SysRegionApiFp(configuration).apiSysRegionQueryPost(body, options).then((request) => request(axios, basePath));
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 从 china.sqlite 中获取区划数据
|
||||||
|
* @param {string} code 区划编码
|
||||||
|
* @param {number} level 级数(从当前code所在级别往下级数)
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysRegionRegionTreeCodeLevelGet(code: string, level: number, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
|
||||||
|
return SysRegionApiFp(configuration).apiSysRegionRegionTreeCodeLevelGet(code, level, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 同步行政区划(高德) 🔖
|
* @summary 同步行政区划(高德) 🔖
|
||||||
@ -1104,6 +1185,18 @@ export class SysRegionApi extends BaseAPI {
|
|||||||
public async apiSysRegionQueryPost(body?: QueryRegionInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultListSysRegion>> {
|
public async apiSysRegionQueryPost(body?: QueryRegionInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultListSysRegion>> {
|
||||||
return SysRegionApiFp(this.configuration).apiSysRegionQueryPost(body, options).then((request) => request(this.axios, this.basePath));
|
return SysRegionApiFp(this.configuration).apiSysRegionQueryPost(body, options).then((request) => request(this.axios, this.basePath));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 从 china.sqlite 中获取区划数据
|
||||||
|
* @param {string} code 区划编码
|
||||||
|
* @param {number} level 级数(从当前code所在级别往下级数)
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof SysRegionApi
|
||||||
|
*/
|
||||||
|
public async apiSysRegionRegionTreeCodeLevelGet(code: string, level: number, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
|
||||||
|
return SysRegionApiFp(this.configuration).apiSysRegionRegionTreeCodeLevelGet(code, level, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @summary 同步行政区划(高德) 🔖
|
* @summary 同步行政区划(高德) 🔖
|
||||||
|
|||||||
@ -50,6 +50,7 @@ export enum DbType {
|
|||||||
NUMBER_29 = 29,
|
NUMBER_29 = 29,
|
||||||
NUMBER_30 = 30,
|
NUMBER_30 = 30,
|
||||||
NUMBER_31 = 31,
|
NUMBER_31 = 31,
|
||||||
|
NUMBER_32 = 32,
|
||||||
NUMBER_900 = 900
|
NUMBER_900 = 900
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,7 @@ export interface Filter {
|
|||||||
*
|
*
|
||||||
* @type {Array<Filter>}
|
* @type {Array<Filter>}
|
||||||
* @memberof Filter
|
* @memberof Filter
|
||||||
|
* @example []
|
||||||
*/
|
*/
|
||||||
filters?: Array<Filter> | null;
|
filters?: Array<Filter> | null;
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,8 @@ export interface GenerateQRImageUnLimitInput {
|
|||||||
width?: number;
|
width?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 二维码携带的参数 eg:a=1(最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:<!-- !#$&'()*+,/:;=?@-._~ -->)
|
||||||
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof GenerateQRImageUnLimitInput
|
* @memberof GenerateQRImageUnLimitInput
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -25,6 +25,7 @@ export interface Search {
|
|||||||
*
|
*
|
||||||
* @type {Array<string>}
|
* @type {Array<string>}
|
||||||
* @memberof Search
|
* @memberof Search
|
||||||
|
* @example []
|
||||||
*/
|
*/
|
||||||
fields?: Array<string> | null;
|
fields?: Array<string> | null;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user