Добавить парсинг дерева в Get-запрос
This commit is contained in:
parent
83c744939b
commit
8e2c3a3a55
@ -1,4 +1,5 @@
|
|||||||
using DD.Persistence.Models;
|
using DD.Persistence.Filter.Models.Abstractions;
|
||||||
|
using DD.Persistence.Models;
|
||||||
using DD.Persistence.Models.Common;
|
using DD.Persistence.Models.Common;
|
||||||
using DD.Persistence.Repositories;
|
using DD.Persistence.Repositories;
|
||||||
using DD.Persistence.Services.Interfaces;
|
using DD.Persistence.Services.Interfaces;
|
||||||
@ -45,6 +46,7 @@ public class TimestampedValuesController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="discriminatorIds">Набор дискриминаторов</param>
|
/// <param name="discriminatorIds">Набор дискриминаторов</param>
|
||||||
/// <param name="timestampBegin">Фильтр позднее даты</param>
|
/// <param name="timestampBegin">Фильтр позднее даты</param>
|
||||||
|
/// <param name="filterTree">Кастомный фильтр по набору значений</param>
|
||||||
/// <param name="columnNames">Фильтр свойств набора</param>
|
/// <param name="columnNames">Фильтр свойств набора</param>
|
||||||
/// <param name="skip"></param>
|
/// <param name="skip"></param>
|
||||||
/// <param name="take"></param>
|
/// <param name="take"></param>
|
||||||
@ -52,7 +54,12 @@ public class TimestampedValuesController : ControllerBase
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(typeof(IEnumerable<TimestampedValuesDto>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<TimestampedValuesDto>), (int)HttpStatusCode.OK)]
|
||||||
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
||||||
public async Task<ActionResult<IEnumerable<TimestampedValuesDto>>> Get([FromQuery] IEnumerable<Guid> discriminatorIds, DateTimeOffset? timestampBegin, [FromQuery] string[]? columnNames, int skip, int take, CancellationToken token)
|
public async Task<ActionResult<IEnumerable<TimestampedValuesDto>>> Get([FromQuery] IEnumerable<Guid> discriminatorIds,
|
||||||
|
DateTimeOffset? timestampBegin,
|
||||||
|
[FromQuery] TNode? filterTree,
|
||||||
|
[FromQuery] string[]? columnNames,
|
||||||
|
int skip, int take,
|
||||||
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await timestampedValuesService.Get(discriminatorIds, timestampBegin, columnNames, skip, take, token);
|
var result = await timestampedValuesService.Get(discriminatorIds, timestampBegin, columnNames, skip, take, token);
|
||||||
|
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
using Mapster;
|
using DD.Persistence.Filter.Models.Abstractions;
|
||||||
|
using DD.Persistence.Models.Configurations;
|
||||||
|
using DD.Persistence.Services;
|
||||||
|
using DD.Persistence.Services.Interfaces;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Microsoft.OpenApi.Any;
|
using Microsoft.OpenApi.Any;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using DD.Persistence.Models;
|
|
||||||
using DD.Persistence.Models.Configurations;
|
|
||||||
using DD.Persistence.Services;
|
|
||||||
using DD.Persistence.Services.Interfaces;
|
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using DD.Persistence.Database.Entity;
|
|
||||||
|
|
||||||
namespace DD.Persistence.API;
|
namespace DD.Persistence.API;
|
||||||
|
|
||||||
@ -30,6 +28,7 @@ public static class DependencyInjection
|
|||||||
new OpenApiSchema {Type = "number", Format = "float" }
|
new OpenApiSchema {Type = "number", Format = "float" }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
c.MapType<TNode>(() => new OpenApiSchema { Type = "string" });
|
||||||
|
|
||||||
c.CustomOperationIds(e =>
|
c.CustomOperationIds(e =>
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Ardalis.Specification;
|
using Ardalis.Specification;
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Specifications;
|
namespace DD.Persistence.Database.Specifications.Operation;
|
||||||
public class AndSpecification<TEntity> : Specification<TEntity>
|
public class AndSpecification<TEntity> : Specification<TEntity>
|
||||||
{
|
{
|
||||||
public AndSpecification(ISpecification<TEntity> first, ISpecification<TEntity> second)
|
public AndSpecification(ISpecification<TEntity> first, ISpecification<TEntity> second)
|
@ -1,13 +1,13 @@
|
|||||||
using Ardalis.Specification;
|
using Ardalis.Specification;
|
||||||
using DD.Persistence.Database.Postgres.Extensions;
|
using DD.Persistence.Database.Postgres.Extensions;
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Specifications;
|
namespace DD.Persistence.Database.Specifications.Operation;
|
||||||
public class OrSpecification<TEntity> : Specification<TEntity>
|
public class OrSpecification<TEntity> : Specification<TEntity>
|
||||||
{
|
{
|
||||||
public OrSpecification(ISpecification<TEntity> first, ISpecification<TEntity> second)
|
public OrSpecification(ISpecification<TEntity> first, ISpecification<TEntity> second)
|
||||||
{
|
{
|
||||||
var orExpression = first.Or(second);
|
var orExpression = first.Or(second);
|
||||||
if (orExpression == null)
|
if (orExpression == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Query.Where(orExpression);
|
Query.Where(orExpression);
|
@ -1,11 +1,14 @@
|
|||||||
using DD.Persistence.Filter.Models.Enumerations;
|
using DD.Persistence.Filter.Models.Enumerations;
|
||||||
|
using DD.Persistence.Filter.TreeBuilder;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace DD.Persistence.Filter.Models.Abstractions;
|
namespace DD.Persistence.Filter.Models.Abstractions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Абстрактная модель вершины
|
/// Абстрактная модель вершины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class TNode
|
|
||||||
|
public abstract class TNode : IParsable<TNode?>
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public TNode(OperationEnum operation)
|
public TNode(OperationEnum operation)
|
||||||
@ -18,6 +21,30 @@ public abstract class TNode
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public OperationEnum Operation { get; }
|
public OperationEnum Operation { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public static TNode? Parse(string s, IFormatProvider? provider)
|
||||||
|
{
|
||||||
|
var result = s.BuildTree();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out TNode result)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(s))
|
||||||
|
{
|
||||||
|
result = default(TNode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = s.BuildTree();
|
||||||
|
if (result is null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Принять посетителя
|
/// Принять посетителя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -62,15 +62,10 @@ abstract class TerminalExpression : IExpression
|
|||||||
|
|
||||||
private static object? ParseValue(string value)
|
private static object? ParseValue(string value)
|
||||||
{
|
{
|
||||||
value = value.Replace('.', ',');
|
var doubleValue= value.Replace('.', ',');
|
||||||
if (value.Contains(',') && double.TryParse(value, out _))
|
if (double.TryParse(doubleValue, out _))
|
||||||
{
|
{
|
||||||
return double.Parse(value);
|
return double.Parse(doubleValue);
|
||||||
}
|
|
||||||
|
|
||||||
if (int.TryParse(value, out _))
|
|
||||||
{
|
|
||||||
return int.Parse(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
value = value.Trim('\"');
|
value = value.Trim('\"');
|
||||||
|
Loading…
Reference in New Issue
Block a user