203 lines
6.9 KiB
C#
203 lines
6.9 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_Service_PathographyDB : BaseDB, IT_Service_Pathography
|
||
{
|
||
public SqlSugarClient db = GetClient();
|
||
|
||
#region 增
|
||
/// <summary>
|
||
/// 新增
|
||
/// </summary>
|
||
/// <param name="model">实体</param>
|
||
/// <returns></returns>
|
||
public bool Add(T_Service_Pathography model)
|
||
{
|
||
return db.Insertable(model).ExecuteCommand() == 0 ? false : true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新增 仅更新赋值的字段
|
||
/// </summary>
|
||
/// <param name="model">实体类</param>
|
||
/// <returns></returns>
|
||
public int AddNotNullColumns(T_Service_Pathography model)
|
||
{
|
||
return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 新增 仅更新赋值的字段
|
||
/// 用于移动端
|
||
/// </summary>
|
||
/// <param name="model">实体类</param>
|
||
/// <returns></returns>
|
||
public int AddForApp(T_Service_Pathography model)
|
||
{
|
||
return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
||
}
|
||
#endregion
|
||
|
||
#region 删
|
||
/// <summary>
|
||
/// 删除一条数据
|
||
/// </summary>
|
||
public bool Delete(long ID)
|
||
{
|
||
return db.Deleteable<T_Service_Pathography>(it => it.ID == ID).ExecuteCommand() == 0 ? false : true; ;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 逻辑删除
|
||
/// </summary>
|
||
/// <param name="model">实体类</param>
|
||
/// <returns></returns>
|
||
public int LogicalDelete(T_Service_Pathography model)
|
||
{
|
||
return db.Updateable(model).UpdateColumns(it => new { it.DeleteFlag, it.EditorID, it.Editor, it.EditTime }).ExecuteCommand();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除
|
||
/// 用于移动端
|
||
/// </summary>
|
||
/// <param name="model">实体类,ID必填</param>
|
||
/// <returns></returns>
|
||
public int DeleteForApp(T_Service_Pathography model)
|
||
{
|
||
return db.Updateable(model).UpdateColumns(it => new { it.DeleteFlag, it.EditorID, it.Editor, it.EditTime }).ExecuteCommand();
|
||
}
|
||
#endregion
|
||
|
||
#region 改
|
||
/// <summary>
|
||
/// 更新一条数据
|
||
/// </summary>
|
||
public bool Update(T_Service_Pathography model)
|
||
{
|
||
return db.Updateable(model).ExecuteCommand() == 0 ? false : true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 仅更新赋值的字段
|
||
/// </summary>
|
||
/// <param name="model">实体类</param>
|
||
/// <returns></returns>
|
||
public int UpdateNotNullColumns(T_Service_Pathography model)
|
||
{
|
||
return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改--仅更新赋值的字段
|
||
/// 用于移动端
|
||
/// </summary>
|
||
/// <param name="model">实体类</param>
|
||
/// <returns></returns>
|
||
public int UpdateForApp(T_Service_Pathography model)
|
||
{
|
||
return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||
}
|
||
#endregion
|
||
|
||
#region 查
|
||
/// <summary>
|
||
/// 得到一个对象实体
|
||
/// </summary>
|
||
public T_Service_Pathography GetModel(long ID)
|
||
{
|
||
return db.Queryable<T_Service_Pathography>().First(it => it.ID == ID);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 得到一个对象实体
|
||
/// 用于移动端
|
||
/// </summary>
|
||
/// <param name="id">患者编号</param>
|
||
/// <param name="guid">GUID</param>
|
||
/// <returns></returns>
|
||
public TableModel<T_Service_Pathography> GetModelForApp(long id, string guid)
|
||
{
|
||
TableModel<T_Service_Pathography> t = new TableModel<T_Service_Pathography>();
|
||
var listMode = db.Queryable<T_Service_Pathography>()
|
||
.Where(it => it.DeleteFlag == 0)
|
||
.WhereIF(id > 0, it => it.ID == id && it.DeleteFlag == 0)
|
||
.WhereIF(!string.IsNullOrEmpty(guid), it => it.GUID == guid).ToList();
|
||
|
||
t.Code = 0;
|
||
t.PageCount = listMode.Count;
|
||
t.TotalNumber = listMode.Count;
|
||
t.Data = listMode;
|
||
t.Msg = "成功";
|
||
return t;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获得前几行数据
|
||
/// </summary>
|
||
/// <param name="pageIndex">起始页</param>
|
||
/// <param name="pageSize">每页条数</param>
|
||
/// <returns></returns>
|
||
public TableModel<T_Service_Pathography> GetPageList(int pageIndex, int pageSize)
|
||
{
|
||
int total = 0;
|
||
List<T_Service_Pathography> data = db.Queryable<T_Service_Pathography>().Where(it => it.DeleteFlag == 0).ToPageList(pageIndex, pageSize, ref total);
|
||
TableModel<T_Service_Pathography> t = new TableModel<T_Service_Pathography>();
|
||
t.Code = 0;
|
||
t.PageCount = data.Count;
|
||
t.TotalNumber = total;
|
||
t.Data = data;
|
||
t.Msg = "成功";
|
||
return t;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据患者编号(GUID) 获取数据信息
|
||
/// </summary>
|
||
/// <param name="patientGuid">病人编号(GUID)</param>
|
||
/// <returns></returns>
|
||
public TableModel<T_Service_Pathography> GetByPatientGuid(string patientGuid)
|
||
{
|
||
TableModel<T_Service_Pathography> t = new TableModel<T_Service_Pathography>();
|
||
|
||
var listMode = db.Queryable<T_Service_Pathography>().Where(it => it.PatientGuid == patientGuid && it.DeleteFlag == 0).OrderBy((it) => it.CreationDate, OrderByType.Desc).ToList();
|
||
|
||
t.Code = 0;
|
||
t.PageCount = listMode.Count;
|
||
t.TotalNumber = listMode.Count;
|
||
t.Data = listMode;
|
||
t.Msg = "成功";
|
||
return t;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据患者编号(GUID) 获取数据信息
|
||
/// 用于移动端
|
||
/// </summary>
|
||
/// <param name="patientGuid">病人编号(GUID)</param>
|
||
/// <returns></returns>
|
||
public TableModel<T_Service_Pathography> GetByPatientGuidForApp(string patientGuid)
|
||
{
|
||
TableModel<T_Service_Pathography> t = new TableModel<T_Service_Pathography>();
|
||
|
||
var listMode = db.Queryable<T_Service_Pathography>().Where(it => it.PatientGuid == patientGuid && it.DeleteFlag == 0).OrderBy((it) => it.CreationDate, OrderByType.Desc).ToList();
|
||
|
||
t.Code = 0;
|
||
t.PageCount = listMode.Count;
|
||
t.TotalNumber = listMode.Count;
|
||
t.Data = listMode;
|
||
t.Msg = "成功";
|
||
return t;
|
||
}
|
||
#endregion
|
||
}
|
||
}
|