featute/ChangeLog #6

Merged
on.nemtina merged 25 commits from featute/ChangeLog into master 2024-12-09 17:44:48 +05:00
3 changed files with 11 additions and 12 deletions
Showing only changes of commit e826a386d2 - Show all commits

View File

@ -66,20 +66,18 @@ public interface IChangeLogClient
/// <summary>
/// Обновить одну запись
/// </summary>
/// <param name="idDiscriminator"></param>
/// <param name="dto"></param>
/// <returns></returns>
[Put($"{BaseRoute}/{{idDiscriminator}}")]
Task<IApiResponse<int>> Update(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto);
[Put($"{BaseRoute}")]
Task<IApiResponse<int>> Update(DataWithWellDepthAndSectionDto dto);
/// <summary>
/// Обновить несколько записей
/// </summary>
/// <param name="idDiscriminator"></param>
/// <param name="dtos"></param>
/// <returns></returns>
[Put($"{BaseRoute}/range/{{idDiscriminator}}")]
Task<IApiResponse<int>> UpdateRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos);
[Put($"{BaseRoute}/range")]
Task<IApiResponse<int>> UpdateRange(IEnumerable<DataWithWellDepthAndSectionDto> dtos);
/// <summary>
/// Удалить одну запись
@ -102,7 +100,7 @@ public interface IChangeLogClient
/// </summary>
/// <param name="idDiscriminator"></param>
/// <returns></returns>
[Get($"{BaseRoute}/datesRange")]
[Get($"{BaseRoute}/datesRange/{{idDiscriminator}}")]
Task<IApiResponse<DatesRangeDto?>> GetDatesRange(Guid idDiscriminator);
}

View File

@ -105,7 +105,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
dto.DepthEnd = dto.DepthEnd + 10;
// act
result = await client.Update(idDiscriminator, dto);
result = await client.Update(dto);
// assert
Assert.Equal(HttpStatusCode.OK, result.StatusCode);
@ -143,7 +143,6 @@ public class ChangeLogControllerTest : BaseIntegrationTest
{
// arrange
var count = 2;
var idDiscriminator = Guid.NewGuid();
var dtos = Generate(count, DateTimeOffset.UtcNow);
var entities = dtos.Select(d => d.Adapt<ChangeLog>()).ToArray();
dbContext.ChangeLog.AddRange(entities);
@ -159,7 +158,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
}).ToArray();
// act
var result = await client.UpdateRange(idDiscriminator, dtos);
var result = await client.UpdateRange(dtos);
// assert
Assert.Equal(HttpStatusCode.OK, result.StatusCode);
@ -298,7 +297,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
entity.DepthEnd = entity.DepthEnd + 10;
}
var dtos = entities.Select(e => e.Adapt<DataWithWellDepthAndSectionDto>()).ToArray();
await client.UpdateRange(idDiscriminator, dtos);
await client.UpdateRange(dtos);
//act
var dateBegin = DateTimeOffset.UtcNow.AddDays(daysBeforeNowFilter);

View File

@ -241,7 +241,9 @@ public class ChangeLogRepository : IChangeLogRepository
.Select(group => new
{
Min = group.Min(e => e.Creation),
Max = group.Max(e => (e.Creation > e.Obsolete ? e.Creation : e.Obsolete!.Value)),
Max = group.Max(e => (e.Obsolete.HasValue && e.Obsolete > e.Creation)
? e.Obsolete.Value

Не все базы так поймут. Лучше для новых сущностей их генерировать самостоятельно (в идеале по седьмой версии).

Не все базы так поймут. Лучше для новых сущностей их генерировать самостоятельно (в идеале по [седьмой версии](https://steven-giesel.com/blogPost/ea42a518-4d8b-4e08-8f73-e542bdd3b983)).
: e.Creation),
});
var values = await query.FirstOrDefaultAsync(token);