forked from ddrilling/AsbCloudServer
3 метода get для ProcessMapPlanBaseController
This commit is contained in:
parent
edd5ca695f
commit
792790556c
64
AsbCloudApp/Data/ChangeLogDto.cs
Normal file
64
AsbCloudApp/Data/ChangeLogDto.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using AsbCloudApp.Data.User;
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Часть записи описывающая изменение
|
||||
/// </summary>
|
||||
public class ChangeLogDto<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Запись
|
||||
/// </summary>
|
||||
public required T Item { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ИД записи
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Автор
|
||||
/// </summary>
|
||||
public UserDto? Author { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Автор
|
||||
/// </summary>
|
||||
public UserDto? Editor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата создания записи
|
||||
/// </summary>
|
||||
public DateTimeOffset Creation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата устаревания (например при удалении)
|
||||
/// </summary>
|
||||
public DateTimeOffset? Obsolete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ИД состояния записи:
|
||||
/// <list type="table">
|
||||
/// <item>
|
||||
/// <term>0</term>
|
||||
/// <description>актуальная запись</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>1</term>
|
||||
/// <description>замененная запись</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>2</term>
|
||||
/// <description>удаленная запись</description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public int IdState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id заменяемой записи
|
||||
/// </summary>
|
||||
public int? IdPrevious { get; set; }
|
||||
}
|
@ -1,23 +1,23 @@
|
||||
using AsbCloudApp.Repositories;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Requests;
|
||||
using System;
|
||||
using System.IO;
|
||||
using AsbCloudApp.Services;
|
||||
using System.Linq;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Requests.ParserOptions;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.ProcessMaps;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Requests.ExportOptions;
|
||||
using AsbCloudApp.Requests.ParserOptions;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudApp.Services.Export;
|
||||
using AsbCloudApp.Services.Parsers;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers.ProcessMaps;
|
||||
|
||||
@ -33,16 +33,19 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
private readonly IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> repository;
|
||||
private readonly IWellService wellService;
|
||||
private readonly IParserService<TDto, WellRelatedParserRequest> parserService;
|
||||
private readonly ITelemetryService telemetryService;
|
||||
private readonly IExportService<WellRelatedExportRequest> processMapPlanExportService;
|
||||
|
||||
protected ProcessMapPlanBaseController(IChangeLogRepository<TDto, ProcessMapPlanBaseRequestWithWell> repository,
|
||||
IWellService wellService,
|
||||
IParserService<TDto, WellRelatedParserRequest> parserService,
|
||||
IExportService<WellRelatedExportRequest> processMapPlanExportService)
|
||||
IExportService<WellRelatedExportRequest> processMapPlanExportService,
|
||||
ITelemetryService telemetryService)
|
||||
{
|
||||
this.repository = repository;
|
||||
this.wellService = wellService;
|
||||
this.parserService = parserService;
|
||||
this.telemetryService = telemetryService;
|
||||
this.processMapPlanExportService = processMapPlanExportService;
|
||||
}
|
||||
|
||||
@ -58,7 +61,7 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> InsertRange([FromRoute][Range(0,int.MaxValue)] int idWell, IEnumerable<TDto> dtos, CancellationToken token)
|
||||
public async Task<IActionResult> InsertRange([FromRoute][Range(0, int.MaxValue)] int idWell, IEnumerable<TDto> dtos, CancellationToken token)
|
||||
{
|
||||
var idUser = await AssertUserHasAccessToWell(idWell, token);
|
||||
|
||||
@ -131,21 +134,71 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
/// Получение
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, [FromQuery] ProcessMapPlanBaseRequest request, CancellationToken token)
|
||||
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, CancellationToken token)
|
||||
{
|
||||
await AssertUserHasAccessToWell(idWell, token);
|
||||
|
||||
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(request, idWell);
|
||||
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(idWell);
|
||||
var result = await repository.Get(serviceRequest, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="moment"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("history")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> Get([FromRoute] int idWell, DateTimeOffset? moment, CancellationToken token)
|
||||
{
|
||||
await AssertUserHasAccessToWell(idWell, token);
|
||||
|
||||
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(new ProcessMapPlanBaseRequest()
|
||||
{
|
||||
Moment = moment,
|
||||
}, idWell);
|
||||
|
||||
var result = await repository.GetChangeLog(serviceRequest, null, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение
|
||||
/// </summary>
|
||||
/// <param name="uid"></param>
|
||||
/// <param name="updateFrom"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("/api/telemetry/{uid}/[controller]")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> Get(string uid, DateTimeOffset? updateFrom, CancellationToken token)
|
||||
{
|
||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid) ?? -1;
|
||||
|
||||
if (idWell < 0)
|
||||
return this.ValidationBadRequest(nameof(uid), "Скважина по uid не найдена");
|
||||
|
||||
await AssertUserHasAccessToWell(idWell, token);
|
||||
|
||||
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(new ProcessMapPlanBaseRequest()
|
||||
{
|
||||
UpdateFrom = updateFrom,
|
||||
}, idWell);
|
||||
|
||||
var result = await repository.GetChangeLog(serviceRequest, null, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Изменения за определенную дату
|
||||
/// </summary>
|
||||
@ -156,7 +209,7 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
[HttpGet("changeLog")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<IEnumerable<TDto>>> GetChangeLog([FromRoute] int idWell, [FromQuery] DateOnly? date, CancellationToken token)
|
||||
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> GetChangeLog([FromRoute] int idWell, [FromQuery] DateOnly? date, CancellationToken token)
|
||||
{
|
||||
await AssertUserHasAccessToWell(idWell, token);
|
||||
|
||||
|
@ -15,8 +15,9 @@ public class ProcessMapPlanDrillingController : ProcessMapPlanBaseController<Pro
|
||||
public ProcessMapPlanDrillingController(IChangeLogRepository<ProcessMapPlanDrillingDto, ProcessMapPlanBaseRequestWithWell> repository,
|
||||
IWellService wellService,
|
||||
ProcessMapPlanDrillingParser parserService,
|
||||
ITelemetryService telemetryService,
|
||||
ProcessMapPlanDrillingExportService processMapPlanExportService)
|
||||
: base(repository, wellService, parserService, processMapPlanExportService)
|
||||
: base(repository, wellService, parserService, processMapPlanExportService, telemetryService)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,9 @@ public class ProcessMapPlanReamController : ProcessMapPlanBaseController<Process
|
||||
public ProcessMapPlanReamController(IChangeLogRepository<ProcessMapPlanReamDto, ProcessMapPlanBaseRequestWithWell> repository,
|
||||
IWellService wellService,
|
||||
ProcessMapPlanReamParser parserService,
|
||||
ITelemetryService telemetryService,
|
||||
ProcessMapPlanReamExportService processMapPlanExportService)
|
||||
: base(repository, wellService, parserService, processMapPlanExportService)
|
||||
: base(repository, wellService, parserService, processMapPlanExportService, telemetryService)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user