From bc459eddf484578562452dba14c1508fe855d29b Mon Sep 17 00:00:00 2001 From: sanji Date: Mon, 23 Oct 2023 10:25:40 +0800 Subject: [PATCH] init --- SiNan.API/Program.cs | 46 ++++++++++++++++++++------------- SiNan.Business/BaseBusiness.cs | 19 ++++++++++++++ SiNan.Business/GOIBusiness.cs | 16 ++++++++++++ SiNan.Common/Log/NLogManager.cs | 2 +- 4 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 SiNan.Business/BaseBusiness.cs create mode 100644 SiNan.Business/GOIBusiness.cs diff --git a/SiNan.API/Program.cs b/SiNan.API/Program.cs index bdf498b..3b27e59 100644 --- a/SiNan.API/Program.cs +++ b/SiNan.API/Program.cs @@ -1,14 +1,15 @@ +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.IdentityModel.Tokens; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Serialization; using SiNan.API.Filters; +using SiNan.API.Middlewares; using SiNan.Business; using SiNan.Common.Http; using SiNan.Common.Log; -using Yitter.IdGenerator; -using Newtonsoft.Json.Serialization; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.IdentityModel.Tokens; -using System.Text; -using Microsoft.OpenApi.Models; using System.Reflection; +using System.Text; +using Yitter.IdGenerator; var builder = WebApplication.CreateBuilder(args); var services = builder.Services; @@ -127,21 +128,30 @@ services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer( var app = builder.Build(); +app.UseMiddleware(); +app.UseRouting(); +app.UseCors("cors"); +app.UseMiddleware(); +app.UseAuthorization(); +app.MapControllers(); + +app.Run(); + // Configure the HTTP request pipeline. -if (!app.Environment.IsDevelopment()) -{ - app.UseExceptionHandler("/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); -} +//if (!app.Environment.IsDevelopment()) +//{ +// app.UseExceptionHandler("/Error"); +// // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. +// app.UseHsts(); +//} -app.UseHttpsRedirection(); -app.UseStaticFiles(); +//app.UseHttpsRedirection(); +//app.UseStaticFiles(); -app.UseRouting(); +//app.UseRouting(); -app.UseAuthorization(); +//app.UseAuthorization(); -app.MapRazorPages(); +//app.MapRazorPages(); -app.Run(); +//app.Run(); diff --git a/SiNan.Business/BaseBusiness.cs b/SiNan.Business/BaseBusiness.cs new file mode 100644 index 0000000..6ae7f49 --- /dev/null +++ b/SiNan.Business/BaseBusiness.cs @@ -0,0 +1,19 @@ +using SiNan.Common.Log; +using Yitter.IdGenerator; + +namespace SiNan.Business +{ + public class BaseBusiness + { + protected IFreeSql fsql; + protected NLogManager nLogManager; + protected IIdGenerator idGenerator; + + public BaseBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) + { + this.fsql = fsql; + this.nLogManager = nLogManager; + this.idGenerator = idGenerator; + } + } +} diff --git a/SiNan.Business/GOIBusiness.cs b/SiNan.Business/GOIBusiness.cs new file mode 100644 index 0000000..6e94e82 --- /dev/null +++ b/SiNan.Business/GOIBusiness.cs @@ -0,0 +1,16 @@ +using SiNan.Common.Log; +using SiNan.Common.Models; +using Yitter.IdGenerator; + +namespace SiNan.Business +{ + public class GOIBusiness : BaseBusiness, IDenpendency + { + private FreeSqlMultiDBManager freeSqlMultiDBManager; + public GOIBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager freeSqlMultiDBManager) : base(fsql, nLogManager, idGenerator) + { + this.freeSqlMultiDBManager = freeSqlMultiDBManager; + } + + } +} diff --git a/SiNan.Common/Log/NLogManager.cs b/SiNan.Common/Log/NLogManager.cs index 698aede..68c4054 100644 --- a/SiNan.Common/Log/NLogManager.cs +++ b/SiNan.Common/Log/NLogManager.cs @@ -1,7 +1,7 @@ using NLog; using System.Collections.Concurrent; -namespace BBWYB.Common.Log +namespace SiNan.Common.Log { public class NLogManager {