前端大更新vuex

This commit is contained in:
橙子
2021-10-17 18:37:07 +08:00
parent b77b91912b
commit 6bb2b41840
24 changed files with 332 additions and 65 deletions

View File

@@ -28,7 +28,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <summary>
/// 登录方法要返回data:{user,token} token先写123456789,不要有导航属性
/// 登录方法要返回data:{user,token} token
/// </summary>
/// <param name="_user"></param>
/// <returns></returns>

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- 将日志以回滚文件的形式写到文件中 -->
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<!--Error-->
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
<!--不加utf-8编码格式中文字符将显示成乱码-->
<param name="Encoding" value="utf-8" />
<file value="log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalExceptionLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="ERROR" />
<levelMax value="FATAL" />
</filter>
</appender>
<!--Error-->
<!--Info-->
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
<!--不加utf-8编码格式中文字符将显示成乱码-->
<param name="Encoding" value="utf-8" />
<!--定义文件存放位置-->
<file value="log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalInfoLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="DEBUG" />
<levelMax value="WARN" />
</filter>
</appender>
<!--Info-->
<root>
<!-- 控制级别由低到高ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
<!-- 比如定义级别为INFO则INFO级别向下的级别比如DEBUG日志将不会被记录 -->
<!-- 如果没有定义LEVEL的值则缺省为DEBUG -->
<level value="ALL" />
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<appender-ref ref="ErrorLog" />
<appender-ref ref="InfoLog" />
</root>
</log4net>

View File

@@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.WebCore.BuilderExtend;
namespace Yi.Framework.ApiMicroservice
{
@@ -19,9 +20,25 @@ namespace Yi.Framework.ApiMicroservice
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
{
configurationBuilder.AddCommandLine(args);
configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
#region
//ApolloÅäÖÃ
#endregion
//configurationBuilder.AddApolloService("Yi");
})
.ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
loggingBuilder.AddLog4Net();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseStartup<Startup>().UseUrls("https://*:44329");
}).UseServiceProviderFactory(new AutofacServiceProviderFactory());
}
}

View File

@@ -13,13 +13,14 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Yi.Framework.ApiMicroservice.Utility;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Interface;
using Yi.Framework.Model;
using Yi.Framework.Service;
using Yi.Framework.WebCore;
using Yi.Framework.WebCore.FilterExtend;
using Yi.Framework.WebCore.MiddlewareExtend;
using Yi.Framework.WebCore.Utility;
namespace Yi.Framework.ApiMicroservice
{
@@ -43,7 +44,9 @@ namespace Yi.Framework.ApiMicroservice
#region
//控制器+过滤器配置
#endregion
services.AddControllers();
services.AddControllers(optios=> {
//optios.Filters.Add(typeof(CustomExceptionFilterAttribute));
});
#region
//Swagger服务配置
@@ -55,6 +58,11 @@ namespace Yi.Framework.ApiMicroservice
#endregion
services.AddCorsService();
#region
//Jwt鉴权配置
#endregion
services.AddJwtService();
#region
//Sqlite服务配置
#endregion
@@ -98,6 +106,10 @@ namespace Yi.Framework.ApiMicroservice
#endregion
app.UseSwaggerService();
}
#region
//错误抓取反馈注入
#endregion
app.UseErrorHandlingService();
#region
//HttpsRedirection注入

View File

@@ -6,7 +6,7 @@
<members>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Login(Yi.Framework.Model.Models.user)">
<summary>
登录方法要返回data:{user,token} token先写123456789,不要有导航属性
登录方法要返回data:{user,token} token
</summary>
<param name="_user"></param>
<returns></returns>
@@ -162,13 +162,5 @@
<param name="idsListDto"></param>
<returns></returns>
</member>
<member name="T:Yi.Framework.ApiMicroservice.Utility.CustomHostingStartup">
<summary>
必须实现IHostingStartup接口
必须标记HostingStartup特性
就像木马一样
</summary>
</member>
</members>
</doc>

View File

@@ -1,21 +0,0 @@
using Castle.DynamicProxy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Yi.Framework.ApiMicroservice.Utility
{
public class CustomAutofacAop : IInterceptor
{
public void Intercept(IInvocation invocation)
{
Console.WriteLine($"invocation.Methond={invocation.Method}");
Console.WriteLine($"invocation.Arguments={string.Join(",", invocation.Arguments)}");
invocation.Proceed(); //继续执行
Console.WriteLine($"方法{invocation.Method}执行完成了");
}
}
}

View File

