爆肝,重构框架,你懂得
This commit is contained in:
@@ -7,7 +7,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
public static class AuthorizationExtension
|
||||
{
|
||||
@@ -12,15 +12,15 @@ using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Attribute;
|
||||
using Yi.Framework.Uow.Interceptors;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
public static class AutoIocExtend
|
||||
{
|
||||
private static void RegIoc(ContainerBuilder build, Assembly assembly)
|
||||
{
|
||||
foreach (var type in assembly.GetTypes())
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
var serviceAttribute = type.GetCustomAttribute<AppServiceAttribute>();
|
||||
if (serviceAttribute is not null)
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.WebCore.Mapper;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用autoMapper扩展
|
||||
@@ -7,8 +7,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
public static class CAPExtend
|
||||
{
|
||||
@@ -19,10 +20,11 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
services.AddCap(x =>
|
||||
{
|
||||
x.UseMySql(Appsettings.app("DbConn", "WriteUrl"));
|
||||
|
||||
x.UseRabbitMQ(optios => {
|
||||
|
||||
x.UseRabbitMQ(optios =>
|
||||
{
|
||||
optios.HostName = Appsettings.app("RabbitConn", "HostName");
|
||||
optios.Port =Convert.ToInt32(Appsettings.app("RabbitConn", "Port"));
|
||||
optios.Port = Convert.ToInt32(Appsettings.app("RabbitConn", "Port"));
|
||||
optios.UserName = Appsettings.app("RabbitConn", "UserName");
|
||||
optios.Password = Appsettings.app("RabbitConn", "Password");
|
||||
|
||||
@@ -4,10 +4,10 @@ using Microsoft.OpenApi.Models;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Cache;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Redis扩展
|
||||
@@ -16,9 +16,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static IServiceCollection AddCacheService(this IServiceCollection services)
|
||||
{
|
||||
var cacheSelect= Appsettings.app("CacheSelect");
|
||||
var cacheSelect = Appsettings.app("CacheSelect");
|
||||
|
||||
switch (cacheSelect) {
|
||||
switch (cacheSelect)
|
||||
{
|
||||
case "Redis":
|
||||
services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConnOptions"));
|
||||
services.AddSingleton<CacheInvoker, RedisCacheClient>();
|
||||
@@ -26,7 +27,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
case "MemoryCache":
|
||||
services.AddSingleton<CacheInvoker, MemoryCacheClient>();
|
||||
break;
|
||||
default:throw new ArgumentException("CacheSelect配置填的是什么东西?俺不认得");
|
||||
default: throw new ArgumentException("CacheSelect配置填的是什么东西?俺不认得");
|
||||
}
|
||||
return services;
|
||||
}
|
||||
@@ -8,14 +8,15 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Cache;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
public static class CacheInitExtend
|
||||
public static class CacheInitExtend
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CacheInitExtend));
|
||||
public static void UseRedisSeedInitService(this IApplicationBuilder app )
|
||||
public static void UseRedisSeedInitService(this IApplicationBuilder app)
|
||||
{
|
||||
|
||||
if (Appsettings.appBool("CacheSeed_Enabled"))
|
||||
@@ -5,8 +5,9 @@ using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 注册ConsulRegisterService 这个servcie在app启动的时候会自动注册服务信息
|
||||
@@ -23,16 +24,16 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
}
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var httpPort = this._consulRegisterOptions.Port;
|
||||
var httpPort = _consulRegisterOptions.Port;
|
||||
//var grpcPort = Convert.ToInt32(Appsettings.app("GrpcPort"));
|
||||
//------------------Http------------------
|
||||
using (ConsulClient client = new ConsulClient(c =>
|
||||
{
|
||||
c.Address = new Uri($"http://{this._consulClientOptions.IP}:{this._consulClientOptions.Port}/");
|
||||
c.Datacenter = this._consulClientOptions.Datacenter;
|
||||
c.Address = new Uri($"http://{_consulClientOptions.IP}:{_consulClientOptions.Port}/");
|
||||
c.Datacenter = _consulClientOptions.Datacenter;
|
||||
}))
|
||||
{
|
||||
var serviceId = $"{this._consulRegisterOptions.IP}:{httpPort}-{this._consulRegisterOptions.GroupName}";
|
||||
var serviceId = $"{_consulRegisterOptions.IP}:{httpPort}-{_consulRegisterOptions.GroupName}";
|
||||
|
||||
await client.Agent.ServiceDeregister(serviceId, cancellationToken);
|
||||
|
||||
@@ -41,18 +42,18 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
await client.Agent.ServiceRegister(new AgentServiceRegistration()
|
||||
{
|
||||
ID = serviceId,//唯一Id
|
||||
Name = this._consulRegisterOptions.GroupName,//组名称-Group
|
||||
Address = this._consulRegisterOptions.IP,
|
||||
Name = _consulRegisterOptions.GroupName,//组名称-Group
|
||||
Address = _consulRegisterOptions.IP,
|
||||
Port = httpPort,
|
||||
Tags = new string[] { "Http" },
|
||||
Check = new AgentServiceCheck()
|
||||
{
|
||||
Interval = TimeSpan.FromSeconds(this._consulRegisterOptions.Interval),
|
||||
Interval = TimeSpan.FromSeconds(_consulRegisterOptions.Interval),
|
||||
HTTP = $"http://{_consulRegisterOptions.IP}:{httpPort}/Health",
|
||||
//GRPC = $"{this._consulRegisterOptions.IP}:{grpcPort}",//gRPC特有
|
||||
GRPCUseTLS = false,//支持http
|
||||
Timeout = TimeSpan.FromSeconds(this._consulRegisterOptions.Timeout),
|
||||
DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(this._consulRegisterOptions.DeregisterCriticalServiceAfter),
|
||||
Timeout = TimeSpan.FromSeconds(_consulRegisterOptions.Timeout),
|
||||
DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(_consulRegisterOptions.DeregisterCriticalServiceAfter),
|
||||
|
||||
}
|
||||
});
|
||||
@@ -71,7 +72,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
// await client.Agent.ServiceDeregister(serviceId, cancellationToken);
|
||||
|
||||
// Console.WriteLine($"开始向Consul注册Grpc[{serviceId}]服务 ...");
|
||||
|
||||
|
||||
// await client.Agent.ServiceRegister(new AgentServiceRegistration()
|
||||
// {
|
||||
// ID = serviceId,//唯一Id
|
||||
@@ -100,18 +101,19 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
/// <returns></returns>
|
||||
public async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var httpPort = this._consulRegisterOptions.Port;
|
||||
var httpPort = _consulRegisterOptions.Port;
|
||||
//var grpcPort = Appsettings.app<int>("GrpcPort");
|
||||
|
||||
|
||||
using (ConsulClient client = new ConsulClient(c =>
|
||||
{
|
||||
c.Address = new Uri($"http://{this._consulClientOptions.IP}:{this._consulClientOptions.Port}/");
|
||||
c.Datacenter = this._consulClientOptions.Datacenter;
|
||||
})) {
|
||||
c.Address = new Uri($"http://{_consulClientOptions.IP}:{_consulClientOptions.Port}/");
|
||||
c.Datacenter = _consulClientOptions.Datacenter;
|
||||
}))
|
||||
{
|
||||
|
||||
|
||||
var serviceId = $"{this._consulRegisterOptions.GroupName}:{this._consulRegisterOptions.IP}-{httpPort}";
|
||||
var serviceId = $"{_consulRegisterOptions.GroupName}:{_consulRegisterOptions.IP}-{httpPort}";
|
||||
|
||||
//var grpcServiceId = $"{this._consulRegisterOptions.GrpcGroupName}:{this._consulRegisterOptions.IP}-{grpcPort}";
|
||||
|
||||
@@ -120,7 +122,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
Console.WriteLine($"开始Consul注销[{serviceId}]服务 ...");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// HTTP模式
|
||||
@@ -2,8 +2,9 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用跨域扩展
|
||||
@@ -5,8 +5,9 @@ using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Redis扩展
|
||||
@@ -6,8 +6,9 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 健康检测扩展
|
||||
@@ -6,8 +6,9 @@ using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Model;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用跨域扩展
|
||||
@@ -11,8 +11,9 @@ using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用跨域扩展
|
||||
@@ -9,13 +9,13 @@ using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Language;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
public static class LocalizerExtend
|
||||
{
|
||||
public static IServiceCollection AddLocalizerService(this IServiceCollection services)
|
||||
{
|
||||
|
||||
|
||||
services.AddLocalization();
|
||||
return services;
|
||||
}
|
||||
@@ -7,9 +7,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Quartz;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 启动定时器服务,后台服务
|
||||
@@ -5,8 +5,9 @@ using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Redis扩展
|
||||
@@ -6,8 +6,9 @@ using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.SMS;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Redis扩展
|
||||
@@ -18,7 +19,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
if (Appsettings.appBool("SMS_Enabled"))
|
||||
{
|
||||
|
||||
|
||||
services.Configure<SMSOptions>(Appsettings.appConfiguration("SMS"));
|
||||
services.AddTransient<AliyunSMSInvoker>();
|
||||
}
|
||||
@@ -8,8 +8,9 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
public static class SqlsugarExtension
|
||||
{
|
||||
@@ -117,7 +118,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
}
|
||||
_logger?.LogInformation(sb.ToString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using IGeekFan.AspNetCore.Knife4jUI;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
@@ -7,7 +6,7 @@ using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.Models;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
namespace Yi.Framework.WebCore.AspNetCoreExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Swagger扩展
|
||||
@@ -20,7 +19,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
Title = title,
|
||||
Version = "v1",
|
||||
Contact = new OpenApiContact { Name = "橙子", Email = "454313500@qq.com", Url = new System.Uri("https://ccnetcore.com") }
|
||||
Contact = new OpenApiContact { Name = "橙子", Email = "454313500@qq.com", Url = new Uri("https://ccnetcore.com") }
|
||||
};
|
||||
#region 注册Swagger服务
|
||||
services.AddSwaggerGen(c =>
|
||||
@@ -12,7 +12,9 @@ using Yi.Framework.Common.Attribute;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.AttributeExtend
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@ using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.WebCore.AuthorizationPolicy
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Attribute;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Job;
|
||||
using Yi.Framework.Repository;
|
||||
|
||||
@@ -7,6 +7,7 @@ using Com.Ctrip.Framework.Apollo.Enums;
|
||||
using Com.Ctrip.Framework.Apollo.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using System.Reflection;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.BuilderExtend
|
||||
{
|
||||
|
||||
@@ -3,31 +3,30 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using Yi.Framework.WebCore.BuilderExtend.OptionsWritable;
|
||||
using Yi.Framework.WebCore.BuilderExtend.OptionsWritable.Internal;
|
||||
|
||||
namespace Yi.Framework.WebCore.BuilderExtend;
|
||||
namespace Yi.Framework.WebCore.BuilderExtend.OptionsWritable;
|
||||
|
||||
public static class OptionsWritableConfigurationServiceCollectionExtensions
|
||||
{
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, Microsoft.Extensions.Configuration.ConfigurationManager configuration, string jsonFilePath)
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, Microsoft.Extensions.Configuration.ConfigurationManager configuration, string jsonFilePath)
|
||||
where TOption : class, new()
|
||||
{
|
||||
ConfigureJson<TOption>(services, configuration.GetSection(typeof(TOption).Name), jsonFilePath);
|
||||
services.ConfigureJson<TOption>(configuration.GetSection(typeof(TOption).Name), jsonFilePath);
|
||||
}
|
||||
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, IConfigurationSection section, string jsonFilePath)
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, IConfigurationSection section, string jsonFilePath)
|
||||
where TOption : class, new()
|
||||
{
|
||||
services.Configure<TOption>(section);
|
||||
services.AddTransient<IOptionsWritable<TOption>>(provider =>
|
||||
services.AddTransient<IOptionsWritable<TOption>>(provider =>
|
||||
new JsonOptionsWritable<TOption>(provider.GetRequiredService<IOptionsMonitor<TOption>>(), section.Key, jsonFilePath));
|
||||
}
|
||||
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, Microsoft.Extensions.Configuration.ConfigurationManager configuration, Func<IServiceProvider, string> jsonFilePathFunc)
|
||||
where TOption : class, new()
|
||||
{
|
||||
ConfigureJson<TOption>(services, configuration.GetSection(typeof(TOption).Name), jsonFilePathFunc);
|
||||
services.ConfigureJson<TOption>(configuration.GetSection(typeof(TOption).Name), jsonFilePathFunc);
|
||||
}
|
||||
|
||||
public static void ConfigureJson<TOption>(this IServiceCollection services, IConfigurationSection section, Func<IServiceProvider, string> jsonFilePathFunc)
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Yi.Framework.WebCore
|
||||
namespace Yi.Framework.WebCore.CommonExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// appsettings.json操作类
|
||||
@@ -13,7 +13,7 @@ namespace Yi.Framework.WebCore
|
||||
{
|
||||
static IConfiguration? Configuration { get; set; }
|
||||
static string? contentPath { get; set; }
|
||||
|
||||
|
||||
public Appsettings(string contentPath)
|
||||
{
|
||||
string Path = "appsettings.json";
|
||||
@@ -44,7 +44,7 @@ namespace Yi.Framework.WebCore
|
||||
|
||||
if (sections.Any())
|
||||
{
|
||||
return Configuration?[string.Join(":", sections)];
|
||||
return Configuration?[string.Join(":", sections)];
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
@@ -54,8 +54,8 @@ namespace Yi.Framework.WebCore
|
||||
|
||||
public static bool appBool(params string[] sections)
|
||||
{
|
||||
|
||||
return Bool(app(sections));
|
||||
|
||||
return Bool(app(sections));
|
||||
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Models;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using UAParser;
|
||||
using IPTools.Core;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
|
||||
namespace Yi.Framework.WebCore
|
||||
namespace Yi.Framework.WebCore.CommonExtend
|
||||
{
|
||||
public static class HttpContextExtend
|
||||
{
|
||||
@@ -113,7 +113,7 @@ namespace Yi.Framework.WebCore
|
||||
/// <param name="fileName"></param>
|
||||
public static void FileInlineHandle(this HttpContext httpContext, string fileName)
|
||||
{
|
||||
string encodeFilename = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.GetEncoding("UTF-8"));
|
||||
string encodeFilename = System.Web.HttpUtility.UrlEncode(fileName, Encoding.GetEncoding("UTF-8"));
|
||||
httpContext.Response.Headers.Add("Content-Disposition", "inline;filename=" + encodeFilename);
|
||||
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace Yi.Framework.WebCore
|
||||
/// <param name="fileName"></param>
|
||||
public static void FileAttachmentHandle(this HttpContext httpContext, string fileName)
|
||||
{
|
||||
string encodeFilename = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.GetEncoding("UTF-8"));
|
||||
string encodeFilename = System.Web.HttpUtility.UrlEncode(fileName, Encoding.GetEncoding("UTF-8"));
|
||||
httpContext.Response.Headers.Add("Content-Disposition", "attachment;filename=" + encodeFilename);
|
||||
|
||||
}
|
||||
@@ -167,7 +167,7 @@ namespace Yi.Framework.WebCore
|
||||
}
|
||||
else
|
||||
{
|
||||
param = context.Request.QueryString.Value is null?"": context.Request.QueryString.Value.ToString();
|
||||
param = context.Request.QueryString.Value is null ? "" : context.Request.QueryString.Value.ToString();
|
||||
}
|
||||
return param;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace Yi.Framework.WebCore
|
||||
/// <returns></returns>
|
||||
public static ClientInfo GetClientInfo(this HttpContext context)
|
||||
{
|
||||
var str = GetUserAgent(context);
|
||||
var str = context.GetUserAgent();
|
||||
var uaParser = Parser.GetDefault();
|
||||
ClientInfo c = uaParser.Parse(str);
|
||||
return c;
|
||||
|
||||
@@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using Ubiety.Dns.Core.Common;
|
||||
|
||||
namespace Yi.Framework.WebCore
|
||||
namespace Yi.Framework.WebCore.CommonExtend
|
||||
{
|
||||
public static class ServiceLocator
|
||||
{
|
||||
@@ -1,15 +1,16 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Yi.Framework.Common.Base;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core.Cache;
|
||||
using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.Core
|
||||
namespace Yi.Framework.WebCore.DbExtend
|
||||
{
|
||||
public class DbFiterExtend
|
||||
{
|
||||
@@ -69,7 +70,7 @@ namespace Yi.Framework.Core
|
||||
break;
|
||||
case DataScopeEnum.CUSTOM:
|
||||
//自定义查询
|
||||
var filter = new TableFilterItem<UserEntity>(it => SqlFunc.Subqueryable<RoleDeptEntity>().Where(f => f.DeptId == it.DeptId && f.RoleId == (long)role.Id).Any(), true);
|
||||
var filter = new TableFilterItem<UserEntity>(it => SqlFunc.Subqueryable<RoleDeptEntity>().Where(f => f.DeptId == it.DeptId && f.RoleId == role.Id).Any(), true);
|
||||
db.QueryFilter.Add(filter);
|
||||
break;
|
||||
case DataScopeEnum.DEPT_FOLLOW:
|
||||
|
||||
@@ -6,8 +6,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.SeedData;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Model.RABC.SeedData;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.DbExtend
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.WebCore.Mapper;
|
||||
|
||||
namespace Yi.Framework.WebCore.Mapper
|
||||
{
|
||||
|
||||
@@ -5,7 +5,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.DTOModel.Vo;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.BBS.Entitys;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
|
||||
namespace Yi.Framework.WebCore.Mapper
|
||||
{
|
||||
@@ -14,11 +15,11 @@ namespace Yi.Framework.WebCore.Mapper
|
||||
// 添加你的实体映射关系.
|
||||
public AutoMapperProfile()
|
||||
{
|
||||
CreateMap<ArticleEntity, ArticleVo > ();
|
||||
CreateMap<ArticleEntity, ArticleVo>();
|
||||
CreateMap<UserEntity, UserVo>();
|
||||
CreateMap<CommentEntity, CommentVo>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.WebCore.SignalRHub
|
||||
{
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
<PackageReference Include="Autofac" Version="6.3.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
|
||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
|
||||
<PackageReference Include="Com.Ctrip.Framework.Apollo.Configuration" Version="2.5.0" />
|
||||
<PackageReference Include="DotNetCore.CAP" Version="5.2.0" />
|
||||
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="5.2.0" />
|
||||
<PackageReference Include="DotNetCore.CAP.MySql" Version="5.2.0" />
|
||||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="5.2.0" />
|
||||
<PackageReference Include="IGeekFan.AspNetCore.Knife4jUI" Version="0.0.11" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
|
||||
Reference in New Issue
Block a user