feat:完成furion改造
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yi.Framework.Infrastructure.Data.Entities;
|
||||
using Yi.Framework.Infrastructure.Data.Filters;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Data
|
||||
{
|
||||
public static class DataFilterExtensions
|
||||
{
|
||||
public static IApplicationBuilder UseDataFiterServer(this IApplicationBuilder builder)
|
||||
{
|
||||
return builder.UseMiddleware<DataFilterMiddleware>();
|
||||
}
|
||||
}
|
||||
|
||||
public class DataFilterMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
private readonly ILogger<DataFilterMiddleware> _logger;
|
||||
public DataFilterMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
|
||||
{
|
||||
_next = next;
|
||||
_logger = loggerFactory.CreateLogger<DataFilterMiddleware>();
|
||||
}
|
||||
public async Task InvokeAsync(HttpContext context, IDataFilter dataFilter)
|
||||
{
|
||||
//添加默认的过滤器
|
||||
dataFilter.AddFilter<ISoftDelete>(u => u.IsDeleted == false);
|
||||
//dataFilter.AddFilter<IMultiTenant>(u => u.TenantId == Guid.Empty);
|
||||
await _next(context);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Data.Json
|
||||
{
|
||||
public class DateTimeJsonConverter : JsonConverter<DateTime>
|
||||
{
|
||||
private readonly string Format;
|
||||
public DateTimeJsonConverter(string format)
|
||||
{
|
||||
Format = format;
|
||||
}
|
||||
public override void Write(Utf8JsonWriter writer, DateTime date, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(date.ToString(Format));
|
||||
}
|
||||
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return DateTime.ParseExact(reader.GetString(), Format, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Buffers.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Yi.Framework.Infrastructure.Data.Json
|
||||
{
|
||||
/// <summary>
|
||||
/// 长整形转字符串
|
||||
/// </summary>
|
||||
public class LongToStringConverter : JsonConverter<long>
|
||||
{
|
||||
public override long Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
ReadOnlySpan<byte> span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan;
|
||||
if (Utf8Parser.TryParse(span, out long number, out int bytesConsumed) && span.Length == bytesConsumed)
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
||||
if (long.TryParse(reader.GetString(), out number))
|
||||
{
|
||||
return number;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return reader.GetInt64();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, long value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using StackExchange.Profiling.SqlFormatters;
|
||||
using Yi.Framework.Infrastructure.AspNetCore;
|
||||
using Yi.Framework.Infrastructure.Data;
|
||||
using Yi.Framework.Infrastructure.Data.Filters;
|
||||
using Yi.Framework.Infrastructure.Sqlsugar;
|
||||
using Yi.Framework.Infrastructure.Sqlsugar.Filters;
|
||||
@@ -29,6 +30,6 @@ public class Startup : AppStartup
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
|
||||
app.UseDataFiterServer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.Extensions.Hosting;
|
||||
using Yi.Framework.Infrastructure.AspNetCore;
|
||||
using Yi.Framework.Infrastructure.Sqlsugar;
|
||||
using Yi.Framework.Module.ImageSharp.HeiCaptcha;
|
||||
using Yi.Framework.Module.Sms.Aliyun;
|
||||
|
||||
namespace Yi.Framework.Module;
|
||||
|
||||
@@ -20,6 +21,8 @@ public class Startup : AppStartup
|
||||
services.AddDbSqlsugarContextServer();
|
||||
|
||||
services.AddHeiCaptcha();
|
||||
|
||||
services.Configure<SmsAliyunOptions>(App.Configuration.GetSection("SmsAliyunOptions"));
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
||||
@@ -55,10 +55,9 @@ namespace Yi.Furion.Application.Bbs.Services.Impl
|
||||
User = new UserGetListOutputDto() { UserName = user.UserName, Nick = user.Nick, Icon = user.Icon }
|
||||
}, true).SingleAsync(discuss => discuss.Id == id);
|
||||
|
||||
await VerifyDiscussPermissionAsync(item.Id);
|
||||
|
||||
if (item is not null)
|
||||
{
|
||||
await VerifyDiscussPermissionAsync(item.Id);
|
||||
_eventPublisher.PublishAsync(new SeeDiscussEventSource(new SeeDiscussEventArgs { DiscussId = item.Id, OldSeeNum = item.SeeNum }));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Yi.Framework.Infrastructure.Data.Json;
|
||||
using Yi.Furion.Web.Core.Handlers;
|
||||
|
||||
namespace Yi.Furion.Web.Core;
|
||||
@@ -16,7 +17,10 @@ public class Startup : AppStartup
|
||||
|
||||
services.AddCorsAccessor();
|
||||
|
||||
services.AddControllers().AddInjectWithUnifyResult();
|
||||
services.AddControllers().AddInjectWithUnifyResult().AddJsonOptions(x => {
|
||||
//x.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
|
||||
x.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
|
||||
});
|
||||
|
||||
services.AddEventBus();
|
||||
|
||||
|
||||
12
Yi.Furion.Net6/Yi.Furion.Web.Entry/.config/dotnet-tools.json
Normal file
12
Yi.Furion.Net6/Yi.Furion.Web.Entry/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "7.0.5",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,14 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\File\" />
|
||||
<Folder Include="wwwroot\Image\" />
|
||||
<Folder Include="wwwroot\Thumbnail\" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<UserProperties properties_4launchsettings_1json__JsonSchema="" />
|
||||
|
||||
@@ -37,5 +37,13 @@
|
||||
"ExpiredTime": 20, // 过期时间,long 类型,单位分钟,默认20分钟
|
||||
"ClockSkew": 5, // 过期时间容错值,long 类型,单位秒,默认 5秒
|
||||
"Algorithm": "HS256" // 加密算法,string 类型,默认 HS256
|
||||
},
|
||||
//阿里云短信
|
||||
"SmsAliyunOptions": {
|
||||
"AccessKeyId": "",
|
||||
"AccessKeySecret": "",
|
||||
"SignName": "",
|
||||
"TemplateCode": "",
|
||||
"EnableFeature": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user