😎1、统一系统标题 2、调整配置为常量 3、优化logo上传 4、优化行政区域入库性能 5、增加权限标记特性 6、调整在线用户

This commit is contained in:
zuohuaijun 2024-07-15 11:38:17 +08:00
parent aad1352f15
commit 91c61d9da5
64 changed files with 1923 additions and 264 deletions

View File

@ -37,7 +37,7 @@
<PackageReference Include="SqlSugarCore" Version="5.1.4.162" />
<PackageReference Include="SSH.NET" Version="2024.1.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.3" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1046" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1047" />
<PackageReference Include="UAParser" Version="3.1.47" />
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
</ItemGroup>

View File

@ -0,0 +1,16 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
/// <summary>
/// 所属机构数据权限
/// </summary>
[SuppressSniffer]
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
public class OwnerOrgAttribute : Attribute
{
}

View File

@ -0,0 +1,16 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
/// <summary>
/// 所属用户数据权限
/// </summary>
[SuppressSniffer]
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
public class OwnerUserAttribute : Attribute
{
}

View File

@ -87,6 +87,11 @@ public class CommonConst
/// </summary>
public const string SysValidationLog = "sys_validation_log";
/// <summary>
/// 行政区域同步层级 1-省级,2-市级,3-区县级,4-街道级,5-村级
/// </summary>
public const string SysRegionSyncLevel = "sys_region_sync_level";
/// <summary>
/// 日志保留天数
/// </summary>

View File

@ -0,0 +1,58 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
/// <summary>
/// 配置常量
/// </summary>
public class ConfigConst
{
/// <summary>
/// WebConfig 分组
/// </summary>
public const string SysWebConfigGroup = "WebConfig";
/// <summary>
/// 系统图标
/// </summary>
public const string SysWebLogo = "sys_web_logo";
/// <summary>
/// 系统主标题
/// </summary>
public const string SysWebTitle = "sys_web_title";
/// <summary>
/// 系统副标题
/// </summary>
public const string SysWebViceTitle = "sys_web_viceTitle";
/// <summary>
/// 系统描述
/// </summary>
public const string SysWebViceDesc = "sys_web_viceDesc";
/// <summary>
/// 水印内容
/// </summary>
public const string SysWebWatermark = "sys_web_watermark";
/// <summary>
/// 版权说明
/// </summary>
public const string SysWebCopyright = "sys_web_copyright";
/// <summary>
/// ICP备案号
/// </summary>
public const string SysWebIcp = "sys_web_icp";
/// <summary>
/// ICP地址
/// </summary>
public const string SysWebIcpUrl = "sys_web_icpUrl";
}

View File

@ -40,6 +40,7 @@ public abstract class EntityBase : EntityBaseId, IDeletedFilter
/// 创建者Id
/// </summary>
[SugarColumn(ColumnDescription = "创建者Id", IsOnlyIgnoreUpdate = true)]
[OwnerUser]
public virtual long? CreateUserId { get; set; }
///// <summary>
@ -92,6 +93,7 @@ public abstract class EntityBaseData : EntityBase, IOrgIdFilter
/// 创建者部门Id
/// </summary>
[SugarColumn(ColumnDescription = "创建者部门Id", IsOnlyIgnoreUpdate = true)]
[OwnerOrg]
public virtual long? CreateOrgId { get; set; }
/// <summary>

View File

@ -679,6 +679,24 @@ public enum ErrorCodeEnum
[ErrorCodeItemMetadata("已有相同编码或名称")]
R2002,
/// <summary>
/// 行政区代码只能为6、9或12位
/// </summary>
[ErrorCodeItemMetadata("行政区代码只能为6、9或12位")]
R2003,
/// <summary>
/// 父节点不能为自己的子节点
/// </summary>
[ErrorCodeItemMetadata("父节点不能为自己的子节点")]
R2004,
/// <summary>
/// 同步国家统计局数据异常,请稍后重试
/// </summary>
[ErrorCodeItemMetadata("同步国家统计局数据异常,请稍后重试")]
R2005,
/// <summary>
/// 默认租户状态禁止修改
/// </summary>

View File

@ -0,0 +1,32 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
/// <summary>
/// 过滤条件
/// </summary>
[Description("过滤条件")]
public enum FilterLogicEnum
{
/// <summary>
/// 并且
/// </summary>
[Description("并且")]
And,
/// <summary>
/// 或者
/// </summary>
[Description("或者")]
Or,
/// <summary>
/// 异或
/// </summary>
[Description("异或")]
Xor
}

View File

@ -0,0 +1,68 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
/// <summary>
/// 过滤逻辑运算符
/// </summary>
[Description("过滤逻辑运算符")]
public enum FilterOperatorEnum
{
/// <summary>
/// 等于(=)
/// </summary>
[Description("等于")]
EQ,
/// <summary>
/// 不等于(!=)
/// </summary>
[Description("不等于")]
NEQ,
/// <summary>
/// 小于(<)
/// </summary>
[Description("小于")]
LT,
/// <summary>
/// 小于等于(<=)
/// </summary>
[Description("小于等于")]
LTE,
/// <summary>
/// 大于(>)
/// </summary>
[Description("大于")]
GT,
/// <summary>
/// 大于等于(>=)
/// </summary>
[Description("大于等于")]
GTE,
/// <summary>
/// 开始包含
/// </summary>
[Description("开始包含")]
StartsWith,
/// <summary>
/// 末尾包含
/// </summary>
[Description("末尾包含")]
EndsWith,
/// <summary>
/// 包含
/// </summary>
[Description("包含")]
Contains
}

View File

@ -42,7 +42,8 @@ public class AppEventSubscriber : IEventSubscriber, ISingleton, IDisposable
//var mailTemp = File.ReadAllText(mailTempPath);
//var mail = await _serviceScope.ServiceProvider.GetRequiredService<IViewEngine>().RunCompileFromCachedAsync(mailTemp, );
var title = "Admin.NET 系统异常";
var webTitle = await _serviceScope.ServiceProvider.GetRequiredService<SysConfigService>().GetConfigValue<string>(ConfigConst.SysWebTitle);
var title = $"{webTitle} 系统异常";
await _serviceScope.ServiceProvider.GetRequiredService<SysEmailService>().SendEmail(JSON.Serialize(context.Source.Payload), title);
}

View File

@ -0,0 +1,94 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using Microsoft.AspNetCore.Authentication;
namespace Admin.NET.Core;
public static class HttpContextExtension
{
public static async Task<AuthenticationScheme[]> GetExternalProvidersAsync(this HttpContext context)
{
ArgumentNullException.ThrowIfNull(context);
var schemes = context.RequestServices.GetRequiredService<IAuthenticationSchemeProvider>();
return (from scheme in await schemes.GetAllSchemesAsync()
where !string.IsNullOrEmpty(scheme.DisplayName)
select scheme).ToArray();
}
public static async Task<bool> IsProviderSupportedAsync(this HttpContext context, string provider)
{
ArgumentNullException.ThrowIfNull(context);
return (from scheme in await context.GetExternalProvidersAsync()
where string.Equals(scheme.Name, provider, StringComparison.OrdinalIgnoreCase)
select scheme).Any();
}
/// <summary>
/// 获取设备信息
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public static string GetClientDeviceInfo(this HttpContext context)
{
ArgumentNullException.ThrowIfNull(context);
return CommonUtil.GetClientDeviceInfo(context.Request.Headers.UserAgent);
}
/// <summary>
/// 获取浏览器信息
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public static string GetClientBrowser(this HttpContext context)
{
ArgumentNullException.ThrowIfNull(context);
string userAgent = context.Request.Headers.UserAgent;
try
{
if (userAgent != null)
{
var client = Parser.GetDefault().Parse(userAgent);
if (client.Device.IsSpider)
return "爬虫";
return $"{client.UA.Family} {client.UA.Major}.{client.UA.Minor} / {client.Device.Family}";
}
}
catch
{ }
return "未知";
}
/// <summary>
/// 获取操作系统信息
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public static string GetClientOs(this HttpContext context)
{
ArgumentNullException.ThrowIfNull(context);
string userAgent = context.Request.Headers.UserAgent;
try
{
if (userAgent != null)
{
var client = Parser.GetDefault().Parse(userAgent);
if (client.Device.IsSpider)
return "爬虫";
return $"{client.OS.Family} {client.OS.Major} {client.OS.Minor}";
}
}
catch
{ }
return "未知";
}
}

View File

