Fixed DrillFlowChart routes, model, dto names

This commit is contained in:
KharchenkoVladimir 2021-10-14 10:18:43 +05:00
parent 7c41fc5b91
commit 32732bf058
8 changed files with 44 additions and 36 deletions

View File

@ -2,7 +2,7 @@ using System;
namespace AsbCloudApp.Data namespace AsbCloudApp.Data
{ {
public class DrillFlowChartParamsDto : IId public class DrillFlowChartDto : IId
{ {
public int Id { get; set; } public int Id { get; set; }

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -5,18 +6,18 @@ using AsbCloudApp.Data;
namespace AsbCloudApp.Services namespace AsbCloudApp.Services
{ {
public interface IDrillFlowChartService : ICrudService<DrillFlowChartParamsDto> public interface IDrillFlowChartService : ICrudService<DrillFlowChartDto>
{ {
Task<IEnumerable<DrillFlowChartParamsDto>> GetAllAsync(int idWell, Task<IEnumerable<DrillFlowChartDto>> GetAllAsync(int idWell,
CancellationToken token = default); DateTime updateFrom, CancellationToken token = default);
Task<int> InsertAsync(int idWell, DrillFlowChartParamsDto dto, Task<int> InsertAsync(int idWell, DrillFlowChartDto dto,
CancellationToken token = default); CancellationToken token = default);
Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillFlowChartParamsDto> dtos, Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillFlowChartDto> dtos,
CancellationToken token = default); CancellationToken token = default);
Task<int> UpdateAsync(int idWell, int idDto, DrillFlowChartParamsDto dto, Task<int> UpdateAsync(int idWell, int idDto, DrillFlowChartDto dto,
CancellationToken token = default); CancellationToken token = default);
} }
} }

View File

@ -36,7 +36,7 @@ namespace AsbCloudDb.Model
public virtual DbSet<WellSectionType> WellSectionTypes { get; set; } public virtual DbSet<WellSectionType> WellSectionTypes { get; set; }
public virtual DbSet<WellType> WellTypes { get; set; } public virtual DbSet<WellType> WellTypes { get; set; }
public virtual DbSet<DrillParams> DrillParams { get; set; } public virtual DbSet<DrillParams> DrillParams { get; set; }
public virtual DbSet<DrillFlowChartParams> DrillFlowChartParams { get; set; } public virtual DbSet<DrillFlowChart> DrillFlowChart { get; set; }
//var options = new DbContextOptionsBuilder<AsbCloudDbContext>() //var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
// .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") // .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")

View File

@ -7,7 +7,7 @@ using System.Text.Json.Serialization;
namespace AsbCloudDb.Model namespace AsbCloudDb.Model
{ {
[Table("t_drill_flow_chart_params"), Comment("Параметры корридоров бурения (диапазоны параметров бурения)")] [Table("t_drill_flow_chart_params"), Comment("Параметры корридоров бурения (диапазоны параметров бурения)")]
public class DrillFlowChartParams : IId public class DrillFlowChart : IId
{ {
[Key] [Key]
[Column("id")] [Column("id")]

View File

@ -34,7 +34,7 @@ namespace AsbCloudDb.Model
DbSet<MeasureCategory> MeasureCategories { get; set; } DbSet<MeasureCategory> MeasureCategories { get; set; }
DbSet<TelemetryDataSpin> TelemetryDataSpin { get; set; } DbSet<TelemetryDataSpin> TelemetryDataSpin { get; set; }
DbSet<DrillParams> DrillParams { get; set; } DbSet<DrillParams> DrillParams { get; set; }
DbSet<DrillFlowChartParams> DrillFlowChartParams { get; set; } DbSet<DrillFlowChart> DrillFlowChart { get; set; }
DatabaseFacade Database { get; } DatabaseFacade Database { get; }

View File

@ -11,7 +11,7 @@ using Mapster;
namespace AsbCloudInfrastructure.Services namespace AsbCloudInfrastructure.Services
{ {
public class DrillFlowChartService : CrudServiceBase<DrillFlowChartParamsDto, DrillFlowChartParams>, public class DrillFlowChartService : CrudServiceBase<DrillFlowChartDto, DrillFlowChart>,
IDrillFlowChartService IDrillFlowChartService
{ {
private readonly IAsbCloudDbContext db; private readonly IAsbCloudDbContext db;
@ -24,21 +24,22 @@ namespace AsbCloudInfrastructure.Services
this.telemetryService = telemetryService; this.telemetryService = telemetryService;
} }
public async Task<IEnumerable<DrillFlowChartParamsDto>> GetAllAsync(int idWell, public async Task<IEnumerable<DrillFlowChartDto>> GetAllAsync(int idWell,
CancellationToken token = default) DateTime updateFrom, CancellationToken token = default)
{ {
var entities = await (from p in db.DrillFlowChartParams var entities = await (from p in db.DrillFlowChart
where p.IdWell == idWell where p.IdWell == idWell &&
p.LastUpdate >= updateFrom
orderby p.Id orderby p.Id
select p) select p)
.ToListAsync(token) .ToListAsync(token)
.ConfigureAwait(false); .ConfigureAwait(false);
var dto = entities.Adapt<DrillFlowChartParamsDto>(); var dto = entities.Adapt<DrillFlowChartDto>();
return dto; return dto;
} }
public async Task<int> InsertAsync(int idWell, DrillFlowChartParamsDto dto, public async Task<int> InsertAsync(int idWell, DrillFlowChartDto dto,
CancellationToken token = default) CancellationToken token = default)
{ {
dto.IdWell = idWell; dto.IdWell = idWell;
@ -49,7 +50,7 @@ namespace AsbCloudInfrastructure.Services
return result; return result;
} }
public async Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillFlowChartParamsDto> dtos, public async Task<int> InsertRangeAsync(int idWell, IEnumerable<DrillFlowChartDto> dtos,
CancellationToken token = default) CancellationToken token = default)
{ {
foreach (var dto in dtos) foreach (var dto in dtos)
@ -63,7 +64,7 @@ namespace AsbCloudInfrastructure.Services
return result; return result;
} }
public async Task<int> UpdateAsync(int idWell, int idDto, DrillFlowChartParamsDto dto, public async Task<int> UpdateAsync(int idWell, int idDto, DrillFlowChartDto dto,
CancellationToken token = default) CancellationToken token = default)
{ {
dto.IdWell = idWell; dto.IdWell = idWell;

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -10,7 +11,7 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Контроллер для корридоров бурения на панели /// Контроллер для корридоров бурения на панели
/// </summary> /// </summary>
[Route("api/drillFlowChartParams/{idWell}")] [Route("api/well/{idWell}/drillFlowChart/")]
[ApiController] [ApiController]
public class DrillFlowChartController : ControllerBase public class DrillFlowChartController : ControllerBase
{ {
@ -30,11 +31,13 @@ namespace AsbCloudWebApi.Controllers
/// Возвращает все значения для корридоров бурения по id скважины /// Возвращает все значения для корридоров бурения по id скважины
/// </summary> /// </summary>
/// <param name="idWell"> id скважины </param> /// <param name="idWell"> id скважины </param>
/// <param name="updateFrom"> Дата, с которой следует искать новые параметры </param>
/// <param name="token"> Токен отмены задачи </param> /// <param name="token"> Токен отмены задачи </param>
/// <returns> Список параметров для корридоров бурения </returns> /// <returns> Список параметров для корридоров бурения </returns>
[HttpGet("paramsByIdWell")] [HttpGet]
[ProducesResponseType(typeof(IEnumerable<DrillFlowChartParamsDto>), (int) System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<DrillFlowChartDto>), (int) System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAllAsync(int idWell, CancellationToken token = default) public async Task<IActionResult> GetAllAsync(int idWell, DateTime updateFrom,
CancellationToken token = default)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -42,7 +45,8 @@ namespace AsbCloudWebApi.Controllers
idWell, token).ConfigureAwait(false)) idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
var dto = await drillFlowChartService.GetAllAsync(idWell, token); var dto = await drillFlowChartService.GetAllAsync(idWell,
updateFrom, token);
return Ok(dto); return Ok(dto);
} }
@ -51,11 +55,12 @@ namespace AsbCloudWebApi.Controllers
/// Возвращает все значения для корридоров бурения по uid панели /// Возвращает все значения для корридоров бурения по uid панели
/// </summary> /// </summary>
/// <param name="uid"> uid панели </param> /// <param name="uid"> uid панели </param>
/// <param name="updateFrom"> Дата, с которой следует искать новые параметры </param>
/// <param name="token"> Токен отмены задачи </param> /// <param name="token"> Токен отмены задачи </param>
/// <returns> Список параметров для корридоров бурения </returns> /// <returns> Список параметров для корридоров бурения </returns>
[HttpGet] [HttpGet("{uid}")]
[ProducesResponseType(typeof(IEnumerable<DrillFlowChartParamsDto>), (int) System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(IEnumerable<DrillFlowChartDto>), (int) System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAllAsync(string uid, CancellationToken token = default) public async Task<IActionResult> GetAllAsync(string uid, DateTime updateFrom, CancellationToken token = default)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -65,7 +70,8 @@ namespace AsbCloudWebApi.Controllers
(int)idWell, token).ConfigureAwait(false)) (int)idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
var dto = await drillFlowChartService.GetAllAsync((int)idWell, token); var dto = await drillFlowChartService.GetAllAsync((int)idWell,
updateFrom, token);
return Ok(dto); return Ok(dto);
} }
@ -74,13 +80,13 @@ namespace AsbCloudWebApi.Controllers
/// Сохраняет значения для корридоров бурения /// Сохраняет значения для корридоров бурения
/// </summary> /// </summary>
/// <param name="idWell"> id скважины </param> /// <param name="idWell"> id скважины </param>
/// <param name="drillFlowChartParamsDto"> Параметры корридоров бурения</param> /// <param name="drillFlowChartDto"> Параметры корридоров бурения</param>
/// <param name="token"> Токен отмены задачи </param> /// <param name="token"> Токен отмены задачи </param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> InsertAsync(int idWell, public async Task<IActionResult> InsertAsync(int idWell,
DrillFlowChartParamsDto drillFlowChartParamsDto, CancellationToken token = default) DrillFlowChartDto drillFlowChartDto, CancellationToken token = default)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -88,7 +94,7 @@ namespace AsbCloudWebApi.Controllers
idWell, token).ConfigureAwait(false)) idWell, token).ConfigureAwait(false))
return Forbid(); return Forbid();
var result = await drillFlowChartService.InsertAsync(idWell, drillFlowChartParamsDto, token); var result = await drillFlowChartService.InsertAsync(idWell, drillFlowChartDto, token);
return Ok(result); return Ok(result);
} }
@ -103,7 +109,7 @@ namespace AsbCloudWebApi.Controllers
[HttpPost("range")] [HttpPost("range")]
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> InsertRangeAsync(int idWell, public async Task<IActionResult> InsertRangeAsync(int idWell,
IEnumerable<DrillFlowChartParamsDto> drillFlowChartParams, CancellationToken token = default) IEnumerable<DrillFlowChartDto> drillFlowChartParams, CancellationToken token = default)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -121,13 +127,13 @@ namespace AsbCloudWebApi.Controllers
/// Изменяет значения выбранного корридора бурения /// Изменяет значения выбранного корридора бурения
/// </summary> /// </summary>
/// <param name="idWell"> id скважины </param> /// <param name="idWell"> id скважины </param>
/// <param name="drillFlowChartParams"> Параметры корридоров бурения</param> /// <param name="drillFlowChart"> Параметры корридоров бурения</param>
/// <param name="token"> Токен отмены задачи </param> /// <param name="token"> Токен отмены задачи </param>
/// <returns></returns> /// <returns></returns>
[HttpPut] [HttpPut]
[ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(int), (int) System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> EditAsync(int idWell, public async Task<IActionResult> EditAsync(int idWell,
DrillFlowChartParamsDto drillFlowChartParams, CancellationToken token = default) DrillFlowChartDto drillFlowChart, CancellationToken token = default)
{ {
var idCompany = User.GetCompanyId(); var idCompany = User.GetCompanyId();
@ -136,7 +142,7 @@ namespace AsbCloudWebApi.Controllers
return Forbid(); return Forbid();
var result = await drillFlowChartService.UpdateAsync(idWell, var result = await drillFlowChartService.UpdateAsync(idWell,
drillFlowChartParams, token); drillFlowChart, token);
return Ok(result); return Ok(result);
} }

View File

@ -10,7 +10,7 @@ namespace AsbCloudWebApi.Controllers
/// <summary> /// <summary>
/// Контроллер для режимов бурения /// Контроллер для режимов бурения
/// </summary> /// </summary>
[Route("api/drillParams/{idWell}")] [Route("api/well/{idWell}/drillParams/")]
[ApiController] [ApiController]
public class DrillParamsController : ControllerBase public class DrillParamsController : ControllerBase
{ {