feat: 修复雪花id问题

This commit is contained in:
橙子
2023-03-11 15:02:50 +08:00
parent 9166fc50aa
commit 9593b68d33
19 changed files with 173 additions and 26 deletions

View File

@@ -1,16 +1,22 @@
using AspNetCore.Microsoft.AspNetCore.Hosting;
using AspNetCore.Microsoft.AspNetCore.Hosting;
using Yi.Framework.Core.Autofac.Extensions;
using Yi.Framework.Core.Autofac.Modules;
using Yi.Framework.Core.Extensions;
using Yi.BBS.Web;
using Yi.Framework.Core.Module;
using NLog.Extensions.Logging;
using NLog;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
Logger? _logger = LogManager.Setup().LoadConfigurationFromAssemblyResource(typeof(Program).Assembly).GetCurrentClassLogger();
_logger.Info("-----( ¯ □ ¯ )YiFrameowrk框架启动-----");
builder.WebHost.UseStartUrlsServer(builder.Configuration);
builder.UseYiModules(typeof(YiBBSWebModule));
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>autofacģ<EFBFBD><EFBFBD>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
//添加autofac模块,需要添加模块
builder.Host.ConfigureAutoFacContainer(container =>
{
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);

View File

@@ -15,6 +15,12 @@
<ProjectReference Include="..\Yi.BBS.Sqlsugar\Yi.BBS.Sqlsugar.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="key.pem">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@@ -12,6 +12,7 @@ using Yi.Framework.AspNetCore;
using Yi.Framework.Data.Json;
using Yi.Framework.OperLogManager;
using Yi.Framework.Core.Module;
using Microsoft.Extensions.Options;
namespace Yi.BBS.Web
{
@@ -28,7 +29,8 @@ namespace Yi.BBS.Web
//添加控制器与动态api
services.AddControllers().AddJsonOptions(opt => {
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
});
opt.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
});
services.AddAutoApiService(opt =>
{

View File

@@ -2,7 +2,7 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Information"
}
},
"AllowedHosts": "*",

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off">
<variable name="archiveAboveSize" value="10485760"/>
<variable name="maxArchiveFiles" value="50"/>
<variable name="layout" value="${date:format=HH\:mm\:ss.fff}|${level}|${threadId:format=threadId}|${logger}${newline}>>${message} ${exception:format=tostring}"/>
<variable name="logsRootPath" value="${basedir}/logs/${shortdate}" />
<targets>
<target xsi:type="File"
name="AllFile"
fileName="${logsRootPath}/AllFile/log.log"
layout="${layout}${newline}"
archiveAboveSize="${archiveAboveSize}"
maxArchiveFiles="${maxArchiveFiles}" />
<target xsi:type="ColoredConsole"
name="ColoredConsole"
layout="${layout}${newline}">
<highlight-row condition="level == LogLevel.Info" foregroundColor="White" />
<highlight-row condition="level == LogLevel.Debug" foregroundColor="Green" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
</target>
<target xsi:type="File" name="OwnFile"
fileName="${logsRootPath}/OwnFile/log.log"
layout="${layout}|Url: ${aspnet-request-url}|Action: ${aspnet-mvc-action}${newline}"
archiveAboveSize="${archiveAboveSize}"
maxArchiveFiles="${maxArchiveFiles}" />
</targets>
<rules>
<logger name="Quartz.*" maxlevel="Warn" final="true" />
<logger name="Grpc.*" maxlevel="Debug" final="true" />
<logger name="Grpc.*" maxlevel="Trace" final="true" />
<logger name="Microsoft.EntityFrameworkCore.*" maxlevel="Warn" final="true" />
<logger name="Microsoft.AspNetCore.*" maxlevel="Warn" final="true" />
<logger name="Microsoft.AspNetCore.SignalR.*" maxlevel="Warn" final="true" />
<logger name="*" minlevel="Information" maxlevel="Fatal" writeTo="AllFile,ColoredConsole"/>
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="ColoredConsole,OwnFile" final="true" />
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<logger name="*" minlevel="Trace" writeTo="OwnFile" />
</rules>
</nlog>

View File

@@ -1,16 +1,22 @@
using AspNetCore.Microsoft.AspNetCore.Hosting;
using AspNetCore.Microsoft.AspNetCore.Hosting;
using Yi.Framework.Core.Autofac.Extensions;
using Yi.Framework.Core.Autofac.Modules;
using Yi.Framework.Core.Extensions;
using Yi.BBS.Web;
using Yi.Framework.Core.Module;
using NLog.Extensions.Logging;
using NLog;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLogging(builder => { builder.ClearProviders().AddNLog("nlog.config").SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); });
Logger? _logger = LogManager.Setup().LoadConfigurationFromAssemblyResource(typeof(Program).Assembly).GetCurrentClassLogger();
_logger.Info("-----( ¯ □ ¯ )YiFrameowrk框架启动-----");
builder.WebHost.UseStartUrlsServer(builder.Configuration);
builder.UseYiModules(typeof(YiBBSWebModule));
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD>autofacģ<EFBFBD><EFBFBD>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
//添加autofac模块,需要添加模块
builder.Host.ConfigureAutoFacContainer(container =>
{
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, ModuleAssembly.Assemblies);

View File

@@ -15,6 +15,12 @@
<ProjectReference Include="..\Yi.BBS.Sqlsugar\Yi.BBS.Sqlsugar.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="key.pem">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@@ -12,6 +12,7 @@ using Yi.Framework.AspNetCore;
using Yi.Framework.Data.Json;
using Yi.Framework.OperLogManager;
using Yi.Framework.Core.Module;
using Microsoft.Extensions.Options;
namespace Yi.BBS.Web
{
@@ -28,7 +29,8 @@ namespace Yi.BBS.Web
//添加控制器与动态api
services.AddControllers().AddJsonOptions(opt => {
opt.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
});
opt.JsonSerializerOptions.Converters.Add(new LongToStringConverter());
});
services.AddAutoApiService(opt =>
{

View File

@@ -2,7 +2,7 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft.AspNetCore": "Information"
}
},
"AllowedHosts": "*",