@ -0,0 +1,294 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using System.Text.Json;
namespace Admin.NET.Core;
/// <summary>
/// Sqlsugar 动态查询扩展方法
/// </summary>
public static class SqlSugarExtension
{
public static ISugarQueryable<T> SearchBy<T>(this ISugarQueryable<T> queryable, BaseFilter filter)
{
return queryable.SearchByKeyword(filter.Keyword)
.AdvancedSearch(filter.Search)
.AdvancedFilter(filter.Filter);
}
public static ISugarQueryable<T> SearchByKeyword<T>(this ISugarQueryable<T> queryable, string keyword)
{
return queryable.AdvancedSearch(new Search { Keyword = keyword });
}
public static ISugarQueryable<T> AdvancedSearch<T>(this ISugarQueryable<T> queryable, Search search)
{
if (!string.IsNullOrWhiteSpace(search?.Keyword))
{
var paramExpr = Expression.Parameter(typeof(T));
Expression right = Expression.Constant(false);
if (search.Fields?.Any() is true)
{
foreach (string field in search.Fields)
{
MemberExpression propertyExpr = GetPropertyExpression(field, paramExpr);
var left = AddSearchPropertyByKeyword<T>(propertyExpr, search.Keyword);
right = Expression.Or(left, right);
}
}
else
{
var properties = typeof(T).GetProperties()
.Where(prop => Nullable.GetUnderlyingType(prop.PropertyType) == null
&& !prop.PropertyType.IsEnum
&& Type.GetTypeCode(prop.PropertyType) != TypeCode.Object);
foreach (var property in properties)
{
var propertyExpr = Expression.Property(paramExpr, property);
var left = AddSearchPropertyByKeyword<T>(propertyExpr, search.Keyword);
right = Expression.Or(left, right);
}
}
var lambda = Expression.Lambda<Func<T, bool>>(right, paramExpr);
return queryable.Where(lambda);
}
return queryable;
}
public static ISugarQueryable<T> AdvancedFilter<T>(this ISugarQueryable<T> queryable, Filter filter)
{
if (filter is not null)
{
var parameter = Expression.Parameter(typeof(T));
Expression binaryExpresioFilter;
if (filter.Logic.HasValue)
{
if (filter.Filters is null) throw new ArgumentException("The Filters attribute is required when declaring a logic");
binaryExpresioFilter = CreateFilterExpression(filter.Logic.Value, filter.Filters, parameter);
}
else
{
var filterValid = GetValidFilter(filter);
binaryExpresioFilter = CreateFilterExpression(filterValid.Field!, filterValid.Operator.Value, filterValid.Value, parameter);
}
var lambda = Expression.Lambda<Func<T, bool>>(binaryExpresioFilter, parameter);
return queryable.Where(lambda);
}
return queryable;
}
private static Expression CombineFilter(
FilterLogicEnum filterLogic,
Expression bExpresionBase,
Expression bExpresion)
{
return filterLogic switch
{
FilterLogicEnum.And => Expression.And(bExpresionBase, bExpresion),
FilterLogicEnum.Or => Expression.Or(bExpresionBase, bExpresion),
FilterLogicEnum.Xor => Expression.ExclusiveOr(bExpresionBase, bExpresion),
_ => throw new ArgumentException("FilterLogic is not valid.", nameof(filterLogic)),
};
}
private static Filter GetValidFilter(Filter filter)
{
if (string.IsNullOrEmpty(filter.Field)) throw new ArgumentException("The field attribute is required when declaring a filter");
if (filter.Operator.IsNullOrEmpty()) throw new ArgumentException("The Operator attribute is required when declaring a filter");
return filter;
}
private static Expression CreateFilterExpression(
FilterLogicEnum filterLogic,
IEnumerable<Filter> filters,
ParameterExpression parameter)
{
Expression filterExpression = default!;
foreach (var filter in filters)
{
Expression bExpresionFilter;
if (filter.Logic.HasValue)
{
if (filter.Filters is null) throw new ArgumentException("The Filters attribute is required when declaring a logic");
bExpresionFilter = CreateFilterExpression(filter.Logic.Value, filter.Filters, parameter);
}
else
{
var filterValid = GetValidFilter(filter);
bExpresionFilter = CreateFilterExpression(filterValid.Field!, filterValid.Operator.Value, filterValid.Value, parameter);
}
filterExpression = filterExpression is null ? bExpresionFilter : CombineFilter(filterLogic, filterExpression, bExpresionFilter);
}
return filterExpression;
}
private static Expression CreateFilterExpression(
string field,
FilterOperatorEnum filterOperator,
object? value,
ParameterExpression parameter)
{
var propertyExpresion = GetPropertyExpression(field, parameter);
var valueExpresion = GeValuetExpression(field, value, propertyExpresion.Type);
return CreateFilterExpression(propertyExpresion, valueExpresion, filterOperator);
}
private static Expression CreateFilterExpression(
MemberExpression memberExpression,
ConstantExpression constantExpression,
FilterOperatorEnum filterOperator)
{
return filterOperator switch
{
FilterOperatorEnum.EQ => Expression.Equal(memberExpression, constantExpression),
FilterOperatorEnum.NEQ => Expression.NotEqual(memberExpression, constantExpression),
FilterOperatorEnum.LT => Expression.LessThan(memberExpression, constantExpression),
FilterOperatorEnum.LTE => Expression.LessThanOrEqual(memberExpression, constantExpression),
FilterOperatorEnum.GT => Expression.GreaterThan(memberExpression, constantExpression),
FilterOperatorEnum.GTE => Expression.GreaterThanOrEqual(memberExpression, constantExpression),
FilterOperatorEnum.Contains => Expression.Call(memberExpression, nameof(FilterOperatorEnum.Contains), null, constantExpression),
FilterOperatorEnum.StartsWith => Expression.Call(memberExpression, nameof(FilterOperatorEnum.StartsWith), null, constantExpression),
FilterOperatorEnum.EndsWith => Expression.Call(memberExpression, nameof(FilterOperatorEnum.EndsWith), null, constantExpression),
_ => throw new ArgumentException("Filter Operator is not valid."),
};
}
private static string GetStringFromJsonElement(object value)
{
if (value is JsonElement) return ((JsonElement)value).GetString()!;
if (value is string) return (string)value;
return value?.ToString();
}
private static ConstantExpression GeValuetExpression(
string field,
object? value,
Type propertyType)
{
if (value == null) return Expression.Constant(null, propertyType);
if (propertyType.IsEnum)
{
string? stringEnum = GetStringFromJsonElement(value);
if (!Enum.TryParse(propertyType, stringEnum, true, out object? valueparsed)) throw new ArgumentException(string.Format("Value {0} is not valid for {1}", value, field));
return Expression.Constant(valueparsed, propertyType);
}
if (propertyType == typeof(long))
{
string? stringLong = GetStringFromJsonElement(value);
if (!long.TryParse(stringLong, out long valueparsed)) throw new ArgumentException(string.Format("Value {0} is not valid for {1}", value, field));
return Expression.Constant(valueparsed, propertyType);
}
if (propertyType == typeof(Guid))
{
string? stringGuid = GetStringFromJsonElement(value);
if (!Guid.TryParse(stringGuid, out Guid valueparsed)) throw new ArgumentException(string.Format("Value {0} is not valid for {1}", value, field));
return Expression.Constant(valueparsed, propertyType);
}
if (propertyType == typeof(string))
{
string? text = GetStringFromJsonElement(value);
return Expression.Constant(text, propertyType);
}
if (propertyType == typeof(DateTime) || propertyType == typeof(DateTime?))
{
string? text = GetStringFromJsonElement(value);
return Expression.Constant(ChangeType(text, propertyType), propertyType);
}
return Expression.Constant(ChangeType(((JsonElement)value).GetRawText(), propertyType), propertyType);
}
private static dynamic? ChangeType(object value, Type conversion)
{
var t = conversion;
if (t.IsGenericType && t.GetGenericTypeDefinition().Equals(typeof(Nullable<>)))
{
if (value == null)
{
return null;
}
t = Nullable.GetUnderlyingType(t);
}
return Convert.ChangeType(value, t!);
}
private static MemberExpression GetPropertyExpression(
string propertyName,
ParameterExpression parameter)
{
Expression propertyExpression = parameter;
foreach (string member in propertyName.Split('.'))
{
propertyExpression = Expression.PropertyOrField(propertyExpression, member);
}
return (MemberExpression)propertyExpression;
}
private static Expression AddSearchPropertyByKeyword<T>(
Expression propertyExpr,
string keyword,
FilterOperatorEnum operatorSearch = FilterOperatorEnum.Contains)
{
if (propertyExpr is not MemberExpression memberExpr || memberExpr.Member is not PropertyInfo property)
{
throw new ArgumentException("propertyExpr must be a property expression.", nameof(propertyExpr));
}
ConstantExpression constant = Expression.Constant(keyword);
MethodInfo method = operatorSearch switch
{
FilterOperatorEnum.Contains => typeof(string).GetMethod(nameof(FilterOperatorEnum.Contains), new Type[] { typeof(string) }),
FilterOperatorEnum.StartsWith => typeof(string).GetMethod(nameof(FilterOperatorEnum.StartsWith), new Type[] { typeof(string) }),
FilterOperatorEnum.EndsWith => typeof(string).GetMethod(nameof(FilterOperatorEnum.EndsWith), new Type[] { typeof(string) }),
_ => throw new ArgumentException("Filter Operator is not valid."),
};
Expression selectorExpr =
property.PropertyType == typeof(string)
? propertyExpr
: Expression.Condition(
Expression.Equal(Expression.Convert(propertyExpr, typeof(object)), Expression.Constant(null, typeof(object))),
Expression.Constant(null, typeof(string)),
Expression.Call(propertyExpr, "ToString", null, null));
return Expression.Call(selectorExpr, method, constant);
}
}

View File

@ -0,0 +1,55 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
public static class SqlSugarFilterExtension
{
/// <summary>
/// 根据指定Attribute获取属性
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="type"></param>
/// <returns></returns>
private static List<string> GetPropertyNames<T>(this Type type)
where T : Attribute
{
var allProperties = type.GetProperties();
var properties = allProperties.Where(x => x.CustomAttributes.Any(a => a.AttributeType == typeof(T)));
return properties.Select(x => x.Name).ToList();
}
/// <summary>
/// 获取过滤表达式
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="type"></param>
/// <param name="owners"></param>
/// <returns></returns>
public static LambdaExpression GetConditionExpression<T>(this Type type, List<long> owners)
where T : Attribute
{
var fieldNames = type.GetPropertyNames<T>();
ParameterExpression parameter = Expression.Parameter(type, "c");
Expression right = Expression.Constant(false);
fieldNames.ForEach(filedName =>
{
owners.ForEach(owner =>
{
Expression left = Expression.Equal(
Expression.Property(parameter, type.GetProperty(filedName)),
Expression.Constant(owner)
);
right = Expression.Or(left, right);
});
});
var finalExpression = Expression.Lambda(right, new ParameterExpression[] { parameter });
return finalExpression;
}
}

