using Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Service
{
    public class ClassesService : Repository<Models.Classes>
    {
        /// <summary>
        /// (限定3级深度) 0-产品类别 1-目数 10-缺陷类别
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        public List<Classes> GetListNav(int tag)
        {
            return base.AsSugarClient().Queryable<Classes>()
                .Includes(m => m.SubClassesList.OrderBy(s => s.Order).ToList(),
                            sub => sub.SubClassesList.OrderBy(s => s.Order).ToList(),
                            sub2 => sub2.SubClassesList.OrderBy(s => s.Order).ToList())
                .Where(m => m.Tag == tag)
                .ToList();
        }
        /// <summary>
        /// (限定3级深度)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool DelNav(Classes model)
        {
            return base.AsSugarClient().DeleteNav<Classes>(model)
                .Include(a => a.SubClassesList).ThenInclude(z1 => z1.SubClassesList)
                .ExecuteCommand();
        }
        //调用仓储扩展方法
        public List<Models.Classes> GetOrderByJson(string Json)
        {
            return base.CommQuery(Json);
        }
    }
}
