using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ewide.Core
{
    public class SearchInfo
    {
        
        /// <summary>
        /// 字段名
        /// </summary>
        public string Field { get; set; }

        /// <summary>
        /// 查询多个条件
        /// </summary>
        public List<string> Value { get; set; }

        /// <summary>
        /// 查询运算符
        /// </summary>
        public string Type { get; set; }
        
        public QueryTypeEnum QueryType
        {
            get
            {
                return Type.ToLower() switch
                {
                    "=" or "equal" => QueryTypeEnum.Equal,
                    "<" or "lessthan" => QueryTypeEnum.LessThan,
                    "<=" or "lessthanorequal" => QueryTypeEnum.LessThanOrEqual,
                    ">" or "greaterthan" => QueryTypeEnum.GreaterThan,
                    ">=" or "greaterthanorequal" => QueryTypeEnum.GreaterThanOrEqual,
                    "start" => QueryTypeEnum.StartWith,
                    "end" => QueryTypeEnum.EndWith,
                    _ => QueryTypeEnum.Like,
                };
            }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public SearchInfo()
        {
            Value = new List<string>();
        }
    }
}
