Рефакторинг
This commit is contained in:
parent
198a65b1d2
commit
25afd50793
@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Persistence.Models;
|
using Persistence.Models;
|
||||||
using Persistence.Models.Requests;
|
using Persistence.Models.Requests;
|
||||||
using Persistence.Repositories;
|
using Persistence.Repositories;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace Persistence.API.Controllers;
|
namespace Persistence.API.Controllers;
|
||||||
|
|
||||||
@ -19,7 +20,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ActionResult<int>> Add(
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> Add(
|
||||||
Guid idDiscriminator,
|
Guid idDiscriminator,
|
||||||
[FromBody] DataWithWellDepthAndSectionDto dto,
|
[FromBody] DataWithWellDepthAndSectionDto dto,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
@ -31,7 +33,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("range")]
|
[HttpPost("range")]
|
||||||
public async Task<ActionResult<int>> AddRange(
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> AddRange(
|
||||||
Guid idDiscriminator,
|
Guid idDiscriminator,
|
||||||
[FromBody] IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
[FromBody] IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
@ -42,7 +45,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public async Task<ActionResult<int>> Delete(Guid id, CancellationToken token)
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> Delete(Guid id, CancellationToken token)
|
||||||
{
|
{
|
||||||
var userId = User.GetUserId<Guid>();
|
var userId = User.GetUserId<Guid>();
|
||||||
var result = await repository.MarkAsDeleted(userId, [id], token);
|
var result = await repository.MarkAsDeleted(userId, [id], token);
|
||||||
@ -51,7 +55,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("range")]
|
[HttpDelete("range")]
|
||||||
public async Task<ActionResult<int>> DeleteRange(IEnumerable<Guid> ids, CancellationToken token)
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> DeleteRange(IEnumerable<Guid> ids, CancellationToken token)
|
||||||
{
|
{
|
||||||
var userId = User.GetUserId<Guid>();
|
var userId = User.GetUserId<Guid>();
|
||||||
var result = await repository.MarkAsDeleted(userId, ids, token);
|
var result = await repository.MarkAsDeleted(userId, ids, token);
|
||||||
@ -60,6 +65,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("replace")]
|
[HttpPost("replace")]
|
||||||
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> ClearAndInsertRange(
|
public async Task<IActionResult> ClearAndInsertRange(
|
||||||
Guid idDiscriminator,
|
Guid idDiscriminator,
|
||||||
IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
||||||
@ -71,7 +77,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public async Task<ActionResult<int>> Update(
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> Update(
|
||||||
Guid idDiscriminator,
|
Guid idDiscriminator,
|
||||||
DataWithWellDepthAndSectionDto dto,
|
DataWithWellDepthAndSectionDto dto,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
@ -83,7 +90,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("range")]
|
[HttpPut("range")]
|
||||||
public async Task<ActionResult<int>> UpdateRange(
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> UpdateRange(
|
||||||
Guid idDiscriminator,
|
Guid idDiscriminator,
|
||||||
IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
@ -95,7 +103,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<PaginationContainer<DataWithWellDepthAndSectionDto>>> GetCurrent(
|
[ProducesResponseType(typeof(PaginationContainer<DataWithWellDepthAndSectionDto>), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetCurrent(
|
||||||
Guid idDiscriminator,
|
Guid idDiscriminator,
|
||||||
[FromQuery]SectionPartRequest request,
|
[FromQuery]SectionPartRequest request,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
@ -107,7 +116,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("moment")]
|
[HttpGet("moment")]
|
||||||
public async Task<ActionResult<PaginationContainer<DataWithWellDepthAndSectionDto>>> GetByDate(
|
[ProducesResponseType(typeof(PaginationContainer<DataWithWellDepthAndSectionDto>), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetByDate(
|
||||||
Guid idDiscriminator,
|
Guid idDiscriminator,
|
||||||
DateTimeOffset moment,
|
DateTimeOffset moment,
|
||||||
SectionPartRequest request,
|
SectionPartRequest request,
|
||||||
@ -119,7 +129,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("history")]
|
[HttpGet("history")]
|
||||||
public async Task<ActionResult<IEnumerable<ChangeLogDto>>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
[ProducesResponseType(typeof(IEnumerable<ChangeLogDto>), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await repository.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd, token);
|
var result = await repository.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd, token);
|
||||||
|
|
||||||
@ -127,7 +138,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("datesChange")]
|
[HttpGet("datesChange")]
|
||||||
public async Task<ActionResult<IEnumerable<DateOnly>>> GetDatesChange(Guid idDiscriminator, CancellationToken token)
|
[ProducesResponseType(typeof(IEnumerable<DateOnly>), (int)HttpStatusCode.OK)]
|
||||||
|
public async Task<IActionResult> GetDatesChange(Guid idDiscriminator, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await repository.GetDatesChange(idDiscriminator, token);
|
var result = await repository.GetDatesChange(idDiscriminator, token);
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="request">параметры запроса</param>
|
/// <param name="request">параметры запроса</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<PaginationContainer<DataWithWellDepthAndSectionDto>>> GetCurrent(Guid idDiscriminator, SectionPartRequest request, CancellationToken token);
|
Task<IActionResult> GetCurrent(Guid idDiscriminator, SectionPartRequest request, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение данных на определенную дату (с пагинацией)
|
/// Получение данных на определенную дату (с пагинацией)
|
||||||
@ -35,7 +35,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="request">параметры запроса</param>
|
/// <param name="request">параметры запроса</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<PaginationContainer<DataWithWellDepthAndSectionDto>>> GetByDate(Guid idDiscriminator, DateTimeOffset moment, SectionPartRequest request, CancellationToken token);
|
Task<IActionResult> GetByDate(Guid idDiscriminator, DateTimeOffset moment, SectionPartRequest request, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение исторических данных за определенный период времени
|
/// Получение исторических данных за определенный период времени
|
||||||
@ -45,7 +45,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="dateEnd"></param>
|
/// <param name="dateEnd"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<IEnumerable<ChangeLogDto>>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token);
|
Task<IActionResult> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить одну запись
|
/// Добавить одну запись
|
||||||
@ -54,7 +54,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> Add(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token);
|
Task<IActionResult> Add(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить несколько записей
|
/// Добавить несколько записей
|
||||||
@ -63,7 +63,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> AddRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
Task<IActionResult> AddRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить одну запись
|
/// Обновить одну запись
|
||||||
@ -72,7 +72,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> Update(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token);
|
Task<IActionResult> Update(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить несколько записей
|
/// Обновить несколько записей
|
||||||
@ -81,7 +81,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> UpdateRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
Task<IActionResult> UpdateRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить одну запись
|
/// Удалить одну запись
|
||||||
@ -89,7 +89,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> Delete(Guid id, CancellationToken token);
|
Task<IActionResult> Delete(Guid id, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить несколько записей
|
/// Удалить несколько записей
|
||||||
@ -97,7 +97,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> DeleteRange(IEnumerable<Guid> ids, CancellationToken token);
|
Task<IActionResult> DeleteRange(IEnumerable<Guid> ids, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени)
|
/// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени)
|
||||||
@ -105,5 +105,5 @@ public interface IChangeLogApi
|
|||||||
/// <param name="idDiscriminator"></param>
|
/// <param name="idDiscriminator"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<IEnumerable<DateOnly>>> GetDatesChange(Guid idDiscriminator, CancellationToken token);
|
Task<IActionResult> GetDatesChange(Guid idDiscriminator, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user