Правка по результатам ревью-3

This commit is contained in:
Olga Nemt 2023-11-30 11:11:45 +05:00
parent 5ed11d8b47
commit 8fd9961da7
4 changed files with 20 additions and 8975 deletions

View File

@ -1,41 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Add_Permissions_For_Trajectory_Fact : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
table: "t_permission",
columns: new[] { "id", "description", "name" },
values: new object[,]
{
{ 529, "Разрешение просматривать фактические траектории", "FactTrajectory.edit" },
});
migrationBuilder.InsertData(
table: "t_relation_user_role_permission",
columns: new[] { "id_permission", "id_user_role" },
values: new object[,]
{
{ 529, 1 },
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "t_relation_user_role_permission",
keyColumns: new[] { "id_permission", "id_user_role" },
keyValues: new object[] { 529, 1 });
migrationBuilder.DeleteData(
table: "t_permission",
keyColumn: "id",
keyValue: 529);
}
}
}

View File

@ -45,12 +45,18 @@ namespace AsbCloudInfrastructure.Repository
{ {
IdWell = idWell, IdWell = idWell,
}; };
var result = await GetByRequestAsync(request, token);
return result;
}
public async Task<IEnumerable<TrajectoryGeoFactDto>> GetByRequestAsync(TrajectoryRequest request, CancellationToken token)
{
var entities = (await BuildQuery(request) var entities = (await BuildQuery(request)
.Where(coord => coord.Deptsvym.HasValue && .Where(coord => coord.Deptsvym.HasValue &&
coord.Svyinc.HasValue && coord.Svyinc.HasValue &&
coord.Svyazc.HasValue) coord.Svyazc.HasValue)
.AsNoTracking() .AsNoTracking()
.ToArrayAsync(token)); .ToArrayAsync(token));
var result = entities var result = entities
.Select(coord => new TrajectoryGeoFactDto .Select(coord => new TrajectoryGeoFactDto
@ -66,10 +72,5 @@ namespace AsbCloudInfrastructure.Repository
return result; return result;
} }
public Task<IEnumerable<TrajectoryGeoFactDto>> GetByRequestAsync(TrajectoryRequest trajectoryRequest, CancellationToken cancellationToken)
{
throw new System.NotImplementedException();
}
} }
} }

View File

@ -6,6 +6,7 @@ using AsbCloudInfrastructure.Services.Trajectory.Export;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -17,18 +18,18 @@ namespace AsbCloudWebApi.Controllers.Trajectory
/// </summary> /// </summary>
[ApiController] [ApiController]
[Authorize] [Authorize]
public abstract class TrajectoryController<Tdto> : ControllerBase public abstract class TrajectoryController<TDto> : ControllerBase
where Tdto : TrajectoryGeoDto where TDto : TrajectoryGeoDto
{ {
protected abstract string fileName { get; set; } protected abstract string fileName { get; set; }
private readonly IWellService wellService; private readonly IWellService wellService;
private readonly TrajectoryExportService<Tdto> trajectoryExportService; private readonly TrajectoryExportService<TDto> trajectoryExportService;
private readonly ITrajectoryRepository<Tdto> trajectoryRepository; private readonly ITrajectoryRepository<TDto> trajectoryRepository;
public TrajectoryController(IWellService wellService, public TrajectoryController(IWellService wellService,
TrajectoryExportService<Tdto> trajectoryExportService, TrajectoryExportService<TDto> trajectoryExportService,
ITrajectoryRepository<Tdto> trajectoryRepository) ITrajectoryRepository<TDto> trajectoryRepository)
{ {
this.trajectoryExportService = trajectoryExportService; this.trajectoryExportService = trajectoryExportService;
this.wellService = wellService; this.wellService = wellService;
@ -60,8 +61,8 @@ namespace AsbCloudWebApi.Controllers.Trajectory
/// <param name="idWell">ключ скважины</param> /// <param name="idWell">ключ скважины</param>
/// <param name="token"> Токен отмены задачи </param> /// <param name="token"> Токен отмены задачи </param>
/// <returns>Список добавленных координат траектории</returns> /// <returns>Список добавленных координат траектории</returns>
//[ProducesResponseType(typeof(IEnumerable<Tdto>), (int)System.Net.HttpStatusCode.OK)] [HttpGet]
public async Task<IActionResult> GetAsync(int idWell, CancellationToken token) public async Task<ActionResult<IEnumerable<TDto>>> GetAsync(int idWell, CancellationToken token)
{ {
if (!await CanUserAccessToWellAsync(idWell, if (!await CanUserAccessToWellAsync(idWell,
token).ConfigureAwait(false)) token).ConfigureAwait(false))