Первая часть работы с заявками

This commit is contained in:
bekodeg
2025-06-17 20:26:36 +04:00
parent 4c75d24f4c
commit 89176542f2
7 changed files with 64 additions and 12 deletions

View File

@@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Http;
using System.ComponentModel.DataAnnotations;
namespace ApplicationSystem.Contracts.Models.Application
{
/// <summary>
/// Запрос на создание заявки
/// </summary>
public record ApplicationCreateRequest
{
/// <summary>
/// Содержимое
/// </summary>
[Required]
[StringLength(1000)]
public string Text { get; init; } = null!;
/// <summary>
/// Тип заявки
/// </summary>
[Required]
public Guid TypeId { get; init; }
/// <summary>
/// Файл
/// </summary>
public IFormFile? File { get; set; }
}
}

View File

@@ -20,8 +20,13 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ApplicationSystem.Contracts\ApplicationSystem.Contracts.csproj" />
<ProjectReference Include="..\ApplicationSystem.Identity\ApplicationSystem.Identity.csproj" />
<ProjectReference Include="..\ApplicationSystem.MediatrHelper\ApplicationSystem.MediatRHelper.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\Queries\AplicationQueries\" />
</ItemGroup>
</Project>

View File

@@ -1,4 +1,6 @@
using Asp.Versioning;
using ApplicationSystem.Models.Commands.ApplicationCommands;
using Asp.Versioning;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -8,13 +10,16 @@ namespace ApplicationSystem.Controllers
[Authorize]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public class ApplicationsController : ControllerBase
public class ApplicationsController(IMediator mediator) : ControllerBase
{
private readonly IMediator _mediator = mediator;
[HttpPost]
public async Task<IActionResult> CreateApplicationAsync()
public async Task<IActionResult> CreateApplicationAsync(
[FromForm] ApplicationCreateCommand request)
{
await Task.Delay(100);
return Ok();
var response = await _mediator.Send(request);
return StatusCode((int)response.ResponseStatusCode);
}
[HttpGet]

View File

@@ -0,0 +1,13 @@
using ApplicationSystem.Contracts.Models.Application;
using ApplicationSystem.MediatRHelper.Models;
namespace ApplicationSystem.Models.Commands.ApplicationCommands
{
/// <summary>
/// Запрос на создание заявки
/// </summary>
public record ApplicationCreateCommand
: ApplicationCreateRequest, IRequestModel
{
}
}

View File

@@ -1,6 +0,0 @@
namespace ApplicationSystem.Models.Queries.AplicationQueries
{
public class ApplicationCreateCommand
{
}
}

View File

@@ -3,7 +3,9 @@ using ApplicationSystem.Identity.Database.Models;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers().AddNewtonsoftJson();
builder.Services
.AddControllers()
.AddNewtonsoftJson();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwagger();