103 lines
5.5 KiB
C#
103 lines
5.5 KiB
C#
|
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 ProductService : Repository<Models.Product>
|
|||
|
{
|
|||
|
//更新选项
|
|||
|
//public class UpdateNavRootOptions
|
|||
|
//{
|
|||
|
// public string[] IgnoreColumns { get; set; }//主表更新忽略列(实体配置特性也可以方便的实现)
|
|||
|
// public string[] UpdateColumns { get; set; }//只更新哪几列
|
|||
|
// public bool IsInsertRoot { get; set; }//强制插入主表 可以实现 更新或者插入效果
|
|||
|
// public string[] IgnoreInsertColumns { get; set; }//主表启用插入忽略列 5.1.3.58
|
|||
|
// public bool IsDiffLogEvent { get; set; }//启用主表差异日志
|
|||
|
// public object DiffLogBizData { get; set; }//差异日志参数
|
|||
|
// public bool IsDisableUpdateRoot { get; set; }//禁更新主表5.1.3.33-preview05
|
|||
|
//}
|
|||
|
public List<Product> GetListNav()
|
|||
|
{
|
|||
|
return base.AsSugarClient().Queryable<Product>()
|
|||
|
.Includes(m => m.ClassesInfo)
|
|||
|
.Includes(m => m.StoreList.Where(c => c.Type == 0).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.DiameterList.Where(c => c.Type == 1).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.ThicknessList.Where(c => c.Type == 2).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.BarcodeList.Where(c => c.Type == 3).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.Barcode2List.Where(c => c.Type == 4).OrderBy(x => x.SPH).OrderBy(x => x.CYL).OrderBy(x => x.ADD).ToList())
|
|||
|
.ToList();
|
|||
|
}
|
|||
|
public Product GetModelNav(int id)
|
|||
|
{
|
|||
|
return base.AsSugarClient().Queryable<Product>()
|
|||
|
.Includes(m => m.ClassesInfo)
|
|||
|
.Includes(m => m.StoreList.Where(c => c.Type == 0).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.DiameterList.Where(c => c.Type == 1).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.ThicknessList.Where(c => c.Type == 2).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.BarcodeList.Where(c => c.Type == 3).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
//.Includes(m => m.Barcode2List.Where(c => c.Type == 4).OrderBy(x => new { x.SPH,x.CYL,x.ADD}).ToList())
|
|||
|
.Includes(m => m.Barcode2List.Where(c => c.Type == 4).OrderBy(x => x.SPH).OrderBy(x => x.CYL).OrderBy(x => x.ADD).ToList())
|
|||
|
.First(m => m.Id == id);
|
|||
|
}
|
|||
|
public Product GetModelNav(string code)
|
|||
|
{
|
|||
|
return base.AsSugarClient().Queryable<Product>()
|
|||
|
.Includes(m => m.ClassesInfo)
|
|||
|
.Includes(m => m.StoreList.Where(c => c.Type == 0).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.DiameterList.Where(c => c.Type == 1).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.ThicknessList.Where(c => c.Type == 2).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.BarcodeList.Where(c => c.Type == 3).OrderBy(x => x.SPH).OrderBy(x => x.CYL).ToList())
|
|||
|
.Includes(m => m.Barcode2List.Where(c => c.Type == 4).OrderBy(x => x.SPH).OrderBy(x => x.CYL).OrderBy(x => x.ADD).ToList())
|
|||
|
.First(m => m.Code == code);
|
|||
|
}
|
|||
|
public bool InsertNav(Models.Product model)
|
|||
|
{
|
|||
|
return base.AsSugarClient().InsertNav(model)
|
|||
|
.Include(a => a.StoreList)//.ThenInclude(z1 => z1.RoomList) //插入2层 Root->ShoolA->RoomList
|
|||
|
.Include(a => a.DiameterList)
|
|||
|
.Include(a => a.ThicknessList)
|
|||
|
.Include(a => a.BarcodeList)
|
|||
|
.Include(a => a.Barcode2List)
|
|||
|
.ExecuteCommand();
|
|||
|
}
|
|||
|
public bool UpdateNav(Models.Product model, UpdateNavRootOptions rootOption = null)
|
|||
|
{
|
|||
|
return base.AsSugarClient().UpdateNav(model, rootOption)
|
|||
|
.Include(a => a.StoreList)
|
|||
|
.Include(a => a.DiameterList)//.ThenInclude(z1 => z1.RoomList) //插入2层 Root->ShoolA->RoomList
|
|||
|
.Include(a => a.ThicknessList)
|
|||
|
.Include(a => a.BarcodeList)
|
|||
|
.Include(a => a.Barcode2List)
|
|||
|
.ExecuteCommand();
|
|||
|
}
|
|||
|
public bool DelNav(Models.Product model)
|
|||
|
{
|
|||
|
return base.AsSugarClient().DeleteNav(model)
|
|||
|
.Include(a => a.StoreList)
|
|||
|
.Include(a => a.DiameterList)//.ThenInclude(z1 => z1.RoomList) //插入2层 Root->ShoolA->RoomList
|
|||
|
.Include(a => a.ThicknessList)
|
|||
|
.Include(a => a.BarcodeList)
|
|||
|
.Include(a => a.Barcode2List)
|
|||
|
.ExecuteCommand();
|
|||
|
}
|
|||
|
|
|||
|
//分页
|
|||
|
//public List<Models.User> GetOrderPage(Expression<Func<Models.User, bool>> where, int pagesize, int pageindex)
|
|||
|
//{
|
|||
|
// return base.GetPageList(where, new SqlSugar.PageModel() { PageIndex = pageindex, PageSize = pagesize }); //使用自已的仓储方法
|
|||
|
//}
|
|||
|
|
|||
|
//调用仓储扩展方法
|
|||
|
//public List<Models.User> GetOrderByJson(string Json)
|
|||
|
//{
|
|||
|
// return base.CommQuery(Json);
|
|||
|
//}
|
|||
|
}
|
|||
|
}
|