View File

@ -17,6 +17,7 @@ public class OnlineUserHub : Hub<IOnlineUserHub>
{
private const string GROUP_ONLINE = "GROUP_ONLINE_"; // 租户分组前缀
private readonly UserManager _userManager;
private readonly SqlSugarRepository<SysOnlineUser> _sysOnlineUerRep;
private readonly SysMessageService _sysMessageService;
private readonly IHubContext<OnlineUserHub, IOnlineUserHub> _onlineUserHubContext;
@ -27,13 +28,15 @@ public class OnlineUserHub : Hub<IOnlineUserHub>
SysMessageService sysMessageService,
IHubContext<OnlineUserHub, IOnlineUserHub> onlineUserHubContext,
SysCacheService sysCacheService,
SysConfigService sysConfigService)
SysConfigService sysConfigService,
UserManager userManager)
{
_sysOnlineUerRep = sysOnlineUerRep;
_sysMessageService = sysMessageService;
_onlineUserHubContext = onlineUserHubContext;
_sysCacheService = sysCacheService;
_sysConfigService = sysConfigService;
_userManager = userManager;
}
/// <summary>
@ -43,23 +46,17 @@ public class OnlineUserHub : Hub<IOnlineUserHub>
public override async Task OnConnectedAsync()
{
var httpContext = Context.GetHttpContext();
var token = httpContext.Request.Query["access_token"];
var claims = JWTEncryption.ReadJwtToken(token)?.Claims;
var client = Parser.GetDefault().Parse(httpContext.Request.Headers["User-Agent"]);
var userId = claims?.FirstOrDefault(u => u.Type == ClaimConst.UserId)?.Value;
var tenantId = claims?.FirstOrDefault(u => u.Type == ClaimConst.TenantId)?.Value;
var user = new SysOnlineUser
{
ConnectionId = Context.ConnectionId,
UserId = string.IsNullOrWhiteSpace(userId) ? 0 : long.Parse(userId),
UserName = claims?.FirstOrDefault(u => u.Type == ClaimConst.Account)?.Value,
RealName = claims?.FirstOrDefault(u => u.Type == ClaimConst.RealName)?.Value,
UserId = _userManager.UserId,
UserName = _userManager.Account,
RealName = _userManager.RealName,
Time = DateTime.Now,
Ip = httpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(),
Browser = client.UA.Family + client.UA.Major,
Os = client.OS.Family + client.OS.Major,
TenantId = string.IsNullOrWhiteSpace(tenantId) ? 0 : Convert.ToInt64(tenantId),
Ip = httpContext.GetRemoteIpAddressToIPv4(true),
Browser = httpContext.GetClientBrowser(),
Os = httpContext.GetClientOs(),
TenantId = _userManager.TenantId,
};
await _sysOnlineUerRep.InsertAsync(user);
@ -70,7 +67,7 @@ public class OnlineUserHub : Hub<IOnlineUserHub>
}
else
{
var device = (client.UA.Family + client.UA.Major + client.OS.Family + client.OS.Major).Trim();
var device = httpContext.GetClientDeviceInfo().Trim();
_sysCacheService.Set(CacheConst.KeyUserOnline + user.UserId + device, user);
}
@ -98,7 +95,6 @@ public class OnlineUserHub : Hub<IOnlineUserHub>
if (string.IsNullOrEmpty(Context.ConnectionId)) return;
var httpContext = Context.GetHttpContext();
var client = Parser.GetDefault().Parse(httpContext.Request.Headers["User-Agent"]);
var user = await _sysOnlineUerRep.AsQueryable().Filter("", true).FirstAsync(u => u.ConnectionId == Context.ConnectionId);
if (user == null) return;
@ -112,7 +108,7 @@ public class OnlineUserHub : Hub<IOnlineUserHub>
}
else
{
var device = (client.UA.Family + client.UA.Major + client.OS.Family + client.OS.Major).Trim();
var device = httpContext.GetClientDeviceInfo().Trim();
_sysCacheService.Remove(CacheConst.KeyUserOnline + user.UserId + device);
}

View File

@ -36,12 +36,13 @@ public class LogJob : IJob
await logOpRep.CopyNew().AsDeleteable().Where(u => (DateTime)u.CreateTime < DateTime.Now.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除操作日志
await logDiffRep.CopyNew().AsDeleteable().Where(u => (DateTime)u.CreateTime < DateTime.Now.AddDays(-daysAgo)).ExecuteCommandAsync(stoppingToken); // 删除差异日志
string msg = $"【{DateTime.Now}】清理系统日志成功,删除 {daysAgo} 天前的日志数据!";
var originColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"【{DateTime.Now}】清理系统日志({daysAgo}天前)");
Console.WriteLine(msg);
Console.ForegroundColor = originColor;
// 自定义日志
_logger.LogInformation($"【{DateTime.Now}】清理系统日志...");
_logger.LogInformation(msg);
}
}

View File

@ -31,15 +31,16 @@ public class OnlineUserJob : IJob
var rep = serviceScope.ServiceProvider.GetRequiredService<SqlSugarRepository<SysOnlineUser>>();
await rep.CopyNew().AsDeleteable().ExecuteCommandAsync(stoppingToken);
var originColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"【{DateTime.Now}】清空在线用户列表");
Console.ForegroundColor = originColor;
// 缓存租户列表
await serviceScope.ServiceProvider.GetRequiredService<SysTenantService>().CacheTenant();
string msg = $"【{DateTime.Now}】清理在线用户成功!服务已重启...";
var originColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(msg);
Console.ForegroundColor = originColor;
// 自定义日志
_logger.LogInformation($"【{DateTime.Now}】服务已重启...");
_logger.LogInformation(msg);
}
}

View File

