using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
|
|
namespace IStation.DAL
|
{
|
/// <summary>
|
/// MsSqlDAL RepairRequestFile
|
/// </summary>
|
public partial class ProductInspectionTemplateValue : BaseDAL<Entity.ProductInspectionTemplateValue>
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get
|
{
|
return ConfigHelper.DefaultConnectionConfig;
|
}
|
}
|
/// <summary>
|
/// 插入指定对象到数据库中
|
/// </summary>
|
public override long Insert(Entity.ProductInspectionTemplateValue entity)
|
{
|
if (entity == null)
|
return default;
|
if (entity.ItemID < 1)
|
return default;
|
entity.CreateTime = DateTime.Now;
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Insertable(entity).ExecuteReturnSnowflakeId();
|
}
|
}
|
|
/// <summary>
|
/// 插入指定对象集合到数据库中
|
/// </summary>
|
public override bool Inserts(List<Entity.ProductInspectionTemplateValue> list)
|
{
|
if (list == null || list.Count < 1)
|
return default;
|
var dt = DateTime.Now;
|
foreach (var item in list)
|
item.CreateTime = dt;
|
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Insertable(list).ExecuteReturnSnowflakeIdList().Count() > 0;
|
}
|
}
|
|
/// <summary>
|
/// 插入并返回
|
/// </summary>
|
public override List<long> InsertsR(List<Entity.ProductInspectionTemplateValue> list)
|
{
|
if (list == null || list.Count < 1)
|
return default;
|
var dt = DateTime.Now;
|
foreach (var item in list)
|
item.CreateTime = dt;
|
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Insertable(list).ExecuteReturnSnowflakeIdList();
|
}
|
}
|
|
/// <summary>
|
/// 更新对象属性到数据库中
|
/// </summary>
|
public override bool Update(Entity.ProductInspectionTemplateValue entity)
|
{
|
if (entity == null)
|
return default;
|
if (entity.ItemID < 1)
|
return default;
|
entity.UpdateTime = DateTime.Now;
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable(entity).IgnoreColumns(it => new { it.CreateTime, it.CreateUserID, it.ItemID }).ExecuteCommand() > 0;
|
}
|
}
|
/// <summary>
|
/// 更新使用状态
|
/// </summary>
|
public virtual bool UpdateUseStatus( long ID, int UseStatus, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable<Entity.ProductInspectionTemplateValue>()
|
.SetColumns(x => x.UseStatus == UseStatus)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.ID == ID)
|
.ExecuteCommandHasChange();
|
}
|
}
|
/// <summary>
|
/// 更新指定对象集合到数据库中
|
/// </summary>
|
public override bool Updates(List<Entity.ProductInspectionTemplateValue> list)
|
{
|
if (list == null || list.Count < 1)
|
return default;
|
foreach(var item in list)
|
item.UpdateTime = DateTime.Now;
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable(list).IgnoreColumns(it => new { it.CreateTime, it.CreateUserID, it.ItemID }).ExecuteCommand() > 0;
|
}
|
}
|
|
/// <summary>
|
/// 通过ItemID获取
|
/// </summary>
|
/// <param name="ItemID"></param>
|
/// <returns></returns>
|
public List<Entity.ProductInspectionTemplateValue> GetByItemID(IEnumerable<long> ItemID)
|
{
|
if (ItemID == null || ItemID.Count() == 0)
|
return null;
|
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.ProductInspectionTemplateValue>()
|
.Where(x => ItemID.Contains(x.ItemID)).ToList();
|
}
|
}
|
|
|
|
/// <summary>
|
/// ItemID
|
/// </summary>
|
/// <param name="ItemID"></param>
|
/// <returns></returns>
|
public List<Entity.ProductInspectionTemplateValue> GetByItemID(long ItemID)
|
{
|
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.ProductInspectionTemplateValue>()
|
.Where(x => ItemID == x.ItemID).ToList();
|
}
|
}
|
|
|
/// <summary>
|
/// 更新排序
|
/// </summary>
|
public virtual bool UpdateSortCode(long CorpID, long ID, int SortCode, long UpdateUserID, DateTime UpdateTime)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable<Entity.ProductInspectionTemplateValue>()
|
.SetColumns(x => x.SortCode == SortCode)
|
.SetColumns(x => x.UpdateUserID == UpdateUserID)
|
.SetColumns(x => x.UpdateTime == UpdateTime)
|
.Where(x => x.ID == ID)
|
.ExecuteCommandHasChange();
|
}
|
}
|
/// <summary>
|
/// 更新排序
|
/// </summary>
|
public virtual bool UpdateSorter(long CorpID, List<Entity.TraceSorter> Sorters)
|
{
|
if (Sorters == null || Sorters.Count() < 1)
|
return default;
|
if (Sorters.Exists(x => x.ID < 1))
|
return default;
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable<Entity.ProductInspectionTemplateValue>(Sorters)
|
.UpdateColumns(nameof(Entity.ISorter.SortCode), nameof(Entity.TraceSorter.UpdateUserID), nameof(Entity.TraceSorter.UpdateTime))
|
.ExecuteCommandHasChange();
|
}
|
}
|
}
|
}
|