Правки по результатам ревью
This commit is contained in:
parent
f647afcd53
commit
4ccbe4361a
@ -37,7 +37,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
public async Task<IActionResult> AddRange(
|
public async Task<IActionResult> AddRange(
|
||||||
[FromRoute] Guid idDiscriminator,
|
[FromRoute] Guid idDiscriminator,
|
||||||
[FromBody] IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
[FromBody] IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var userId = User.GetUserId<Guid>();
|
var userId = User.GetUserId<Guid>();
|
||||||
var result = await repository.AddRange(userId, idDiscriminator, dtos, token);
|
var result = await repository.AddRange(userId, idDiscriminator, dtos, token);
|
||||||
@ -47,7 +47,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> Delete(Guid id, CancellationToken token = default)
|
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);
|
||||||
@ -57,7 +57,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
|
|
||||||
[HttpDelete("range")]
|
[HttpDelete("range")]
|
||||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> DeleteRange(IEnumerable<Guid> ids, CancellationToken token = default)
|
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);
|
||||||
@ -70,7 +70,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
public async Task<IActionResult> ClearAndAddRange(
|
public async Task<IActionResult> ClearAndAddRange(
|
||||||
[FromRoute] Guid idDiscriminator,
|
[FromRoute] Guid idDiscriminator,
|
||||||
[FromBody] IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
[FromBody] IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var userId = User.GetUserId<Guid>();
|
var userId = User.GetUserId<Guid>();
|
||||||
var result = await repository.ClearAndAddRange(userId, idDiscriminator, dtos, token);
|
var result = await repository.ClearAndAddRange(userId, idDiscriminator, dtos, token);
|
||||||
@ -81,7 +81,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> Update(
|
public async Task<IActionResult> Update(
|
||||||
DataWithWellDepthAndSectionDto dto,
|
DataWithWellDepthAndSectionDto dto,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var userId = User.GetUserId<Guid>();
|
var userId = User.GetUserId<Guid>();
|
||||||
var result = await repository.UpdateRange(userId, [dto], token);
|
var result = await repository.UpdateRange(userId, [dto], token);
|
||||||
@ -93,7 +93,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> UpdateRange(
|
public async Task<IActionResult> UpdateRange(
|
||||||
IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var userId = User.GetUserId<Guid>();
|
var userId = User.GetUserId<Guid>();
|
||||||
var result = await repository.UpdateRange(userId, dtos, token);
|
var result = await repository.UpdateRange(userId, dtos, token);
|
||||||
@ -107,7 +107,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
[FromRoute] Guid idDiscriminator,
|
[FromRoute] Guid idDiscriminator,
|
||||||
[FromQuery] SectionPartRequest filterRequest,
|
[FromQuery] SectionPartRequest filterRequest,
|
||||||
[FromQuery] PaginationRequest paginationRequest,
|
[FromQuery] PaginationRequest paginationRequest,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
var moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
||||||
var result = await repository.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token);
|
var result = await repository.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token);
|
||||||
@ -122,7 +122,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
DateTimeOffset moment,
|
DateTimeOffset moment,
|
||||||
[FromQuery] SectionPartRequest filterRequest,
|
[FromQuery] SectionPartRequest filterRequest,
|
||||||
[FromQuery] PaginationRequest paginationRequest,
|
[FromQuery] PaginationRequest paginationRequest,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await repository.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token);
|
var result = await repository.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token);
|
||||||
|
|
||||||
@ -131,11 +131,12 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
|
|
||||||
[HttpGet("history/{idDiscriminator}")]
|
[HttpGet("history/{idDiscriminator}")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<ChangeLogDto>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<ChangeLogDto>), (int)HttpStatusCode.OK)]
|
||||||
|
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
||||||
public async Task<IActionResult> GetChangeLogForDate(
|
public async Task<IActionResult> GetChangeLogForDate(
|
||||||
[FromRoute] Guid idDiscriminator,
|
[FromRoute] Guid idDiscriminator,
|
||||||
DateTimeOffset dateBegin,
|
DateTimeOffset dateBegin,
|
||||||
DateTimeOffset dateEnd,
|
DateTimeOffset dateEnd,
|
||||||
CancellationToken token = default)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await repository.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token);
|
var result = await repository.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token);
|
||||||
|
|
||||||
@ -144,7 +145,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
|
|
||||||
[HttpGet("datesChange/{idDiscriminator}")]
|
[HttpGet("datesChange/{idDiscriminator}")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<DateOnly>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<DateOnly>), (int)HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetDatesChange([FromRoute] Guid idDiscriminator, CancellationToken token = default)
|
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
||||||
|
public async Task<IActionResult> GetDatesChange([FromRoute] Guid idDiscriminator, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await repository.GetDatesChange(idDiscriminator, token);
|
var result = await repository.GetDatesChange(idDiscriminator, token);
|
||||||
|
|
||||||
@ -153,6 +155,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
|
|
||||||
[HttpGet("part/{idDiscriminator}")]
|
[HttpGet("part/{idDiscriminator}")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<DataWithWellDepthAndSectionDto>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<DataWithWellDepthAndSectionDto>), (int)HttpStatusCode.OK)]
|
||||||
|
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
||||||
public async Task<IActionResult> GetPart([FromRoute] Guid idDiscriminator, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default)
|
public async Task<IActionResult> GetPart([FromRoute] Guid idDiscriminator, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var result = await repository.GetGtDate(idDiscriminator, dateBegin, token);
|
var result = await repository.GetGtDate(idDiscriminator, dateBegin, token);
|
||||||
@ -163,7 +166,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
[HttpGet("datesRange/{idDiscriminator}")]
|
[HttpGet("datesRange/{idDiscriminator}")]
|
||||||
[ProducesResponseType(typeof(DatesRangeDto), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(DatesRangeDto), (int)HttpStatusCode.OK)]
|
||||||
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
||||||
public async Task<IActionResult> GetDatesRangeAsync([FromRoute] Guid idDiscriminator, CancellationToken token = default)
|
public async Task<IActionResult> GetDatesRangeAsync([FromRoute] Guid idDiscriminator, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await repository.GetDatesRange(idDiscriminator, token);
|
var result = await repository.GetDatesRange(idDiscriminator, token);
|
||||||
|
|
||||||
|
@ -67,12 +67,14 @@ public static class QueryBuilders
|
|||||||
.Take(request.Take)
|
.Take(request.Take)
|
||||||
.ToArrayAsync(token);
|
.ToArrayAsync(token);
|
||||||
|
|
||||||
|
var count = await query.CountAsync(token);
|
||||||
|
var items = entities.Select(Convert);
|
||||||
var result = new PaginationContainer<TDto>
|
var result = new PaginationContainer<TDto>
|
||||||
{
|
{
|
||||||
Skip = request.Skip,
|
Skip = request.Skip,
|
||||||
Take = request.Take,
|
Take = request.Take,
|
||||||
Items = entities.Select(Convert),
|
Items = items,
|
||||||
Count = await query.CountAsync(token)
|
Count = count
|
||||||
};
|
};
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user