using Yw.DAL.SQLite;
|
|
namespace PBS.DAL.SQLite
|
{
|
/// <summary>
|
/// 模型模板
|
///</summary>
|
public class ModelTemplate : BaseDAL_Paras_Flags_TagName_Sorter_UseStatus<PBS.Entity.ModelTemplate>, IModelTemplate
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return PBS.ConfigHelper.SQLiteConnectionConfig; }
|
}
|
|
|
|
/// <summary>
|
/// 通过 GroupID 获取
|
/// </summary>
|
public List<PBS.Entity.ModelTemplate> GetByGroupID(long GroupID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<PBS.Entity.ModelTemplate>()
|
.Where(x => x.GroupID == GroupID).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 通过 GroupIds 获取
|
/// </summary>
|
public List<PBS.Entity.ModelTemplate> GetByGroupIds(List<long> GroupIds)
|
{
|
if (GroupIds == null || !GroupIds.Any())
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<PBS.Entity.ModelTemplate>()
|
.Where(x => GroupIds.Contains(x.GroupID)).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 更新 GroupID
|
/// </summary>
|
public bool UpdateGroupID(long ID, long GroupID)
|
{
|
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Updateable<PBS.Entity.ModelTemplate>()
|
.SetColumns(x => x.GroupID == GroupID)
|
.Where(x => x.ID == ID)
|
.ExecuteCommand() > 0;
|
}
|
}
|
|
/// <summary>
|
/// 批量更新 GroupID
|
/// </summary>
|
public bool UpdateGroupIds(List<(long ID, long GroupID)> list)
|
{
|
if (list == null || list.Count < 1)
|
return false;
|
using (var db = new SqlSugarClient(this.ConnectionConfig))
|
{
|
var entityList = list.Select(x => new PBS.Entity.ModelTemplate() { ID = x.ID, GroupID = x.GroupID }).ToList();
|
return db.Updateable(entityList)
|
.UpdateColumns(nameof(PBS.Entity.ModelTemplate.GroupID))
|
.ExecuteCommandHasChange();
|
}
|
}
|
|
|
}
|
}
|