修复枚举类型在mysql中类型出错的问题
This commit is contained in:
@@ -49,7 +49,6 @@
|
||||
{
|
||||
_sysCacheService.Set(CacheConst.Cache_SysUser, sysUser.Id.ToString(), sysUser); //更新Cache信息
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
@@ -33,7 +33,7 @@
|
||||
if (relations.Count > 0)
|
||||
{
|
||||
var userIds = relations.Select(it => it.ObjectId).ToList();//用户ID列表
|
||||
// 解析用户服务
|
||||
// 解析用户服务
|
||||
var userService = scope.ServiceProvider.GetRequiredService<ISysUserService>();
|
||||
//从缓存中删除
|
||||
userService.DeleteUserFromCache(userIds);
|
||||
|
@@ -45,7 +45,6 @@
|
||||
{
|
||||
_sysCacheService.Set(CacheConst.Cache_OpenApiUser, openApiUser.Id.ToString(), openApiUser); //更新Cache信息
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,6 @@
|
||||
namespace ThingsGateway.Core
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
namespace ThingsGateway.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源
|
||||
@@ -36,7 +38,7 @@
|
||||
/// <summary>
|
||||
/// 分类
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Category", ColumnDescription = "分类", Length = 200)]
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnName = "Category", ColumnDescription = "分类", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public MenuCategoryEnum Category { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
@@ -65,7 +67,7 @@
|
||||
/// <summary>
|
||||
/// 跳转类型
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "TargetType", ColumnDescription = "跳转类型", Length = 200, IsNullable = true)]
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnName = "TargetType", ColumnDescription = "跳转类型", SqlParameterDbType = typeof(EnumToStringConvert), IsNullable = true)]
|
||||
public virtual TargetTypeEnum TargetType { get; set; }
|
||||
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ namespace ThingsGateway.Core
|
||||
});
|
||||
});
|
||||
//注入sqlsugar服务
|
||||
SqlsugarSetup.AddSqlSugar();
|
||||
SqlSugarSetup.InitSqlSugar();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -7,13 +7,13 @@ namespace ThingsGateway.Core
|
||||
/// <summary>
|
||||
/// SqlSugar设置启动
|
||||
/// </summary>
|
||||
public static class SqlsugarSetup
|
||||
public static class SqlSugarSetup
|
||||
{
|
||||
/// <summary>
|
||||
/// 注入Sqlsugar
|
||||
/// </summary>
|
||||
/// <param name="services"></param>
|
||||
public static void AddSqlSugar()
|
||||
public static void InitSqlSugar()
|
||||
{
|
||||
//services.AddSingleton<ISqlSugarClient>(DbContext.Db); // 单例注册,不用工作单元不需要注入
|
||||
//services.AddUnitOfWork<SqlSugarUnitOfWork>(); // 事务与工作单元注册
|
||||
|
@@ -23,6 +23,32 @@
|
||||
"IsSeedData": true, //是否初始化种子数据
|
||||
"IsUpdateSeedData": false
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
|
||||
//"Sqlsugar": [
|
||||
// {
|
||||
// "ConfigId": "Default", //租户ID
|
||||
// "ConnectionString": "Data Source=./Default1.db;", //连接字符串
|
||||
// "DbType": "Sqlite", //数据库类型
|
||||
// "IsAutoCloseConnection": false, //是否自动释放
|
||||
// "IsInitDb": true, //是否初始化数据库,适用于codefirst
|
||||
// "IsUnderLine": false, //是否驼峰转下划线
|
||||
// "IsSeedData": true, //是否初始化种子数据
|
||||
// "IsUpdateSeedData": false
|
||||
// },
|
||||
// {
|
||||
// "ConfigId": "ThingsGateway", //租户ID
|
||||
// "ConnectionString": "Data Source=./ThingsGateway1.db", //连接字符串
|
||||
// "DbType": "Sqlite", //数据库类型
|
||||
// "IsAutoCloseConnection": true, //是否自动释放
|
||||
// "IsInitDb": true, //是否初始化数据库,适用于codefirst
|
||||
// "IsUnderLine": false, //是否驼峰转下划线
|
||||
// "IsSeedData": true, //是否初始化种子数据
|
||||
// "IsUpdateSeedData": false
|
||||
// }
|
||||
|
||||
//]
|
||||
}
|
||||
}
|
@@ -2,20 +2,19 @@
|
||||
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
||||
namespace ThingsGateway.Web.Core
|
||||
{
|
||||
public class BlazorAuthorizeHandler : AppAuthorizeHandler
|
||||
{
|
||||
private IOpenApiUserService _openApiUserService;
|
||||
private SysCacheService _sysCacheService;
|
||||
private ISysUserService _sysUserService;
|
||||
|
||||
public BlazorAuthorizeHandler(SysCacheService sysCacheService, ISysUserService sysUserService, IOpenApiUserService openApiUserService)
|
||||
private IServiceScope _serviceScope;
|
||||
public BlazorAuthorizeHandler(SysCacheService sysCacheService,IServiceScopeFactory serviceScopeFactory)
|
||||
{
|
||||
_sysCacheService = sysCacheService;
|
||||
_openApiUserService = openApiUserService;
|
||||
_sysUserService = sysUserService;
|
||||
_serviceScope = serviceScopeFactory.CreateScope();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(AuthorizationHandlerContext context)
|
||||
@@ -56,11 +55,14 @@ namespace ThingsGateway.Web.Core
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext)
|
||||
{
|
||||
//这里鉴别密码是否改变
|
||||
var userId = context.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.UserId).Value.ToLong();
|
||||
|
||||
//这里鉴别密码是否改变
|
||||
var userId = context.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.UserId).Value.ToLong();
|
||||
var isOpenApi = context.User.Claims.FirstOrDefault(it => it.Type == ClaimConst.IsOpenApi)?.Value?.ToBoolean(false) == true;
|
||||
if (isOpenApi)
|
||||
{
|
||||
|
||||
var _openApiUserService = _serviceScope.ServiceProvider.GetService<OpenApiUserService>();
|
||||
var user = await _openApiUserService.GetUsertById(userId);
|
||||
if (user == null) { return false; }
|
||||
// 此处已经自动验证 Jwt Verificat的有效性了,无需手动验证
|
||||
@@ -71,10 +73,12 @@ namespace ThingsGateway.Web.Core
|
||||
if (isRolePermission == null || user.PermissionCodeList?.Contains(routeName) == true)//如果当前路由信息不包含在角色授权路由列表中则认证失败
|
||||
return true;
|
||||
else
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var _sysUserService = _serviceScope.ServiceProvider.GetService<SysUserService>();
|
||||
var user = await _sysUserService.GetUsertById(userId);
|
||||
if (user == null) { return false; }
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Configuration\App.json" />
|
||||
<None Remove="Configuration\Database - 复制.json" />
|
||||
<None Remove="Configuration\Database.json" />
|
||||
<None Remove="Configuration\IpRateLimiting.json" />
|
||||
<None Remove="Configuration\JWT.json" />
|
||||
@@ -23,6 +24,11 @@
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Configuration\Database - 复制.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="Configuration\Database.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
|
@@ -1,4 +1,6 @@
|
||||
using ThingsGateway.Core;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
using ThingsGateway.Core;
|
||||
|
||||
namespace ThingsGateway.Web.Foundation;
|
||||
/// <summary>
|
||||
@@ -21,7 +23,7 @@ public class DriverPlugin : BaseEntity
|
||||
/// <summary>
|
||||
/// 插件类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "DriverTypeEnum", ColumnDescription = "插件类型")]
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnName = "DriverTypeEnum", ColumnDescription = "插件类型", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public DriverEnum DriverTypeEnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@@ -1,5 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
using ThingsGateway.Core;
|
||||
|
||||
namespace ThingsGateway.Web.Foundation
|
||||
@@ -19,7 +21,7 @@ namespace ThingsGateway.Web.Foundation
|
||||
/// <summary>
|
||||
/// 日志级别
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "LogLevel", ColumnDescription = "日志级别", IsNullable = false)]
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnName = "LogLevel", ColumnDescription = "日志级别", SqlParameterDbType = typeof(EnumToStringConvert), IsNullable = false)]
|
||||
public LogLevel LogLevel { get; set; }
|
||||
/// <summary>
|
||||
/// 日志来源
|
||||
|
@@ -19,7 +19,7 @@ else
|
||||
<MSheet Elevation=1 Style="width:100%; height:100%;" Class="d-flex align-start flex-column mb-6">
|
||||
<div class="d-flex align-center ml-12 mt-12">
|
||||
<MAvatar Size="40" Color="teal">
|
||||
<span class="white--text text-h6">@SYS_DEFAULT_TITLE.GetNameLen2()</span>
|
||||
<span class="white--text text-h6">@SYS_DEFAULT_TITLE?.GetNameLen2()</span>
|
||||
</MAvatar>
|
||||
<h1>@SYS_DEFAULT_TITLE</h1>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user