@ -32,6 +32,7 @@ public class SysConfigSeedData : ISqlSugarEntitySeedData<SysConfig>
new SysConfig{ Id=1300000000201, Name="发送异常日志邮件", Code="sys_error_mail", Value="True", SysFlag=YesNoEnum.Y, Remark="是否发送异常日志邮件", OrderNo=110, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
new SysConfig{ Id=1300000000211, Name="开启域登录验证", Code="sys_domain_login", Value="False", SysFlag=YesNoEnum.Y, Remark="是否开启域登录验证", OrderNo=120, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
new SysConfig{ Id=1300000000221, Name="开启数据校验日志", Code="sys_validation_log", Value="True", SysFlag=YesNoEnum.Y, Remark="是否数据校验日志", OrderNo=130, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
new SysConfig{ Id=1300000000231, Name="行政区域同步层级", Code="sys_region_sync_level", Value="3", SysFlag=YesNoEnum.Y, Remark="行政区域同步层级 1-省级,2-市级,3-区县级,4-街道级,5-村级", OrderNo=140, GroupCode="Default", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
new SysConfig{ Id=1300000000301, Name="系统主标题", Code="sys_web_title", Value="Admin.NET.Pro", SysFlag=YesNoEnum.Y, Remark="系统主标题", OrderNo=300, GroupCode="WebConfig", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
new SysConfig{ Id=1300000000311, Name="系统副标题", Code="sys_web_viceTitle", Value="Admin.NET.Pro", SysFlag=YesNoEnum.Y, Remark="系统副标题", OrderNo=310, GroupCode="WebConfig", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },
new SysConfig{ Id=1300000000321, Name="系统描述", Code="sys_web_viceDesc", Value="站在巨人肩膀上的 .NET 通用权限开发框架", SysFlag=YesNoEnum.Y, Remark="系统描述", OrderNo=320, GroupCode="WebConfig", CreateTime=DateTime.Parse("2022-02-10 00:00:00") },

View File

@ -275,7 +275,7 @@ public class SysAuthService : IDynamicApiController, ITransient
var roleIds = await _sysUserRep.ChangeRepository<SqlSugarRepository<SysUserRole>>().AsQueryable()
.Where(u => u.UserId == user.Id).Select(u => u.RoleId).ToListAsync();
// 获取水印文字(若系统水印为空则全局为空)
var watermarkText = await _sysConfigService.GetConfigValue<string>("sys_web_watermark");
var watermarkText = await _sysConfigService.GetConfigValue<string>(ConfigConst.SysWebWatermark);
if (!string.IsNullOrWhiteSpace(watermarkText))
watermarkText += $"-{user.RealName}"; // $"-{user.RealName}-{_httpContextAccessor.HttpContext.GetRemoteIp()}-{DateTime.Now}";

View File

@ -16,6 +16,11 @@ public class InfoSaveInput
/// </summary>
public string SysLogoBase64 { get; set; }
/// <summary>
/// 系统图标文件名
/// </summary>
public string SysLogoFileName { get; set; }
/// <summary>
/// 系统主标题
/// </summary>

View File

@ -14,15 +14,12 @@ public class SysConfigService : IDynamicApiController, ITransient
{
private readonly SysCacheService _sysCacheService;
private readonly SqlSugarRepository<SysConfig> _sysConfigRep;
private readonly UserManager _userManager;
public SysConfigService(SysCacheService sysCacheService,
SqlSugarRepository<SysConfig> sysConfigRep,
UserManager userManager)
SqlSugarRepository<SysConfig> sysConfigRep)
{
_sysCacheService = sysCacheService;
_sysConfigRep = sysConfigRep;
_userManager = userManager;
}
/// <summary>
@ -34,7 +31,7 @@ public class SysConfigService : IDynamicApiController, ITransient
public async Task<SqlSugarPagedList<SysConfig>> Page(PageConfigInput input)
{
return await _sysConfigRep.AsQueryable()
.WhereIF(!_userManager.SuperAdmin, u => u.GroupCode != "WebConfig") // 若非超管,不显示 WebConfig 分组
.Where(u => u.GroupCode != ConfigConst.SysWebConfigGroup) // 不显示 WebConfig 分组
.WhereIF(!string.IsNullOrWhiteSpace(input.Name?.Trim()), u => u.Name.Contains(input.Name))
.WhereIF(!string.IsNullOrWhiteSpace(input.Code?.Trim()), u => u.Code.Contains(input.Code))
.WhereIF(!string.IsNullOrWhiteSpace(input.GroupCode?.Trim()), u => u.GroupCode.Equals(input.GroupCode))
@ -186,7 +183,7 @@ public class SysConfigService : IDynamicApiController, ITransient
public async Task<List<string>> GetGroupList()
{
return await _sysConfigRep.AsQueryable()
.Where(u => u.GroupCode != "WebConfig") // 不显示 WebConfig 分组
.Where(u => u.GroupCode != ConfigConst.SysWebConfigGroup) // 不显示 WebConfig 分组
.GroupBy(u => u.GroupCode)
.Select(u => u.GroupCode).ToListAsync();
}
@ -240,14 +237,14 @@ public class SysConfigService : IDynamicApiController, ITransient
[DisplayName("获取系统信息")]
public async Task<dynamic> GetSysInfo()
{
var sysLogo = await GetConfigValue<string>("sys_web_logo");
var sysTitle = await GetConfigValue<string>("sys_web_title");
var sysViceTitle = await GetConfigValue<string>("sys_web_viceTitle");
var sysViceDesc = await GetConfigValue<string>("sys_web_viceDesc");
var sysWatermark = await GetConfigValue<string>("sys_web_watermark");
var sysCopyright = await GetConfigValue<string>("sys_web_copyright");
var sysIcp = await GetConfigValue<string>("sys_web_icp");
var sysIcpUrl = await GetConfigValue<string>("sys_web_icpUrl");
var sysLogo = await GetConfigValue<string>(ConfigConst.SysWebLogo);
var sysTitle = await GetConfigValue<string>(ConfigConst.SysWebTitle);
var sysViceTitle = await GetConfigValue<string>(ConfigConst.SysWebViceTitle);
var sysViceDesc = await GetConfigValue<string>(ConfigConst.SysWebViceDesc);
var sysWatermark = await GetConfigValue<string>(ConfigConst.SysWebWatermark);
var sysCopyright = await GetConfigValue<string>(ConfigConst.SysWebCopyright);
var sysIcp = await GetConfigValue<string>(ConfigConst.SysWebIcp);
var sysIcpUrl = await GetConfigValue<string>(ConfigConst.SysWebIcpUrl);
return new
{
@ -266,6 +263,7 @@ public class SysConfigService : IDynamicApiController, ITransient
/// 保存系统信息 🔖
/// </summary>
/// <returns></returns>
[UnitOfWork]
[DisplayName("保存系统信息")]
public async Task SaveSysInfo(InfoSaveInput input)
{
@ -273,17 +271,18 @@ public class SysConfigService : IDynamicApiController, ITransient
if (!string.IsNullOrEmpty(input.SysLogoBase64))
{
// 旧图标文件相对路径
var oldSysLogoRelativeFilePath = await GetConfigValue<string>("sys_web_logo") ?? "";
var oldSysLogoRelativeFilePath = await GetConfigValue<string>(ConfigConst.SysWebLogo) ?? "";
var oldSysLogoAbsoluteFilePath = Path.Combine(App.WebHostEnvironment.WebRootPath, oldSysLogoRelativeFilePath.TrimStart('/'));
var groups = Regex.Match(input.SysLogoBase64, @"data:image/(?<type>.+?);base64,(?<data>.+)").Groups;
var type = groups["type"].Value;
//var type = groups["type"].Value;
var base64Data = groups["data"].Value;
var binData = Convert.FromBase64String(base64Data);
// 根据文件名取扩展名
var ext = string.IsNullOrWhiteSpace(input.SysLogoFileName) ? ".png" : Path.GetExtension(input.SysLogoFileName);
// 本地图标保存路径
var path = "Upload";
var absoluteFilePath = Path.Combine(App.WebHostEnvironment.WebRootPath, path, $"logo.{type}");
var absoluteFilePath = Path.Combine(App.WebHostEnvironment.WebRootPath, path, $"logo{ext}");
// 删除已存在文件
if (File.Exists(oldSysLogoAbsoluteFilePath))
@ -298,16 +297,16 @@ public class SysConfigService : IDynamicApiController, ITransient
await File.WriteAllBytesAsync(absoluteFilePath, binData);
// 保存图标配置
var relativeUrl = $"/{path}/logo.{type}";
await UpdateConfigValue("sys_web_logo", relativeUrl);
var relativeUrl = $"/{path}/logo{ext}";
await UpdateConfigValue(ConfigConst.SysWebLogo, relativeUrl);
}
await UpdateConfigValue("sys_web_title", input.SysTitle);
await UpdateConfigValue("sys_web_viceTitle", input.SysViceTitle);
await UpdateConfigValue("sys_web_viceDesc", input.SysViceDesc);
await UpdateConfigValue("sys_web_watermark", input.SysWatermark);
await UpdateConfigValue("sys_web_copyright", input.SysCopyright);
await UpdateConfigValue("sys_web_icp", input.SysIcp);
await UpdateConfigValue("sys_web_icpUrl", input.SysIcpUrl);
await UpdateConfigValue(ConfigConst.SysWebTitle, input.SysTitle);
await UpdateConfigValue(ConfigConst.SysWebViceTitle, input.SysViceTitle);
await UpdateConfigValue(ConfigConst.SysWebViceDesc, input.SysViceDesc);
await UpdateConfigValue(ConfigConst.SysWebWatermark, input.SysWatermark);
await UpdateConfigValue(ConfigConst.SysWebCopyright, input.SysCopyright);
await UpdateConfigValue(ConfigConst.SysWebIcp, input.SysIcp);
await UpdateConfigValue(ConfigConst.SysWebIcpUrl, input.SysIcpUrl);
}
}

View File

@ -33,7 +33,7 @@ public class JobMonitor : IJobMonitor
if (await _sysConfigService.GetConfigValue<bool>(CommonConst.SysErrorMail) && context.Exception != null)
{
var errorInfo = $"【{context.Trigger.Description}】定时任务错误:{context.Exception}";
await _eventPublisher.PublishAsync(CommonConst.SendErrorMail, errorInfo);
await _eventPublisher.PublishAsync(CommonConst.SendErrorMail, errorInfo, stoppingToken);
}
}
}

View File

@ -16,10 +16,12 @@ namespace Admin.NET.Core.Service;
public class SysEmailService : IDynamicApiController, ITransient
{
private readonly EmailOptions _emailOptions;
private readonly SysConfigService _sysConfigService;
public SysEmailService(IOptions<EmailOptions> emailOptions)
public SysEmailService(IOptions<EmailOptions> emailOptions, SysConfigService sysConfigService)
{
_emailOptions = emailOptions.Value;
_sysConfigService = sysConfigService;
}
/// <summary>
@ -29,8 +31,10 @@ public class SysEmailService : IDynamicApiController, ITransient
/// <param name="title"></param>
/// <returns></returns>
[DisplayName("发送邮件")]
public async Task SendEmail([Required] string content, string title = "Admin.NET 系统邮件")
public async Task SendEmail([Required] string content, string title = "")
{
var webTitle = await _sysConfigService.GetConfigValue<string>(ConfigConst.SysWebTitle);
title = string.IsNullOrWhiteSpace(title) ? $"{webTitle} 系统邮件" : title;
var message = new MimeMessage();
message.From.Add(new MailboxAddress(_emailOptions.DefaultFromEmail, _emailOptions.DefaultFromEmail));
message.To.Add(new MailboxAddress(_emailOptions.DefaultToEmail, _emailOptions.DefaultToEmail));

View File

@ -1,32 +0,0 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using Microsoft.AspNetCore.Authentication;
namespace Admin.NET.Core.Service;
public static class HttpContextExtension
{
public static async Task<AuthenticationScheme[]> GetExternalProvidersAsync(this HttpContext context)
{
ArgumentNullException.ThrowIfNull(context);
var schemes = context.RequestServices.GetRequiredService<IAuthenticationSchemeProvider>();
return (from scheme in await schemes.GetAllSchemesAsync()
where !string.IsNullOrEmpty(scheme.DisplayName)
select scheme).ToArray();
}
public static async Task<bool> IsProviderSupportedAsync(this HttpContext context, string provider)
{
ArgumentNullException.ThrowIfNull(context);
return (from scheme in await context.GetExternalProvidersAsync()
where string.Equals(scheme.Name, provider, StringComparison.OrdinalIgnoreCase)
select scheme).Any();
}
}

View File

@ -4,6 +4,9 @@
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using AngleSharp;
using AngleSharp.Html.Dom;
namespace Admin.NET.Core.Service;
/// <summary>
@ -13,13 +16,15 @@ namespace Admin.NET.Core.Service;
public class SysRegionService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<SysRegion> _sysRegionRep;
private readonly SysConfigService _sysConfigService;
//// Url地址-国家统计局行政区域2023年
//private readonly string _url = "http://www.stats.gov.cn/sj/tjbz/tjyqhdmhcxhfdm/2023/index.html";
// Url地址-国家统计局行政区域2023年
private readonly string _url = "http://www.stats.gov.cn/sj/tjbz/tjyqhdmhcxhfdm/2023/index.html";
public SysRegionService(SqlSugarRepository<SysRegion> sysRegionRep)
public SysRegionService(SqlSugarRepository<SysRegion> sysRegionRep, SysConfigService sysConfigService)
{
_sysRegionRep = sysRegionRep;
_sysConfigService = sysConfigService;
}
/// <summary>
@ -59,7 +64,7 @@ public class SysRegionService : IDynamicApiController, ITransient
{
input.Code = input.Code.Trim();
if (input.Code.Length != 12 && input.Code.Length != 9 && input.Code.Length != 6)
throw Oops.Oh("行政区代码只能为6、9或12位");
throw Oops.Oh(ErrorCodeEnum.R2003);
if (input.Pid != 0)
{
@ -90,7 +95,7 @@ public class SysRegionService : IDynamicApiController, ITransient
{
input.Code = input.Code.Trim();
if (input.Code.Length != 12 && input.Code.Length != 9 && input.Code.Length != 6)
throw Oops.Oh("行政区代码只能为6、9或12位");
throw Oops.Oh(ErrorCodeEnum.R2003);
if (input.Pid != input.Pid && input.Pid != 0)
{
@ -103,7 +108,7 @@ public class SysRegionService : IDynamicApiController, ITransient
var regionTreeList = await _sysRegionRep.AsQueryable().ToChildListAsync(u => u.Pid, input.Id, true);
var childIdList = regionTreeList.Select(u => u.Id).ToList();
if (childIdList.Contains(input.Pid))
throw Oops.Oh("父节点不能为自己的子节点");
throw Oops.Oh(ErrorCodeEnum.R2004);
}
if (input.Id == input.Pid)
@ -144,93 +149,117 @@ public class SysRegionService : IDynamicApiController, ITransient
[DisplayName("同步行政区域")]
public async Task Sync()
{
var syncLevel = await _sysConfigService.GetConfigValue<int>(CommonConst.SysRegionSyncLevel);
if (syncLevel < 1 || syncLevel > 5)
syncLevel = 3;//默认区县级
var context = BrowsingContext.New(AngleSharp.Configuration.Default.WithDefaultLoader());
var dom = await context.OpenAsync(_url);
// 省级
var itemList = dom.QuerySelectorAll("table.provincetable tr.provincetr td a");
if (itemList.Length == 0)
throw Oops.Oh(ErrorCodeEnum.R2005);
await _sysRegionRep.DeleteAsync(u => u.Id > 0);
//var context = BrowsingContext.New(AngleSharp.Configuration.Default.WithDefaultLoader());
//var dom = await context.OpenAsync(_url);
foreach (IHtmlAnchorElement item in itemList)
{
var list = new List<SysRegion>();
//// 省级
//var itemList = dom.QuerySelectorAll("table.provincetable tr.provincetr td a");
//foreach (IHtmlAnchorElement item in itemList)
//{
// var region = await _sysRegionRep.InsertReturnEntityAsync(new SysRegion
// {
// Pid = 0,
// Name = item.TextContent,
// Remark = item.Href,
// Level = 1,
// });
var region = new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = 0,
Name = item.TextContent,
Remark = item.Href,
Level = 1,
};
list.Add(region);
// // 市级
// if (string.IsNullOrEmpty(item.Href))
// continue;
// var dom1 = await context.OpenAsync(item.Href);
// var itemList1 = dom1.QuerySelectorAll("table.citytable tr.citytr td a");
// for (var i1 = 0; i1 < itemList1.Length; i1 += 2)
// {
// var item1 = (IHtmlAnchorElement)itemList1[i1 + 1];
// var region1 = await _sysRegionRep.InsertReturnEntityAsync(new SysRegion
// {
// Pid = region.Id,
// Name = item1.TextContent,
// Code = itemList1[i1].TextContent,
// Remark = item1.Href,
// Level = 2,
// });
// 市级
if (!string.IsNullOrEmpty(item.Href) && syncLevel > 1)
{
var dom1 = await context.OpenAsync(item.Href);
var itemList1 = dom1.QuerySelectorAll("table.citytable tr.citytr td a");
for (var i1 = 0; i1 < itemList1.Length; i1 += 2)
{
var item1 = (IHtmlAnchorElement)itemList1[i1 + 1];
var region1 = new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = region.Id,
Name = item1.TextContent,
Code = itemList1[i1].TextContent,
Remark = item1.Href,
Level = 2,
};
list.Add(region1);
// // 区县级
// if (string.IsNullOrEmpty(item1.Href))
// continue;
// var dom2 = await context.OpenAsync(item1.Href);
// var itemList2 = dom2.QuerySelectorAll("table.countytable tr.countytr td a");
// for (var i2 = 0; i2 < itemList2.Length; i2 += 2)
// {
// var item2 = (IHtmlAnchorElement)itemList2[i2 + 1];
// var region2 = await _sysRegionRep.InsertReturnEntityAsync(new SysRegion
// {
// Pid = region1.Id,
// Name = item2.TextContent,
// Code = itemList2[i2].TextContent,
// Remark = item2.Href,
// Level = 3,
// });
// 区县级
if (!string.IsNullOrEmpty(item1.Href) && syncLevel > 2)
{
var dom2 = await context.OpenAsync(item1.Href);
var itemList2 = dom2.QuerySelectorAll("table.countytable tr.countytr td a");
for (var i2 = 0; i2 < itemList2.Length; i2 += 2)
{
var item2 = (IHtmlAnchorElement)itemList2[i2 + 1];
var region2 = new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = region1.Id,
Name = item2.TextContent,
Code = itemList2[i2].TextContent,
Remark = item2.Href,
Level = 3,
};
list.Add(region2);
// // 街道级
// if (string.IsNullOrEmpty(item2.Href))
// continue;
// var dom3 = await context.OpenAsync(item2.Href);
// var itemList3 = dom3.QuerySelectorAll("table.towntable tr.towntr td a");
// for (var i3 = 0; i3 < itemList3.Length; i3 += 2)
// {
// var item3 = (IHtmlAnchorElement)itemList3[i3 + 1];
// var region3 = await _sysRegionRep.InsertReturnEntityAsync(new SysRegion
// {
// Pid = region2.Id,
// Name = item3.TextContent,
// Code = itemList3[i3].TextContent,
// Remark = item3.Href,
// Level = 4,
// });
// 街道级
if (!string.IsNullOrEmpty(item2.Href) && syncLevel > 3)
{
var dom3 = await context.OpenAsync(item2.Href);
var itemList3 = dom3.QuerySelectorAll("table.towntable tr.towntr td a");
for (var i3 = 0; i3 < itemList3.Length; i3 += 2)
{
var item3 = (IHtmlAnchorElement)itemList3[i3 + 1];
var region3 = new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = region2.Id,
Name = item3.TextContent,
Code = itemList3[i3].TextContent,
Remark = item3.Href,
Level = 4,
};
list.Add(region3);
// // 村级
// if (string.IsNullOrEmpty(item3.Href))
// continue;
// var dom4 = await context.OpenAsync(item3.Href);
// var itemList4 = dom4.QuerySelectorAll("table.villagetable tr.villagetr td");
// for (var i4 = 0; i4 < itemList4.Length; i4 += 3)
// {
// await _sysRegionRep.InsertAsync(new SysRegion
// {
// Pid = region3.Id,
// Name = itemList4[i4 + 2].TextContent,
// Code = itemList4[i4].TextContent,
// CityCode = itemList4[i4 + 1].TextContent,
// Level = 5,
// });
// }
// }
// }
// }
//}
// 村级
if (!string.IsNullOrEmpty(item3.Href) && syncLevel > 4)
{
var dom4 = await context.OpenAsync(item3.Href);
var itemList4 = dom4.QuerySelectorAll("table.villagetable tr.villagetr td");
for (var i4 = 0; i4 < itemList4.Length; i4 += 3)
{
list.Add(new SysRegion
{
Id = YitIdHelper.NextId(),
Pid = region3.Id,
Name = itemList4[i4 + 2].TextContent,
Code = itemList4[i4].TextContent,
CityCode = itemList4[i4 + 1].TextContent,
Level = 5,
});
}
}
}
}
}
}
}
}
//按省份同步快速写入提升同步效率,全部一次性写入容易出现从统计局获取数据失败
_sysRegionRep.Context.Fastest<SysRegion>().BulkCopy(list);
}
}
}

View File

@ -122,19 +122,21 @@ public class AddSubscribeMessageTemplateInput
/// </summary>
public class VerifySignatureInput
{
/// <summary>
/// 签名
/// </summary>
public string signature { get; set; }
/// <summary>
/// 时间戳
/// </summary>
public string timestamp { get; set; }
/// <summary>
/// 随机数
/// </summary>
public string nonce { get; set; }
/// <summary>
/// 随机字符串
/// </summary>

View File

@ -123,7 +123,6 @@ public class SysWxOpenService : IDynamicApiController, ITransient
[DisplayName("验证签名")]
public string VerifySignature([FromQuery] VerifySignatureInput input)
{
bool valid = _wechatApiClient.VerifyEventSignatureForEcho(input.timestamp, input.nonce, input.signature);
if (!valid)
{

View File

@ -68,8 +68,10 @@ public static class SqlSugarFilter
if ((tAtt != null && db.CurrentConnectionConfig.ConfigId.ToString() != tAtt.configId.ToString()))
continue;
var lambda = DynamicExpressionParser.ParseLambda(new[] {
Expression.Parameter(entityType, "u") }, typeof(bool), $"@0.Contains(u.{nameof(EntityBaseData.CreateOrgId)}??{default(long)})", orgIds);
//var lambda = DynamicExpressionParser.ParseLambda(new[] {
// Expression.Parameter(entityType, "u") }, typeof(bool), $"@0.Contains(u.{nameof(EntityBaseData.CreateOrgId)}??{default(long)})", orgIds);
var lambda = entityType.GetConditionExpression<OwnerOrgAttribute>(orgIds);
db.QueryFilter.AddTableFilter(entityType, lambda);
orgFilter.TryAdd(entityType, lambda);
}
@ -114,8 +116,10 @@ public static class SqlSugarFilter
if ((tAtt != null && db.CurrentConnectionConfig.ConfigId.ToString() != tAtt.configId.ToString()))
continue;
var lambda = DynamicExpressionParser.ParseLambda(new[] {
Expression.Parameter(entityType, "u") }, typeof(bool), $"u.{nameof(EntityBaseData.CreateUserId)}=@0", userId);
//var lambda = DynamicExpressionParser.ParseLambda(new[] {
// Expression.Parameter(entityType, "u") }, typeof(bool), $"u.{nameof(EntityBaseData.CreateUserId)}=@0", userId);
var lambda = entityType.GetConditionExpression<OwnerUserAttribute>(new List<long> { long.Parse(userId) });
db.QueryFilter.AddTableFilter(entityType, lambda);
dataScopeFilter.TryAdd(entityType, lambda);
}

View File

@ -0,0 +1,75 @@
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
//
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
namespace Admin.NET.Core;
/// <summary>
/// 模糊查询条件
/// </summary>
public class Search
{
/// <summary>
/// 字段名称集合
/// </summary>
public List<string> Fields { get; set; }
/// <summary>
/// 关键字
/// </summary>
public string? Keyword { get; set; }
}
/// <summary>
/// 筛选过滤条件
/// </summary>
public class Filter
{
/// <summary>
/// 过滤条件
/// </summary>
public FilterLogicEnum? Logic { get; set; }
/// <summary>
/// 筛选过滤条件子项
/// </summary>
public IEnumerable<Filter>? Filters { get; set; }
/// <summary>
/// 字段名称
/// </summary>
public string? Field { get; set; }
/// <summary>
/// 逻辑运算符
/// </summary>
public FilterOperatorEnum? Operator { get; set; }
/// <summary>
/// 字段值
/// </summary>
public object? Value { get; set; }
}
/// <summary>
/// 过滤条件基类
/// </summary>
public abstract class BaseFilter
{
/// <summary>
/// 模糊查询条件
/// </summary>
public Search? Search { get; set; }
/// <summary>
/// 模糊查询关键字
/// </summary>
public string? Keyword { get; set; }
/// <summary>
/// 筛选过滤条件
/// </summary>
public Filter? Filter { get; set; }
}

View File

@ -9,7 +9,7 @@ namespace Admin.NET.Core;
/// <summary>
/// 全局分页查询输入参数
/// </summary>
public class BasePageInput
public class BasePageInput : BaseFilter
{
/// <summary>
/// 当前页码

View File

@ -17,6 +17,7 @@ import { Configuration } from '../configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
import { AdminResultIActionResult } from '../models';
import { AdminResultListApiOutput } from '../models';
import { AdminResultSmKeyPairOutput } from '../models';
import { AdminResultString } from '../models';
@ -74,6 +75,54 @@ export const SysCommonApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions,
};
},
/**
*
* @summary Excel
* @param {string} [fileName]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysCommonDownloadErrorExcelTempPost: async (fileName?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysCommon/downloadErrorExcelTemp`;
// 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: 'POST', ...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;
}
if (fileName !== undefined) {
localVarQueryParameter['fileName'] = fileName;
}
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 MD5加密字符串 🏆
@ -195,6 +244,20 @@ export const SysCommonApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary Excel
* @param {string} [fileName]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysCommonDownloadErrorExcelTempPost(fileName?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultIActionResult>>> {
const localVarAxiosArgs = await SysCommonApiAxiosParamCreator(configuration).apiSysCommonDownloadErrorExcelTempPost(fileName, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary MD5加密字符串 🏆
@ -242,6 +305,16 @@ export const SysCommonApiFactory = function (configuration?: Configuration, base
async apiSysCommonApiListGet(groupName?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultListApiOutput>> {
return SysCommonApiFp(configuration).apiSysCommonApiListGet(groupName, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Excel
* @param {string} [fileName]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysCommonDownloadErrorExcelTempPost(fileName?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultIActionResult>> {
return SysCommonApiFp(configuration).apiSysCommonDownloadErrorExcelTempPost(fileName, options).then((request) => request(axios, basePath));
},
/**
*
* @summary MD5加密字符串 🏆
@ -283,6 +356,17 @@ export class SysCommonApi extends BaseAPI {
public async apiSysCommonApiListGet(groupName?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultListApiOutput>> {
return SysCommonApiFp(this.configuration).apiSysCommonApiListGet(groupName, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary Excel
* @param {string} [fileName]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysCommonApi
*/
public async apiSysCommonDownloadErrorExcelTempPost(fileName?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultIActionResult>> {
return SysCommonApiFp(this.configuration).apiSysCommonDownloadErrorExcelTempPost(fileName, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary MD5加密字符串 🏆

View File

@ -22,6 +22,9 @@ import { AdminResultListSysNotice } from '../models';
import { AdminResultSqlSugarPagedListSysNotice } from '../models';
import { AdminResultSqlSugarPagedListSysNoticeUser } from '../models';
import { DeleteNoticeInput } from '../models';
import { Filter } from '../models';
import { FilterLogicEnum } from '../models';
import { FilterOperatorEnum } from '../models';
import { NoticeInput } from '../models';
import { NoticeTypeEnum } from '../models';
import { PageNoticeInput } from '../models';
@ -186,10 +189,18 @@ export const SysNoticeApiAxiosParamCreator = function (configuration?: Configura
* @param {string} [field]
* @param {string} [order]
* @param {string} [descStr]
* @param {Array<string>} [searchFields]
* @param {string} [searchKeyword]
* @param {string} [keyword]
* @param {FilterLogicEnum} [filterLogic]
* @param {Array<Filter>} [filterFilters]
* @param {string} [filterField]
* @param {FilterOperatorEnum} [filterOperator]
* @param {any} [filterValue]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysNoticePageReceivedGet: async (title?: string, type?: NoticeTypeEnum, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
apiSysNoticePageReceivedGet: async (title?: string, type?: NoticeTypeEnum, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array<string>, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array<Filter>, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysNotice/pageReceived`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
@ -238,6 +249,38 @@ export const SysNoticeApiAxiosParamCreator = function (configuration?: Configura
localVarQueryParameter['DescStr'] = descStr;
}
if (searchFields) {
localVarQueryParameter['Search.Fields'] = searchFields;
}
if (searchKeyword !== undefined) {
localVarQueryParameter['Search.Keyword'] = searchKeyword;
}
if (keyword !== undefined) {
localVarQueryParameter['Keyword'] = keyword;
}
if (filterLogic !== undefined) {
localVarQueryParameter['Filter.Logic'] = filterLogic;
}
if (filterFilters) {
localVarQueryParameter['Filter.Filters'] = filterFilters;
}
if (filterField !== undefined) {
localVarQueryParameter['Filter.Field'] = filterField;
}
if (filterOperator !== undefined) {
localVarQueryParameter['Filter.Operator'] = filterOperator;
}
if (filterValue !== undefined) {
localVarQueryParameter['Filter.Value'] = filterValue;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
@ -502,11 +545,19 @@ export const SysNoticeApiFp = function(configuration?: Configuration) {
* @param {string} [field]
* @param {string} [order]
* @param {string} [descStr]
* @param {Array<string>} [searchFields]
* @param {string} [searchKeyword]
* @param {string} [keyword]
* @param {FilterLogicEnum} [filterLogic]
* @param {Array<Filter>} [filterFilters]
* @param {string} [filterField]
* @param {FilterOperatorEnum} [filterOperator]
* @param {any} [filterValue]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysNoticePageReceivedGet(title?: string, type?: NoticeTypeEnum, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultSqlSugarPagedListSysNoticeUser>>> {
const localVarAxiosArgs = await SysNoticeApiAxiosParamCreator(configuration).apiSysNoticePageReceivedGet(title, type, page, pageSize, field, order, descStr, options);
async apiSysNoticePageReceivedGet(title?: string, type?: NoticeTypeEnum, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array<string>, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array<Filter>, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultSqlSugarPagedListSysNoticeUser>>> {
const localVarAxiosArgs = await SysNoticeApiAxiosParamCreator(configuration).apiSysNoticePageReceivedGet(title, type, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
@ -616,11 +667,19 @@ export const SysNoticeApiFactory = function (configuration?: Configuration, base
* @param {string} [field]
* @param {string} [order]
* @param {string} [descStr]
* @param {Array<string>} [searchFields]
* @param {string} [searchKeyword]
* @param {string} [keyword]
* @param {FilterLogicEnum} [filterLogic]
* @param {Array<Filter>} [filterFilters]
* @param {string} [filterField]
* @param {FilterOperatorEnum} [filterOperator]
* @param {any} [filterValue]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysNoticePageReceivedGet(title?: string, type?: NoticeTypeEnum, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultSqlSugarPagedListSysNoticeUser>> {
return SysNoticeApiFp(configuration).apiSysNoticePageReceivedGet(title, type, page, pageSize, field, order, descStr, options).then((request) => request(axios, basePath));
async apiSysNoticePageReceivedGet(title?: string, type?: NoticeTypeEnum, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array<string>, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array<Filter>, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultSqlSugarPagedListSysNoticeUser>> {
return SysNoticeApiFp(configuration).apiSysNoticePageReceivedGet(title, type, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options).then((request) => request(axios, basePath));
},
/**
*
@ -714,12 +773,20 @@ export class SysNoticeApi extends BaseAPI {
* @param {string} [field]
* @param {string} [order]
* @param {string} [descStr]
* @param {Array<string>} [searchFields]
* @param {string} [searchKeyword]
* @param {string} [keyword]
* @param {FilterLogicEnum} [filterLogic]
* @param {Array<Filter>} [filterFilters]
* @param {string} [filterField]
* @param {FilterOperatorEnum} [filterOperator]
* @param {any} [filterValue]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysNoticeApi
*/
public async apiSysNoticePageReceivedGet(title?: string, type?: NoticeTypeEnum, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultSqlSugarPagedListSysNoticeUser>> {
return SysNoticeApiFp(this.configuration).apiSysNoticePageReceivedGet(title, type, page, pageSize, field, order, descStr, options).then((request) => request(this.axios, this.basePath));
public async apiSysNoticePageReceivedGet(title?: string, type?: NoticeTypeEnum, page?: number, pageSize?: number, field?: string, order?: string, descStr?: string, searchFields?: Array<string>, searchKeyword?: string, keyword?: string, filterLogic?: FilterLogicEnum, filterFilters?: Array<Filter>, filterField?: string, filterOperator?: FilterOperatorEnum, filterValue?: any, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultSqlSugarPagedListSysNoticeUser>> {
return SysNoticeApiFp(this.configuration).apiSysNoticePageReceivedGet(title, type, page, pageSize, field, order, descStr, searchFields, searchKeyword, keyword, filterLogic, filterFilters, filterField, filterOperator, filterValue, options).then((request) => request(this.axios, this.basePath));
}
/**
*

View File

@ -168,6 +168,69 @@ export const SysWxOpenApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions,
};
},
/**
*
* @summary 🔖
* @param {string} [signature]
* @param {string} [timestamp]
* @param {string} [nonce]
* @param {string} [echostr]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysWxOpenVerifySignatureGet: async (signature?: string, timestamp?: string, nonce?: string, echostr?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysWxOpen/verifySignature`;
// 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;
}
if (signature !== undefined) {
localVarQueryParameter['signature'] = signature;
}
if (timestamp !== undefined) {
localVarQueryParameter['timestamp'] = timestamp;
}
if (nonce !== undefined) {
localVarQueryParameter['nonce'] = nonce;
}
if (echostr !== undefined) {
localVarQueryParameter['echostr'] = echostr;
}
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 OpenId 🔖
@ -379,6 +442,23 @@ export const SysWxOpenApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary 🔖
* @param {string} [signature]
* @param {string} [timestamp]
* @param {string} [nonce]
* @param {string} [echostr]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysWxOpenVerifySignatureGet(signature?: string, timestamp?: string, nonce?: string, echostr?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<string>>> {
const localVarAxiosArgs = await SysWxOpenApiAxiosParamCreator(configuration).apiSysWxOpenVerifySignatureGet(signature, timestamp, nonce, echostr, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary OpenId 🔖
@ -460,6 +540,19 @@ export const SysWxOpenApiFactory = function (configuration?: Configuration, base
async apiSysWxOpenSendSubscribeMessagePost(body?: SendSubscribeMessageInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultObject>> {
return SysWxOpenApiFp(configuration).apiSysWxOpenSendSubscribeMessagePost(body, options).then((request) => request(axios, basePath));
},
/**
*
* @summary 🔖
* @param {string} [signature]
* @param {string} [timestamp]
* @param {string} [nonce]
* @param {string} [echostr]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysWxOpenVerifySignatureGet(signature?: string, timestamp?: string, nonce?: string, echostr?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<string>> {
return SysWxOpenApiFp(configuration).apiSysWxOpenVerifySignatureGet(signature, timestamp, nonce, echostr, options).then((request) => request(axios, basePath));
},
/**
*
* @summary OpenId 🔖
@ -533,6 +626,20 @@ export class SysWxOpenApi extends BaseAPI {
public async apiSysWxOpenSendSubscribeMessagePost(body?: SendSubscribeMessageInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultObject>> {
return SysWxOpenApiFp(this.configuration).apiSysWxOpenSendSubscribeMessagePost(body, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary 🔖
* @param {string} [signature]
* @param {string} [timestamp]
* @param {string} [nonce]
* @param {string} [echostr]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysWxOpenApi
*/
public async apiSysWxOpenVerifySignatureGet(signature?: string, timestamp?: string, nonce?: string, echostr?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<string>> {
return SysWxOpenApiFp(this.configuration).apiSysWxOpenVerifySignatureGet(signature, timestamp, nonce, echostr, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary OpenId 🔖

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface AddCodeGenInput {
/**
* @type {Search}
* @memberof AddCodeGenInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof AddCodeGenInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof AddCodeGenInput
*/
filter?: Filter;
/**
*
*

View File

@ -0,0 +1,25 @@
/* tslint:disable */
/* eslint-disable */
/**
* Admin.NET
* .NET <br/><u><b><font color='FF0000'> 👮</font></b></u>
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/**
* <br />&nbsp; And = 0<br />&nbsp; Or = 1<br />&nbsp; Xor = 2<br />
* @export
* @enum {string}
*/
export enum FilterLogicEnum {
NUMBER_0 = 0,
NUMBER_1 = 1,
NUMBER_2 = 2
}

View File

@ -0,0 +1,31 @@
/* tslint:disable */
/* eslint-disable */
/**
* Admin.NET
* .NET <br/><u><b><font color='FF0000'> 👮</font></b></u>
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/**
* <br />&nbsp; EQ = 0<br />&nbsp; NEQ = 1<br />&nbsp; LT = 2<br />&nbsp; LTE = 3<br />&nbsp; GT = 4<br />&nbsp; GTE = 5<br />&nbsp; StartsWith = 6<br />&nbsp; EndsWith = 7<br />&nbsp; Contains = 8<br />
* @export
* @enum {string}
*/
export enum FilterOperatorEnum {
NUMBER_0 = 0,
NUMBER_1 = 1,
NUMBER_2 = 2,
NUMBER_3 = 3,
NUMBER_4 = 4,
NUMBER_5 = 5,
NUMBER_6 = 6,
NUMBER_7 = 7,
NUMBER_8 = 8
}

View File

@ -0,0 +1,61 @@
/* tslint:disable */
/* eslint-disable */
/**
* Admin.NET
* .NET <br/><u><b><font color='FF0000'> 👮</font></b></u>
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { FilterLogicEnum } from './filter-logic-enum';
import { FilterOperatorEnum } from './filter-operator-enum';
/**
*
*
* @export
* @interface Filter
*/
export interface Filter {
/**
* @type {FilterLogicEnum}
* @memberof Filter
*/
logic?: FilterLogicEnum;
/**
*
*
* @type {Array<Filter>}
* @memberof Filter
*/
filters?: Array<Filter> | null;
/**
*
*
* @type {string}
* @memberof Filter
*/
field?: string | null;
/**
* @type {FilterOperatorEnum}
* @memberof Filter
*/
operator?: FilterOperatorEnum;
/**
*
*
* @type {any}
* @memberof Filter
*/
value?: any | null;
}

View File

@ -13,13 +13,14 @@
*/
/**
* <br />&nbsp; Male = 1<br />&nbsp; Female = 2<br />&nbsp; Other = 3<br />
* GB/T 2261.1-2003<br />&nbsp; Unknown = 0<br />&nbsp; Male = 1<br />&nbsp; Female = 2<br />&nbsp; Unspecified = 9<br />
* @export
* @enum {string}
*/
export enum GenderEnum {
NUMBER_0 = 0,
NUMBER_1 = 1,
NUMBER_2 = 2,
NUMBER_3 = 3
NUMBER_9 = 9
}

View File

@ -183,6 +183,9 @@ export * from './field-attributes';
export * from './field-info';
export * from './file-input';
export * from './file-output';
export * from './filter';
export * from './filter-logic-enum';
export * from './filter-operator-enum';
export * from './from';
export * from './gen-auth-url-input';
export * from './gender-enum';
@ -274,6 +277,7 @@ export * from './runtime-field-handle';
export * from './runtime-method-handle';
export * from './runtime-type-handle';
export * from './schema-serialization-mode';
export * from './search';
export * from './security-rule-set';
export * from './send-subscribe-message-input';
export * from './serialization-format';

View File

@ -28,6 +28,14 @@ export interface InfoSaveInput {
*/
sysLogoBase64?: string | null;
/**
*
*
* @type {string}
* @memberof InfoSaveInput
*/
sysLogoFileName?: string | null;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface OAuthUserInput {
/**
* @type {Search}
* @memberof OAuthUserInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof OAuthUserInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof OAuthUserInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageCodeGenInput {
/**
* @type {Search}
* @memberof PageCodeGenInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageCodeGenInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageCodeGenInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageConfigInput {
/**
* @type {Search}
* @memberof PageConfigInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageConfigInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageConfigInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageDictDataInput {
/**
* @type {Search}
* @memberof PageDictDataInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageDictDataInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageDictDataInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageDictTypeInput {
/**
* @type {Search}
* @memberof PageDictTypeInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageDictTypeInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageDictTypeInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageFileInput {
/**
* @type {Search}
* @memberof PageFileInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageFileInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageFileInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageJobDetailInput {
/**
* @type {Search}
* @memberof PageJobDetailInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageJobDetailInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageJobDetailInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageJobTriggerRecordInput {
/**
* @type {Search}
* @memberof PageJobTriggerRecordInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageJobTriggerRecordInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageJobTriggerRecordInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageLogInput {
/**
* @type {Search}
* @memberof PageLogInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageLogInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageLogInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,7 +12,9 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { NoticeTypeEnum } from './notice-type-enum';
import { Search } from './search';
/**
*
*
@ -21,6 +23,26 @@ import { NoticeTypeEnum } from './notice-type-enum';
*/
export interface PageNoticeInput {
/**
* @type {Search}
* @memberof PageNoticeInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageNoticeInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageNoticeInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageOnlineUserInput {
/**
* @type {Search}
* @memberof PageOnlineUserInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageOnlineUserInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageOnlineUserInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageOpenAccessInput {
/**
* @type {Search}
* @memberof PageOpenAccessInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageOpenAccessInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageOpenAccessInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PagePluginInput {
/**
* @type {Search}
* @memberof PagePluginInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PagePluginInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PagePluginInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PagePosInput {
/**
* @type {Search}
* @memberof PagePosInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PagePosInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PagePosInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PagePrintInput {
/**
* @type {Search}
* @memberof PagePrintInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PagePrintInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PagePrintInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageRegionInput {
/**
* @type {Search}
* @memberof PageRegionInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageRegionInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageRegionInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageRoleInput {
/**
* @type {Search}
* @memberof PageRoleInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageRoleInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageRoleInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageSysLdapInput {
/**
* @type {Search}
* @memberof PageSysLdapInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageSysLdapInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageSysLdapInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageSysWechatPayInput {
/**
* @type {Search}
* @memberof PageSysWechatPayInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageSysWechatPayInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageSysWechatPayInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageTenantInput {
/**
* @type {Search}
* @memberof PageTenantInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageTenantInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageTenantInput
*/
filter?: Filter;
/**
*
*

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface PageUserInput {
/**
* @type {Search}
* @memberof PageUserInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof PageUserInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof PageUserInput
*/
filter?: Filter;
/**
*
*

View File

@ -0,0 +1,38 @@
/* tslint:disable */
/* eslint-disable */
/**
* Admin.NET
* .NET <br/><u><b><font color='FF0000'> 👮</font></b></u>
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/**
*
*
* @export
* @interface Search
*/
export interface Search {
/**
*
*
* @type {Array<string>}
* @memberof Search
*/
fields?: Array<string> | null;
/**
*
*
* @type {string}
* @memberof Search
*/
keyword?: string | null;
}

View File

@ -12,6 +12,8 @@
* Do not edit the class manually.
*/
import { Filter } from './filter';
import { Search } from './search';
/**
*
*
@ -20,6 +22,26 @@
*/
export interface UpdateCodeGenInput {
/**
* @type {Search}
* @memberof UpdateCodeGenInput
*/
search?: Search;
/**
*
*
* @type {string}
* @memberof UpdateCodeGenInput
*/
keyword?: string | null;
/**
* @type {Filter}
* @memberof UpdateCodeGenInput
*/
filter?: Filter;
/**
*
*

View File

@ -11,7 +11,7 @@
<el-icon><ele-PictureRounded /></el-icon>
</div>
</template> -->
<el-upload class="avatar-uploader" :showFileList="false" :autoUpload="false" accept=".jpg,.png,.svg" action="" :limit="1" :onChange="handleUploadChange">
<el-upload ref="uploadRef" class="avatar-uploader" :showFileList="false" :autoUpload="false" accept=".jpg,.png,.svg" action="" :limit="1" :onChange="handleUploadChange">
<img v-if="state.formData.sysLogo" :src="state.formData.sysLogo" class="avatar" />
<SvgIcon v-else class="avatar-uploader-icon" name="ele-Plus" :size="28" />
</el-upload>
@ -46,18 +46,21 @@
</template>
<script setup lang="ts" name="sysInfoSetting">
import { nextTick, onMounted, reactive } from 'vue';
import { getAPI } from '/@/utils/axios-utils';
import { SysConfigApi } from '/@/api-services';
import { ElMessage } from 'element-plus';
import { nextTick, reactive, ref } from 'vue';
import { ElMessage, UploadInstance } from 'element-plus';
import { fileToBase64 } from '/@/utils/base64Conver';
import { getAPI } from '/@/utils/axios-utils';
import { SysConfigApi } from '/@/api-services';
const uploadRef = ref<UploadInstance>();
const state = reactive({
isLoading: false,
file: undefined as any,
formData: {
sysLogoBlob: undefined,
sysLogo: '',
sysLogoFileName: '',
sysTitle: '',
sysViceTitle: '',
sysViceDesc: '',
@ -68,10 +71,49 @@ const state = reactive({
},
});
//
onMounted(async () => {
loadData();
// onChange
const handleUploadChange = (file: any) => {
uploadRef.value!.clearFiles();
state.file = file;
state.formData.sysLogo = URL.createObjectURL(state.file.raw); // logo
};
//
const onSave = async () => {
// base64
let sysLogoBase64 = '';
let sysLogoFileName = '';
if (state.file) {
sysLogoBase64 = (await fileToBase64(state.file.raw)) as string;
sysLogoFileName = state.file.raw.name;
}
try {
state.isLoading = true;
const res = await getAPI(SysConfigApi).apiSysConfigSaveSysInfoPost({
sysLogoBase64: sysLogoBase64,
sysLogoFileName: sysLogoFileName,
sysTitle: state.formData.sysTitle,
sysViceTitle: state.formData.sysViceTitle,
sysViceDesc: state.formData.sysViceDesc,
sysWatermark: state.formData.sysWatermark,
sysCopyright: state.formData.sysCopyright,
sysIcp: state.formData.sysIcp,
sysIcpUrl: state.formData.sysIcpUrl,
});
if (res.data!.type !== 'success') return;
// file
state.file = undefined;
await loadData();
ElMessage.success('保存成功');
} finally {
nextTick(() => {
state.isLoading = false;
});
}
};
//
const loadData = async () => {
@ -84,6 +126,7 @@ const loadData = async () => {
state.formData = {
sysLogoBlob: undefined,
sysLogo: result.sysLogo,
sysLogoFileName: '',
sysTitle: result.sysTitle,
sysViceTitle: result.sysViceTitle,
sysViceDesc: result.sysViceDesc,
@ -99,48 +142,7 @@ const loadData = async () => {
}
};
// onChange
const handleUploadChange = (file: any) => {
state.file = file;
// sysLogo
state.formData.sysLogo = URL.createObjectURL(state.file.raw);
};
//
const onSave = async () => {
// base64
let sysLogoBase64 = '';
if (state.file) {
sysLogoBase64 = (await fileToBase64(state.file.raw)) as string;
}
try {
state.isLoading = true;
const res = await getAPI(SysConfigApi).apiSysConfigSaveSysInfoPost({
sysLogoBase64: sysLogoBase64,
sysTitle: state.formData.sysTitle,
sysViceTitle: state.formData.sysViceTitle,
sysViceDesc: state.formData.sysViceDesc,
sysWatermark: state.formData.sysWatermark,
sysCopyright: state.formData.sysCopyright,
sysIcp: state.formData.sysIcp,
sysIcpUrl: state.formData.sysIcpUrl,
});
if (res.data!.type !== 'success') return;
// file
state.file = undefined;
await loadData();
ElMessage.success('保存成功');
//
window.location.reload();
} finally {
nextTick(() => {
state.isLoading = false;
});
}
};
loadData();
</script>
<style lang="scss" scoped>
@ -148,6 +150,7 @@ const onSave = async () => {
width: 100px;
height: 100px;
display: block;
object-fit: contain;
}
:deep(.avatar-uploader) .el-upload {

View File

@ -5,7 +5,7 @@ import { getToken } from '/@/utils/axios-utils';
// 初始化SignalR对象
const connection = new SignalR.HubConnectionBuilder()
.configureLogging(SignalR.LogLevel.Information)
.withUrl(`${window.__env__.VITE_API_URL}/hubs/onlineUser?access_token=${getToken()}`, { transport: SignalR.HttpTransportType.WebSockets, skipNegotiation: true })
.withUrl(`${window.__env__.VITE_API_URL}/hubs/onlineUser?token=${getToken()}`, { transport: SignalR.HttpTransportType.WebSockets, skipNegotiation: true })
.withAutomaticReconnect({
nextRetryDelayInMilliseconds: () => {
return 5000; // 每5秒重连一次
@ -20,12 +20,10 @@ connection.serverTimeoutInMilliseconds = 30 * 60 * 1000; // 超时时间30m
connection.start().then(() => {
console.log('启动连接');
});
// 断开连接
connection.onclose(async () => {
console.log('断开连接');
});
// 重连中
connection.onreconnecting(() => {
ElNotification({
@ -35,7 +33,6 @@ connection.onreconnecting(() => {
position: 'bottom-right',
});
});
// 重连成功
connection.onreconnected(() => {
console.log('重连成功');
@ -43,20 +40,4 @@ connection.onreconnected(() => {
connection.on('OnlineUserList', () => {});
// 接收消息
connection.on('ReceiveMessage', (message: any) => {
var tmpMsg = `${message.message}<br/>`;
tmpMsg += `<p style="color:#808080; font-size:12px">发送人员:${message.sendUserName}<p>`;
tmpMsg += `<p style="color:#808080; font-size:12px">发送时间:${message.sendTime}<p>`;
ElNotification({
title: `消息【${message.title}`,
message: tmpMsg,
type: 'info',
position: 'top-right',
dangerouslyUseHTMLString: true,
duration: 0,
});
});
export { connection as signalR };