namespace Yw.DAL.PostgreSql
|
{
|
/// <summary>
|
/// 运行分析配置
|
/// </summary>
|
public partial class RunAnalyConfigure : BaseDAL<Entity.RunAnalyConfigure>, IRunAnalyConfigure
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return ConfigHelper.PostgreSqlConnectionConfig; }
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public Entity.RunAnalyConfigure GetByObjectTypeAndObjectID(string ObjectType, long ObjectID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.RunAnalyConfigure>()
|
.Where(x => x.ObjectType == ObjectType && x.ObjectID == ObjectID)
|
.First();
|
}
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public long InsertOrUpdate(Entity.RunAnalyConfigurePure pure)
|
{
|
if (pure == null)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var entity = db.Queryable<Entity.RunAnalyConfigure>()
|
.Where(x => x.ObjectType == pure.ObjectType && x.ObjectID == pure.ObjectID)
|
.First();
|
if (entity == null)
|
{
|
entity = new Entity.RunAnalyConfigure(pure);
|
}
|
else
|
{
|
entity.Reset(pure);
|
}
|
|
if (entity.ID < 1)
|
{
|
entity.ID = db.Insertable(entity).ExecuteReturnSnowflakeId();
|
if (entity.ID < 1)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
else
|
{
|
var bol = db.Updateable(entity).ExecuteCommandHasChange();
|
if (!bol)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
return entity.ID;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 设置
|
/// </summary>
|
public bool Set(List<Entity.RunAnalyConfigurePure> pureList)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
if (pureList != null && pureList.Count > 0)
|
{
|
foreach (var pure in pureList)
|
{
|
var entity = db.Queryable<Entity.RunAnalyConfigure>()
|
.Where(x => x.ObjectType == pure.ObjectType && x.ObjectID == pure.ObjectID)
|
.First();
|
if (entity == null)
|
{
|
entity = new Entity.RunAnalyConfigure(pure);
|
}
|
else
|
{
|
entity.Reset(pure);
|
}
|
|
if (entity.ID < 1)
|
{
|
entity.ID = db.Insertable(entity).ExecuteReturnSnowflakeId();
|
if (entity.ID < 1)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
else
|
{
|
var bol = db.Updateable(entity).ExecuteCommandHasChange();
|
if (!bol)
|
{
|
db.RollbackTran();
|
return false;
|
}
|
}
|
}
|
}
|
|
db.CommitTran();
|
return true;
|
}
|
catch
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 通过 ObjectType 和 ObjectID 删除
|
/// </summary>
|
public bool DeleteByObjectTypeAndObjectID(string ObjectType, long ObjectID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Deleteable<Entity.RunAnalyConfigure>()
|
.Where(x => x.ObjectType == ObjectType && x.ObjectID == ObjectID)
|
.ExecuteCommandHasChange();
|
}
|
}
|
|
}
|
}
|