完成错误中间件,统一返回结果

This commit is contained in:
橙子
2023-01-17 22:47:15 +08:00
parent f68ffefaa9
commit da2cf2acc5
16 changed files with 193 additions and 39 deletions

View File

@@ -13,14 +13,17 @@ using Yi.Framework.Ddd.Services.Abstract;
using Yi.Framework.Application.Contracts.Student.Dtos;
using Yi.Framework.Domain.Student.Entities;
using Yi.Framework.Ddd.Services;
using Yi.Framework.Core.Attributes;
namespace Yi.Framework.Application.Student
{
/// <summary>
/// 服务实现
/// </summary>
[AppService]
public class StudentService : CrudAppService<StudentEntity, StudentGetOutputDto, StudentGetListOutputDto, long, StudentGetListInputVo, StudentCreateInputVo, StudentUpdateInputVo>,
IStudentService, IAutoApiService
IStudentService,IAutoApiService
{
private readonly IStudentRepository _studentRepository;
private readonly StudentManager _studentManager;

View File

@@ -22,12 +22,10 @@ namespace Yi.Framework.Application
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
services.AddTransient<IStudentService, StudentService>();
}
}
}

View File

@@ -0,0 +1 @@
global using Yi.Framework.Core.Attributes;

View File

@@ -9,6 +9,7 @@ namespace Yi.Framework.Domain.Shared.Student.ConstClasses
/// <summary>
/// 常量定义
/// </summary>
public class StudentConst
{
public const string = "失败!学生已经重复";

View File

@@ -0,0 +1 @@
global using Yi.Framework.Core.Attributes;

View File

@@ -1,3 +1,4 @@
using AspNetCore.Microsoft.AspNetCore.Hosting;
using Yi.Framework.Core.Autofac.Extensions;
using Yi.Framework.Core.Autofac.Modules;
using Yi.Framework.Core.Extensions;
@@ -6,7 +7,8 @@ using Yi.Framework.Web;
TimeTest.Start();
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url
builder.WebHost.UseStartUrlsServer(builder.Configuration, "StartUrl");
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
builder.UseYiModules(typeof(YiFrameworkWebModule));
@@ -17,10 +19,12 @@ builder.Host.ConfigureAutoFacContainer(container =>
container.RegisterYiModule(AutoFacModuleEnum.PropertiesAutowiredModule, typeof(YiFrameworkWebModule).Assembly);
});
var app = builder.Build();
var t = app.Services.GetService<Test2Entity>();
//ȫ<>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
app.UseErrorHandlingServer();
app.MapControllers();
app.Run();

View File

@@ -1,5 +1,4 @@
using Yi.Framework.Core.Attributes;
using Yi.Framework.Core.DependencyInjection;
using Yi.Framework.Core.DependencyInjection;
namespace Yi.Framework.Web
{

View File

@@ -11,3 +11,22 @@
2023:01:17-17:45:11本次运行启动时间为4771毫秒
2023:01:17-17:45:54本次运行启动时间为1917毫秒
2023:01:17-17:48:04本次运行启动时间为2138毫秒
2023:01:17-17:57:41本次运行启动时间为1907毫秒
2023:01:17-17:58:29本次运行启动时间为1895毫秒
2023:01:17-17:58:43本次运行启动时间为1937毫秒
2023:01:17-17:59:38本次运行启动时间为1856毫秒
2023:01:17-21:06:57本次运行启动时间为2285毫秒
2023:01:17-21:09:32本次运行启动时间为2007毫秒
2023:01:17-21:10:16本次运行启动时间为1862毫秒
2023:01:17-21:12:25本次运行启动时间为2055毫秒
2023:01:17-21:13:46本次运行启动时间为5606毫秒
2023:01:17-21:14:35本次运行启动时间为4824毫秒
2023:01:17-21:18:17本次运行启动时间为8985毫秒
2023:01:17-21:19:48本次运行启动时间为1859毫秒
2023:01:17-21:21:32本次运行启动时间为1786毫秒
2023:01:17-22:41:17本次运行启动时间为1901毫秒
2023:01:17-22:42:21本次运行启动时间为1946毫秒
2023:01:17-22:42:55本次运行启动时间为1970毫秒
2023:01:17-22:43:56本次运行启动时间为2023毫秒
2023:01:17-22:45:25本次运行启动时间为1803毫秒
2023:01:17-22:45:52本次运行启动时间为1877毫秒

View File

@@ -7,11 +7,7 @@ using Yi.Framework.Sqlsugar;
namespace Yi.Framework.Web
{
/// <summary>
/// 这里是最后执行的模块
/// </summary>
[DependsOn(
typeof(YiFrameworkCoreModule),
typeof(YiFrameworkSqlsugarModule),
typeof(YiFrameworkApplicationModule)
)]