112 lines
2.7 KiB
C#
112 lines
2.7 KiB
C#
|
|
using WcsMain.Common;
|
|||
|
|
using WcsMain.DataBase.TableEntity;
|
|||
|
|
using WcsMain.WcsAttribute.AutoFacAttribute;
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace WcsMain.DataBase.Dao;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// tbl_app_db 表的增删改查
|
|||
|
|
/// </summary>
|
|||
|
|
[Component]
|
|||
|
|
public class AppDBDao
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 插入数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appDB"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int Insert(AppDB appDB)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int insertResult = CommonTool.DbServe.Insertable(appDB).ExecuteCommand();
|
|||
|
|
return insertResult;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更新数据,以主键为条件,主键 : DBName
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appDB"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int Update(AppDB appDB)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Updateable(appDB).IgnoreColumns(ignoreAllNullColumns: true);
|
|||
|
|
return sqlFuc.ExecuteCommand();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除数据,以主键为条件
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appDB"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public int Delete(AppDB appDB)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Deleteable(appDB);
|
|||
|
|
return sqlFuc.ExecuteCommand();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查找数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appDB"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<AppDB>? Select(AppDB appDB)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var sqlFuc = CommonTool.DbServe.Queryable<AppDB>();
|
|||
|
|
if (appDB.DBName != null)
|
|||
|
|
{
|
|||
|
|
sqlFuc = sqlFuc.Where(w => w.DBName == appDB.DBName);
|
|||
|
|
}
|
|||
|
|
if (appDB.DBAddress != null)
|
|||
|
|
{
|
|||
|
|
sqlFuc = sqlFuc.Where(w => w.DBAddress == appDB.DBAddress);
|
|||
|
|
}
|
|||
|
|
if (appDB.IsSystem != null)
|
|||
|
|
{
|
|||
|
|
sqlFuc = sqlFuc.Where(w => w.IsSystem == appDB.IsSystem);
|
|||
|
|
}
|
|||
|
|
if (appDB.Remark != null)
|
|||
|
|
{
|
|||
|
|
sqlFuc = sqlFuc.Where(w => w.Remark == appDB.Remark);
|
|||
|
|
}
|
|||
|
|
return sqlFuc.OrderBy(o => new { o.PlcId, o.DBName }).ToList();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
_ = ex;
|
|||
|
|
return default;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查找所有数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<AppDB>? Select() => Select(new AppDB());
|
|||
|
|
|
|||
|
|
}
|