StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_ImageDB.cs

163 lines
6.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System.Collections.Generic;
namespace HL_FristAidPlatform_DataBase
{
//T_Service_Image
public class T_Service_ImageDB : BaseDB, IT_Service_Image
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 增加一条数据
/// </summary>
public bool Add(T_Service_Image model)
{
//bool flag = false;
//if (db.Queryable<T_Service_Image>("select * from T_Service_Image where PatientID=" + model.PatientGuid + " and SystemModuleID=" + model.SystemModuleID + "").Count() > 0)
//{
// flag = db.Insertable(model).ExecuteCommandIdentityIntoEntity();
//}
//return flag;
return db.Insertable(model).ExecuteCommandIdentityIntoEntity();
}
/// <summary>
/// 更新一条数据
/// </summary>
public bool Update(T_Service_Image model)
{
return db.Updateable(model).ExecuteCommand() == 0 ? false : true;
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(long ID)
{
return db.Deleteable<T_Service_Image>(it => it.ID == ID).ExecuteCommand() == 0 ? false : true; ;
}
/// <summary>
/// 逻辑删除
/// </summary>
/// <param name="id">编号:大于0删除当前编号的数据小于或等于0删除当前病人+当前模块+当前图片类型的所有图片</param>
/// <param name="patientGuid">患者编号(GUID)</param>
/// <param name="systemModuleID">所属系统模块编号</param>
/// <param name="fileType">图片类型1CT检查2院前首份心电图;3:院内首份心电图</param>
/// <returns></returns>
public int LogicalDelete(long id, string patientGuid, long systemModuleID, int fileType)
{
if (id > 0)
{
return db.Updateable<T_Service_Image>().SetColumns(it => new T_Service_Image() { DeleteFlag = 1 }).Where(it => it.ID == id).ExecuteCommand();
}
else
{
return db.Updateable<T_Service_Image>().SetColumns(it => new T_Service_Image() { DeleteFlag = 1 }).Where(it => it.PatientGuid == patientGuid && it.SystemModuleID == systemModuleID && it.FileType == fileType).ExecuteCommand();
}
}
/// <summary>
/// 分页
/// </summary>
/// <param name="pageIndex">起始页</param>
/// <param name="pageSize">每页大小</param>
/// <param name="patientGuid">患者编号(Guid)</param>
/// <param name="systemModuleID">所属系统编号</param>
/// <returns></returns>
public TableModel<T_Service_Image> GetPageList(int pageIndex, int pageSize, string patientGuid, long systemModuleID)
{
int total = 0;
List<T_Service_Image> data = db.Queryable<T_Service_Image>().Where(it => it.PatientGuid == patientGuid && it.SystemModuleID == systemModuleID).ToPageList(pageIndex, pageSize, ref total);
TableModel<T_Service_Image> t = new TableModel<T_Service_Image>();
t.Code = 0;
t.PageCount = data.Count;
t.TotalNumber = total;
t.Data = data;
t.Msg = "成功";
return t;
}
/// <summary>
/// 获取所有
/// </summary>
/// <param name="patientGuid">患者编号(Guid)</param>
/// <param name="systemModuleID">所属系统编号</param>
/// <param name="fileType">查看图片类型0查询所有</param>
/// <returns></returns>
public TableModel<T_Service_Image> GetList(string patientGuid, long systemModuleID, int fileType)
{
TableModel<T_Service_Image> t = new TableModel<T_Service_Image>();
var listMode = db.Queryable<T_Service_Image>()
.Where(it => it.PatientGuid == patientGuid && it.SystemModuleID == systemModuleID && it.DeleteFlag == 0)
.WhereIF(fileType > 0, it => it.FileType == fileType)
.Select(it => new T_Service_Image
{
ID = it.ID,
GUID = it.GUID.ToString(),
PatientGuid = it.PatientGuid,
SystemModuleID = it.SystemModuleID,
FileName = it.FileName,
FilePath = it.FilePath,
FileType = it.FileType,
FileImage = it.FileImage,
CreateTime = it.CreateTime,
DeleteFlag = it.DeleteFlag,
}).OrderBy((it) => it.CreateTime, OrderByType.Desc).ToList();
t.Code = 0;
t.PageCount = listMode.Count;
t.TotalNumber = listMode.Count;
t.Data = listMode;
t.Msg = "成功";
return t;
}
/// <summary>
/// 获取指定图片
/// </summary>
/// <param name="guid">图片编号(Guid)</param>
/// <returns></returns>
public TableModel<T_Service_Image> GetByGuid(string guid)
{
TableModel<T_Service_Image> t = new TableModel<T_Service_Image>();
var listMode = db.Queryable<T_Service_Image>()
.Where(it => it.GUID == guid && it.DeleteFlag == 0)
.Select(it => new T_Service_Image
{
ID = it.ID,
GUID = it.GUID.ToString(),
PatientGuid = it.PatientGuid,
SystemModuleID = it.SystemModuleID,
FileName = it.FileName,
FilePath = it.FilePath,
FileType = it.FileType,
FileImage = it.FileImage,
CreateTime = it.CreateTime,
DeleteFlag = it.DeleteFlag,
}).OrderBy((it) => it.CreateTime, OrderByType.Desc).ToList();
t.Code = 0;
t.PageCount = listMode.Count;
t.TotalNumber = listMode.Count;
t.Data = listMode;
t.Msg = "成功";
return t;
}
/// <summary>
/// 获得前几行数据
/// </summary>
public T_Service_Image Get(string id)
{
List<T_Service_Image> t_Service_Images = new List<T_Service_Image>();
t_Service_Images = db.Queryable<T_Service_Image>("select * from T_Service_Image where PatientGuid='" + id + "'").ToList();
return t_Service_Images[0];
}
}
}