StableVersion4.3/HL_FristAidPlatform_DataBase/Base/T_Base_TimeAxisGroupDB.cs

104 lines
4.0 KiB
C#

using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System.Collections.Generic;
namespace HL_FristAidPlatform_DataBase
{
/// <summary>
/// 时间几点分组
/// </summary>
public class T_Base_TimeAxisGroupDB : BaseDB, IT_Base_TimeAxisGroup
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 增加一条数据
/// </summary>
public bool Add(T_Base_TimeAxisGroup model)
{
return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 1 ? true : false;
}
/// <summary>
/// 更新一条数据
/// </summary>
public bool Update(T_Base_TimeAxisGroup model)
{
return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand() == 1 ? true : false;
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(int id)
{
return db.Deleteable<T_Base_TimeAxisGroup>().Where(new T_Base_TimeAxisGroup() { ID = id }).ExecuteCommand() == 1 ? true : false;
}
/// <summary>
/// 获得数据列表
/// </summary>
/// <param name="keyWord">关键词</param>
/// <param name="systemModuleID">模块ID</param>
/// <param name="deleteFlag">删除标记</param>
/// <returns></returns>
public TableModel<T_Base_TimeAxisGroupModel> GetList(string keyWord, int systemModuleID, int deleteFlag)
{
TableModel<T_Base_TimeAxisGroupModel> t = new TableModel<T_Base_TimeAxisGroupModel>();
var listMode = db.Queryable<T_Base_TimeAxisGroup, T_SYS_SystemModule>((a, b) => new object[] {
JoinType.Left,a.SystemModuleID==b.ID }).
Where((a, b) => a.SystemModuleID == systemModuleID && b.DeleteFlag == 0).
WhereIF(!string.IsNullOrEmpty(keyWord), (a) => a.GroupName.Contains(keyWord)).
WhereIF(deleteFlag != -1, (a) => a.DeleteFlag == deleteFlag).
Select((a, b) => new T_Base_TimeAxisGroupModel
{
ID = a.ID,
GUID = a.GUID.ToString(),
SystemModuleID = a.SystemModuleID,
GroupName = a.GroupName,
Describe = a.Describe,
LocationX = a.LocationX,
LocationY = a.LocationY,
IsDisplayTimeAxis = a.IsDisplayTimeAxis,
IsDisplayTimeAxisCase = a.IsDisplayTimeAxis.ToString(),
DeleteFlag = a.DeleteFlag,
CreationDate = a.CreationDate,
ModificationDate = a.ModificationDate,
OrderBy = a.OrderBy,
SystemModule = b.SystemName.ToString(),
}).OrderBy((a) => a.OrderBy).ToList();
t.Code = 0;
t.TotalNumber = listMode.Count;
t.Data = listMode;
t.Msg = "成功";
return t;
}
/// <summary>
/// 获得前几行数据
/// </summary>
public T_Base_TimeAxisGroup Get(int id)
{
return db.Queryable<T_Base_TimeAxisGroup>().First(it => it.ID == id);
}
/// <summary>
/// 根据系统模块编号数据列表
/// </summary>
/// <param name="systemModuleID">系统模块编号</param>
/// <returns></returns>
public TableModel<T_Base_TimeAxisGroup> GetListBySystemModuleID(long systemModuleID)
{
List<T_Base_TimeAxisGroup> data = db.Queryable<T_Base_TimeAxisGroup>().Where(it => it.SystemModuleID == systemModuleID && it.DeleteFlag == 0).ToList();
TableModel<T_Base_TimeAxisGroup> list = new TableModel<T_Base_TimeAxisGroup>();
list.Code = 0;
list.TotalNumber = data.Count;
list.Data = data;
list.Msg = "成功";
return list;
}
}
}