@@ -1,67 +0,0 @@
using Autofac;
using Autofac.Extras.DynamicProxy;
using Castle.DynamicProxy;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Yi.Framework.ApiMicroservice.Utility;
using Yi.Framework.Interface;
using Yi.Framework.Model;
using Yi.Framework.Service;
using Module = Autofac.Module;
namespace Yi.Framework.ApiMicroservice.Utility
{
public class CustomAutofacModule : Module
{
protected override void Load(ContainerBuilder containerBuilder)
{
var basePath = AppContext.BaseDirectory;
var servicesDllFile = Path.Combine(basePath, "Yi.Framework.Service.dll");
if (!(File.Exists(servicesDllFile)))
{
var msg = "service.dll 丢失,请编译后重新生成。";
throw new Exception(msg);
}
var assemblysServices = Assembly.LoadFrom(servicesDllFile);
containerBuilder.RegisterAssemblyTypes(assemblysServices)
.AsImplementedInterfaces()
.InstancePerDependency()
.EnableInterfaceInterceptors();
containerBuilder.Register(c => new CustomAutofacAop());//AOP注册
//containerBuilder.RegisterType<A>().As<IA>().EnableInterfaceInterceptors();开启Aop
//将数据库对象注入
//containerBuilder.RegisterType<DataContext>().As<DbContext>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
//containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerDependency().EnableInterfaceInterceptors();
}
}
}
public interface IAutofacTest
{
void Show(int id, string name);
}
[Intercept(typeof(CustomAutofacAop))]
public class AutofacTest : IAutofacTest
{
public void Show(int id, string name)
{
Console.WriteLine($"This is {id} _ {name}");
}
}

View File

@@ -1,54 +0,0 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
[assembly: HostingStartup(typeof(Yi.Framework.ApiMicroservice.Utility.CustomHostingStartup))]
namespace Yi.Framework.ApiMicroservice.Utility
{
/// <summary>
/// 必须实现IHostingStartup接口
/// 必须标记HostingStartup特性
///
/// 就像木马一样
/// </summary>
public class CustomHostingStartup : IHostingStartup
{
public void Configure(IWebHostBuilder builder)
{
Console.WriteLine("This is CustomHostingStartup Invoke");
//有IWebHostBuilder一切都可以做。。
#region MyRegion
//builder.ConfigureAppConfiguration(configurationBuilder =>
//{
// configurationBuilder.AddXmlFile("appsettings1.xml", optional: false, reloadOnChange: true);
//});//添加配置
//builder.ConfigureServices(services =>
//{
// services.AddTransient<ITestServiceA, TestServiceA>();
//});//IOC注册
//builder.Configure(app =>
//{
// app.Use(next =>
// {
// Console.WriteLine("This is CustomHostingStartup-Middleware Init");
// return new RequestDelegate(
// async context =>
// {
// Console.WriteLine("This is CustomHostingStartup-Middleware start");
// await next.Invoke(context);
// Console.WriteLine("This is CustomHostingStartup-Middleware end");
// });
// });
//});//甚至来个中间件
#endregion
}
}
}

View File

@@ -9,17 +9,6 @@
<NoWarn>1701;1702;CS1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" />
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />

View File

@@ -6,8 +6,49 @@
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Apollo": {
"AppId": "Yi-ApiMicroservice",
"Env": "DEV",
"MetaServer": "http://192.168.2.168:8080",
"ConfigServer": [ "http://192.168.2.168:8080" ]
},
"SqliteConn": {
"Url": "Filename=YIDB.db"
},
"AllowedHosts": "*"
"MysqlConn": {
"Url": "server=192.168.2.128;port=3306;database=ECDB;user id=root;password=123456"
},
"JWTTokenOptions": {
"Audience": "http://localhost:7000",
"Issuer": "http://localhost:7000",
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
},
"RedisConn": {
"Host": "192.168.2.128",
"Prot": 6379,
"DB": 0,
"Password": "123456"
},
"KafkaOptions": {
"BrokerList": "192.168.3.230:9092",
"TopicName": "kafkalog"
},
"ConsulClientOption": {
"IP": "192.168.2.128",
"Port": "8500",
"Datacenter": "dc1"
},
"ConsulRegisterOption": {
"IP": "192.168.1.104",
"Port": "7001",
"GroupName": "ApiMicroservice",
"HealthCheckUrl": "/Health",
"Interval": 10,
"Timeout": 5,
"DeregisterCriticalServiceAfter": 60,
"Tag": "13"
},
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
}