using System;

namespace DBEntitys
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class DBFieldNameAttribute : Attribute
    {
        /// <summary>
        /// 别名
        /// </summary>
        public string FieldName { get; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public DBFieldNameAttribute(string fieldName = "")
        {
            FieldName = fieldName;
        }
    }
    
    /// <summary>
    /// 标记实体属性为时间区间字段
    /// 使用此注解的属性在查询时会自动使用 WhereBetween
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class DateRangeFieldAttribute : Attribute
    {
        /// <summary>
        /// 是否为时间区间字段
        /// </summary>
        public bool IsDateRange { get; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="isDateRange">默认为true，标记为时间区间字段</param>
        public DateRangeFieldAttribute(bool isDateRange = true)
        {
            IsDateRange = isDateRange;
        }
    }

    /// <summary>
    /// 标记实体属性在查询时忽略此字段
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class QueryIgnoreAttribute : Attribute
    {
    }

    /// <summary>
    /// 标记实体属性使用 LIKE 查询
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class LikeFieldAttribute : Attribute
    {
    }

    /// <summary>
    /// 标记实体属性使用 IN 查询（字段值为逗号分隔的多个值）
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class InFieldAttribute : Attribute
    {
        /// <summary>
        /// 分隔符，默认为逗号
        /// </summary>
        public char Separator { get; set; } = ',';
    }
}