2024-03-07 14:03:22 +08:00
|
|
|
|
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.QualifiedLimitList)
|
|
|
|
|
.Includes(m => m.GradeLimitList)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
//分页查询
|
|
|
|
|
public List<Product> GetListNav(int pageNum, int pageSize, ref int totalCount, Expression<Func<Product, bool>> exp)
|
|
|
|
|
{
|
|
|
|
|
return base.AsSugarClient().Queryable<Product>()
|
|
|
|
|
.WhereIF(exp != null, exp)
|
|
|
|
|
.OrderByDescending(m => m.CreateTime)
|
|
|
|
|
.ToPageList(pageNum, pageSize, ref totalCount);
|
|
|
|
|
}
|
|
|
|
|
public Product GetModelNav(int id)
|
|
|
|
|
{
|
|
|
|
|
return base.AsSugarClient().Queryable<Product>()
|
|
|
|
|
//.Includes(m => m.ClassesInfo)
|
|
|
|
|
.Includes(m => m.QualifiedLimitList)
|
|
|
|
|
.Includes(m => m.GradeLimitList)
|
|
|
|
|
.First(m => m.Id == id);
|
|
|
|
|
}
|
|
|
|
|
public Product GetModelNav(string code)
|
|
|
|
|
{
|
|
|
|
|
return base.AsSugarClient().Queryable<Product>()
|
|
|
|
|
//.Includes(m => m.ClassesInfo)
|
|
|
|
|
.Includes(m => m.QualifiedLimitList)
|
|
|
|
|
.Includes(m => m.GradeLimitList)
|
|
|
|
|
.First(m => m.Code == code);
|
|
|
|
|
}
|
2024-05-21 14:22:10 +08:00
|
|
|
|
public Product GetModelNavByName(string name)
|
|
|
|
|
{
|
|
|
|
|
return base.AsSugarClient().Queryable<Product>()
|
|
|
|
|
//.Includes(m => m.ClassesInfo)
|
|
|
|
|
.Includes(m => m.QualifiedLimitList)
|
|
|
|
|
.Includes(m => m.GradeLimitList)
|
|
|
|
|
.First(m => m.Name == name);
|
|
|
|
|
}
|
2024-03-07 14:03:22 +08:00
|
|
|
|
public bool InsertNav(Models.Product model)
|
|
|
|
|
{
|
|
|
|
|
return base.AsSugarClient().InsertNav(model)
|
|
|
|
|
//.Include(a => a.ProductParamsList)//.ThenInclude(z1 => z1.RoomList) //插入2层 Root->ShoolA->RoomList
|
|
|
|
|
.Include(m => m.QualifiedLimitList)
|
|
|
|
|
.Include(m => m.GradeLimitList)
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
public bool UpdateNav(Models.Product model)
|
|
|
|
|
{
|
|
|
|
|
return base.AsSugarClient().UpdateNav(model)
|
|
|
|
|
.Include(m => m.QualifiedLimitList)
|
|
|
|
|
.Include(m => m.GradeLimitList)
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
public bool DelNav(Models.Product model)
|
|
|
|
|
{
|
|
|
|
|
return base.AsSugarClient().DeleteNav(model)
|
|
|
|
|
.Include(m => m.QualifiedLimitList)
|
|
|
|
|
.Include(m => m.GradeLimitList)
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 注:导航更新子表时会先把子表当前pid全delete再重新insert,即使子表数据和Id都没变动
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="model"></param>
|
|
|
|
|
///// <param name="rootOption"></param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//public bool UpdateNav(Models.Product model, UpdateNavRootOptions rootOption = null)
|
|
|
|
|
//{
|
|
|
|
|
// return base.AsSugarClient().UpdateNav(model, rootOption)
|
|
|
|
|
// //会先把子表当前pid全delete再重新insert,即使子表数据和Id都没变动
|
|
|
|
|
// //.Include(a => a.ProductParamsList)//.ThenInclude(z1 => z1.RoomList) //插入2层 Root->ShoolA->RoomList
|
|
|
|
|
// .ExecuteCommand();
|
|
|
|
|
//}
|
|
|
|
|
//public bool DelNav(Models.Product model)
|
|
|
|
|
//{
|
|
|
|
|
// return base.AsSugarClient().DeleteNav(model)
|
|
|
|
|
// //.Include(a => a.ProductParamsList)//.ThenInclude(z1 => z1.RoomList) //插入2层 Root->ShoolA->RoomList
|
|
|
|
|
// .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);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|