Merge from dev

This commit is contained in:
Оля Бизюкова 2024-12-05 11:30:07 +05:00
parent c66b0bbc2f
commit ae3e164df1
7 changed files with 83 additions and 82 deletions

View File

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Persistence.Models;
using Persistence.Models.Requests;
using Persistence.Repositories;
namespace Persistence.API.Controllers;
@ -36,7 +37,7 @@ public class TechMessagesController : ControllerBase
/// <param name="token"></param>
/// <returns></returns>
[HttpGet]
public async Task<ActionResult<PaginationContainer<TechMessageDto>>> GetPage([FromQuery] RequestDto request, CancellationToken token)
public async Task<ActionResult<PaginationContainer<TechMessageDto>>> GetPage([FromQuery] PaginationRequest request, CancellationToken token)
{
var result = await techMessagesRepository.GetPage(request, token);

View File

@ -1,4 +1,3 @@
using System.Text.Json.Nodes;
using Mapster;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
@ -8,6 +7,7 @@ using Persistence.Database.Entity;
using Persistence.Models;
using Persistence.Models.Configurations;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Reflection;
using System.Text.Json.Nodes;
namespace Persistence.API;

View File

@ -1,4 +1,5 @@
using Persistence.Models;
using Persistence.Models.Requests;
using Refit;
namespace Persistence.Client.Clients
@ -11,7 +12,7 @@ namespace Persistence.Client.Clients
private const string BaseRoute = "/api/techMessages";
[Get($"{BaseRoute}")]
Task<IApiResponse<PaginationContainer<TechMessageDto>>> GetPage([Query] RequestDto request, CancellationToken token);
Task<IApiResponse<PaginationContainer<TechMessageDto>>> GetPage([Query] PaginationRequest request, CancellationToken token);
[Post($"{BaseRoute}")]
Task<IApiResponse<int>> AddRange([Body] IEnumerable<TechMessageDto> dtos, CancellationToken token);

View File

@ -1,7 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Npgsql;
using Persistence.Database.Entity;
using System.Data.Common;
namespace Persistence.Database.Model;
public partial class PersistenceDbContext : DbContext
@ -52,7 +50,6 @@ public partial class PersistenceDbContext : DbContext
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
}
modelBuilder.Entity<ChangeLog>()
.Property(e => e.Value)

View File

@ -5,6 +5,7 @@ using Persistence.Client;
using Persistence.Client.Clients;
using Persistence.Database.Entity;
using Persistence.Models;
using Persistence.Models.Requests;
using Xunit;
namespace Persistence.IntegrationTests.Controllers
@ -32,7 +33,7 @@ namespace Persistence.IntegrationTests.Controllers
dbContext.CleanupDbSet<TechMessage>();
dbContext.CleanupDbSet<Database.Entity.DrillingSystem>();
var requestDto = new RequestDto()
var PaginationRequest = new PaginationRequest()
{
Skip = 1,
Take = 2,
@ -40,14 +41,14 @@ namespace Persistence.IntegrationTests.Controllers
};
//act
var response = await techMessagesClient.GetPage(requestDto, new CancellationToken());
var response = await techMessagesClient.GetPage(PaginationRequest, new CancellationToken());
//assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content);
Assert.Empty(response.Content.Items);
Assert.Equal(requestDto.Skip, response.Content.Skip);
Assert.Equal(requestDto.Take, response.Content.Take);
Assert.Equal(PaginationRequest.Skip, response.Content.Skip);
Assert.Equal(PaginationRequest.Take, response.Content.Take);
}
[Fact]
@ -56,7 +57,7 @@ namespace Persistence.IntegrationTests.Controllers
//arrange
var dtos = await InsertRange();
var dtosCount = dtos.Count();
var requestDto = new RequestDto()
var PaginationRequest = new PaginationRequest()
{
Skip = 0,
Take = 2,
@ -64,7 +65,7 @@ namespace Persistence.IntegrationTests.Controllers
};
//act
var response = await techMessagesClient.GetPage(requestDto, new CancellationToken());
var response = await techMessagesClient.GetPage(PaginationRequest, new CancellationToken());
//assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);

View File

@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using Persistence.Database.Entity;
using Persistence.Models;
using Persistence.Models.Requests;
using Persistence.Repositories;
using Persistence.Repository.Extensions;
@ -24,7 +25,7 @@ namespace Persistence.Repository.Repositories
protected virtual IQueryable<TechMessage> GetQueryReadOnly() => db.Set<TechMessage>()
.Include(e => e.System);
public async Task<PaginationContainer<TechMessageDto>> GetPage(RequestDto request, CancellationToken token)
public async Task<PaginationContainer<TechMessageDto>> GetPage(PaginationRequest request, CancellationToken token)
{
var query = GetQueryReadOnly();
var count = await query.CountAsync(token);

View File

@ -1,5 +1,5 @@
using System.Threading.Tasks;
using Persistence.Models;
using Persistence.Models;
using Persistence.Models.Requests;
namespace Persistence.Repositories
{
@ -14,7 +14,7 @@ namespace Persistence.Repositories
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<PaginationContainer<TechMessageDto>> GetPage(RequestDto request, CancellationToken token);
Task<PaginationContainer<TechMessageDto>> GetPage(PaginationRequest request, CancellationToken token);
/// <summary>
/// Добавление новых сообщений