添加命令数据验证和其他杂项修改
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
using Domain.AggregateModel.AppAggregate;
|
||||
using Domain.AggregateModel.LinkAggregate;
|
||||
using FluentValidation;
|
||||
using FluentValidation.AspNetCore;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Repositories;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@@ -12,6 +17,9 @@ using Microsoft.OpenApi.Models;
|
||||
using Pomelo.EntityFrameworkCore.MySql;
|
||||
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
|
||||
using QRCodeService.Application.Behaviors;
|
||||
using QRCodeService.Application.Commands;
|
||||
using QRCodeService.Application.Queries;
|
||||
using QRCodeService.Application.Validations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -38,12 +46,14 @@ namespace QRCodeService
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "QRCodeService", Version = "v1" });
|
||||
});
|
||||
//MediatR
|
||||
services.AddMediatR(Assembly.GetExecutingAssembly());
|
||||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>));
|
||||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidatorBehavior<,>));
|
||||
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(TransactionBehaviour<,>));
|
||||
//validator
|
||||
services.AddTransient<IValidator<CreateLinkCommand>, CreateLinkCommandValidator>();
|
||||
|
||||
//MediatR+
|
||||
services.AddMediatR(Assembly.GetExecutingAssembly())
|
||||
.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>))
|
||||
.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidatorBehavior<,>))
|
||||
.AddTransient(typeof(IPipelineBehavior<,>), typeof(TransactionBehaviour<,>));
|
||||
//EFCore
|
||||
services.AddDbContext<AppDbContext>(
|
||||
dbContextOptions => dbContextOptions
|
||||
@@ -57,6 +67,12 @@ namespace QRCodeService
|
||||
.EnableSensitiveDataLogging()
|
||||
.EnableDetailedErrors()
|
||||
);
|
||||
|
||||
//Repository
|
||||
services.AddScoped<IAppRepository, AppRepository>();
|
||||
services.AddScoped<ILinkRepository, LinkRepository>();
|
||||
services.AddScoped<ILinkQueries, LinkQueries>();
|
||||
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
||||
Reference in New Issue
Block a user