Fix ProcessMapPlanBaseRequest

This commit is contained in:
ngfrolov 2024-01-22 13:16:39 +05:00
parent b67c30a2c7
commit bbfe42c4f0
Signed by untrusted user who does not match committer: ng.frolov
GPG Key ID: E99907A0357B29A7
5 changed files with 16 additions and 29 deletions

View File

@ -41,11 +41,12 @@ public interface IProcessMapPlanBaseRepository<T>: IChangeLogRepository<T>
/// <returns></returns>
Task<IEnumerable<T>> GetChangeLog(int idWell, DateOnly? date, CancellationToken token);
/// <summary>
/// Получение записей по параметрам
/// </summary>
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<T>> Get(ProcessMapPlanBaseRequest request, CancellationToken token);
/// <summary>
/// Получение записей по параметрам
/// </summary>
/// <param name="idWell"></param>
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<T>> Get(int idWell, ProcessMapPlanBaseRequest request, CancellationToken token);
}

View File

@ -8,12 +8,6 @@ namespace AsbCloudApp.Requests;
/// </summary>
public class ProcessMapPlanBaseRequest: ChangeLogBaseRequest
{
/// <summary>
/// Идентификатор скважины
/// </summary>
[Range(1, int.MaxValue, ErrorMessage = "Id скважины - положительное число")]
public int IdWell { get; set; }
/// <summary>
/// Тип секции
/// </summary>

View File

@ -98,14 +98,14 @@ public class ProcessMapPlanBaseRepository<TDto, TEntity> : IProcessMapPlanBaseRe
return result;
}
public async Task<IEnumerable<TDto>> Get(ProcessMapPlanBaseRequest request, CancellationToken token)
public async Task<IEnumerable<TDto>> Get(int idWell, ProcessMapPlanBaseRequest request, CancellationToken token)
{
var timezone = wellService.GetTimezone(request.IdWell);
var timezone = wellService.GetTimezone(idWell);
var offset = TimeSpan.FromHours(timezone.Hours);
var query = context
.Set<TEntity>()
.Where(e => e.IdWell == request.IdWell);
.Where(e => e.IdWell == idWell);
if(request.IdWellSectionType.HasValue)
query = query.Where(e => e.IdWellSectionType == request.IdWellSectionType);

View File

@ -351,10 +351,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
var offset = TimeSpan.FromHours(timezoneHours);
//act
var request = new ProcessMapPlanBaseRequest
{
IdWell = dto.IdWell,
};
var request = new ProcessMapPlanBaseRequest();
var response = await client.Get(dto.IdWell, request);
//assert
@ -387,8 +384,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
var offset = TimeSpan.FromHours(timezoneHours);
//act
var request = new ProcessMapPlanBaseRequest {
IdWell = dto.IdWell,
var request = new ProcessMapPlanBaseRequest {
Moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, 0, TimeSpan.Zero)
};
var response = await client.Get(dto.IdWell, request);
@ -441,7 +437,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//act
var request = new ProcessMapPlanBaseRequest
{
IdWell = dto.IdWell,
Moment = now.AddMinutes(0.5),
};
var response = await client.Get(dto.IdWell, request);
@ -449,7 +444,7 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.NotNull(response.Content);
Assert.Equal(1, response.Content.Count());
Assert.Single(response.Content);
}
[Fact]
@ -475,7 +470,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//act
var request = new ProcessMapPlanBaseRequest
{
IdWell = dto.IdWell,
IdWellSectionType = 2,
};
var response = await client.Get(dto.IdWell, request);
@ -525,7 +519,6 @@ public class ProcessMapPlanDrillingControllerTest: BaseIntegrationTest
//act
var request = new ProcessMapPlanBaseRequest
{
IdWell = dto.IdWell,
UpdateFrom = updateFrom,
};
var response = await client.Get(dto.IdWell, request);

View File

@ -101,9 +101,8 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<ActionResult<IEnumerable<TDto>>> Get([FromRoute] int idWell, [FromQuery]ProcessMapPlanBaseRequest request, CancellationToken token)
{
request.IdWell = idWell;
await AssertUserHasAccessToWell(request.IdWell, token);
var result = await repository.Get(request, token);
await AssertUserHasAccessToWell(idWell, token);
var result = await repository.Get(idWell, request, token);
return Ok(result);
}