forked from ddrilling/AsbCloudServer
Правки после ревью
This commit is contained in:
parent
ba2370ae15
commit
04c984e558
@ -48,7 +48,7 @@ namespace AsbCloudApp.Repositories
|
|||||||
int id,
|
int id,
|
||||||
int operationType,
|
int operationType,
|
||||||
int? take,
|
int? take,
|
||||||
IEnumerable<string> sortFields,
|
IEnumerable<string>? sortFields,
|
||||||
CancellationToken token);
|
CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -75,44 +75,42 @@ public class WellOperationRepository : CrudRepositoryBase<WellOperationDto, Well
|
|||||||
int id,
|
int id,
|
||||||
int operationType,
|
int operationType,
|
||||||
int? take,
|
int? take,
|
||||||
IEnumerable<string> sortFields,
|
IEnumerable<string>? sortFields,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = GetQuery()
|
var request = new WellOperationRequest(new[] { idWell })
|
||||||
.Where(o => o.IdType == operationType &&
|
{
|
||||||
o.IdWell == idWell);
|
OperationType = operationType,
|
||||||
|
SortFields = sortFields,
|
||||||
if (!await query.AnyAsync(x => x.Id == id, token))
|
};
|
||||||
return null;
|
|
||||||
|
|
||||||
query = sortFields?.Any() is true ? query.SortBy(sortFields) : query.OrderBy(e => e.DateStart);
|
var (wellOperations, count) = await GetWithDaysAndNpvAsync(request, token);
|
||||||
|
|
||||||
var skip = 0;
|
var skip = 0;
|
||||||
take ??= 32;
|
take ??= 32;
|
||||||
|
|
||||||
var count = await query.CountAsync(token);
|
|
||||||
|
|
||||||
while (skip < count)
|
while (skip < count)
|
||||||
{
|
{
|
||||||
var isExists = await query.Skip(skip)
|
var page = wellOperations.Skip(skip)
|
||||||
.Take(take.Value)
|
.Take(take.Value);
|
||||||
.AnyAsync(x => x.Id == id, token);
|
|
||||||
|
|
||||||
if (isExists)
|
if (page.Any(x => x.Id == id))
|
||||||
break;
|
{
|
||||||
|
var paginationContainer = new PaginationContainer<WellOperationDto>
|
||||||
|
{
|
||||||
|
Skip = skip,
|
||||||
|
Take = take.Value,
|
||||||
|
Items = page,
|
||||||
|
Count = count
|
||||||
|
};
|
||||||
|
|
||||||
|
return paginationContainer;
|
||||||
|
}
|
||||||
|
|
||||||
skip += take.Value;
|
skip += take.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = new WellOperationRequest(new[] { idWell })
|
return null;
|
||||||
{
|
|
||||||
OperationType = operationType,
|
|
||||||
Skip = skip,
|
|
||||||
Take = take,
|
|
||||||
SortFields = sortFields
|
|
||||||
};
|
|
||||||
|
|
||||||
return await GetPageAsync(request, token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<WellGroupOpertionDto>> GetGroupOperationsStatAsync(WellOperationRequest request, CancellationToken token)
|
public async Task<IEnumerable<WellGroupOpertionDto>> GetGroupOperationsStatAsync(WellOperationRequest request, CancellationToken token)
|
||||||
|
@ -213,7 +213,7 @@ public class WellOperationController : ControllerBase
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("getPageWithOperation")]
|
[HttpGet("getPageWithOperation")]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(int), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PaginationContainer<WellOperationDto>), StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> GetPageWithOperationAsync([FromRoute] int idWell,
|
public async Task<IActionResult> GetPageWithOperationAsync([FromRoute] int idWell,
|
||||||
int id,
|
int id,
|
||||||
int operationType,
|
int operationType,
|
||||||
@ -224,12 +224,12 @@ public class WellOperationController : ControllerBase
|
|||||||
if (!await CanUserAccessToWellAsync(idWell, token))
|
if (!await CanUserAccessToWellAsync(idWell, token))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var indexPage = await wellOperationRepository.GetPageAsync(idWell, id, operationType, take, sortFields, token);
|
var paginationContainer = await wellOperationRepository.GetPageAsync(idWell, id, operationType, take, sortFields, token);
|
||||||
|
|
||||||
if (indexPage == null)
|
if (paginationContainer == null)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
return Ok(indexPage);
|
return Ok(paginationContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user