using System;
using Dpz.Core.Infrastructure.ExpressTreeQuery.ComparisonStrategy;
namespace Dpz.Core.Infrastructure.ExpressTreeQuery;
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class QueryFilterAttribute : Attribute
{
/// <summary>
///
/// </summary>
/// <param name="condition">请求参数需要达成的条件</param>
public QueryFilterAttribute(FilterCondition condition)
{
Condition = condition;
// if (!typeof(IComparisonStrategy).IsAssignableFrom(comparisonStrategyType))
// {
// throw new ArgumentException($"{comparisonStrategyType.Name} must implement IComparisonStrategy");
// }
//
// ComparisonStrategy = (IComparisonStrategy)Activator.CreateInstance(comparisonStrategyType)!;
}
/// <summary>
/// 请求参数需要达成的条件
/// </summary>
public FilterCondition Condition { get; }
/// <summary>
/// <code>Condition == FilterCondition.EqualValue</code>
/// 需达成条件的比较值
/// </summary>
public object? ConditionValue { get; set; }
/// <summary>
/// 比较方式
/// 默认为 Equal
/// </summary>
public Comparison Comparison { get; set; } = Comparison.Equal;
/// <summary>
/// 需要比较的字段名称
/// 默认为 Null
/// 为 Null 时,获取与该属性相同的属性名称
/// </summary>
public string? PropertyName { get; set; }
/// <summary>
/// 需要比较字段的值
/// 默认为 string "10001"
/// 值为 "10001" 时,会忽略 PropertyValue 值
/// </summary>
public object? PropertyValue { get; set; } = GenerateConditionFilter.DefaultPropertyValue;
/// <summary>
/// 筛选结束时间 是否 +1 天
/// </summary>
public bool EndAddDay { get; set; }
/// <summary>
/// 是否筛选一天内的时间
/// 只支持 <see cref="DateTime"/> 类型
/// </summary>
public bool FilterInDay { get; set; }
/// <summary>
/// 实体类型
/// </summary>
public Type? EntityType { get; set; }
// /// <summary>
// /// 比较策略类型
// /// </summary>
// public Type ComparisonStrategyType { get; set; }
}