117 lines
4.1 KiB
C#
117 lines
4.1 KiB
C#
using HL_FristAidPlatform_Help;
|
|
using HL_FristAidPlatform_IDataBase;
|
|
using HL_FristAidPlatform_Models;
|
|
using SqlSugar;
|
|
using System.Collections.Generic;
|
|
|
|
namespace HL_FristAidPlatform_DataBase
|
|
{
|
|
public class T_SYS_UserHospitalDB : BaseDB, IT_SYS_UserHospital
|
|
{
|
|
public SqlSugarClient db = GetClient();
|
|
|
|
/// <summary>
|
|
/// 新增
|
|
/// </summary>
|
|
/// <param name="userRole"></param>
|
|
/// <returns></returns>
|
|
public bool Add(T_SYS_UserHospital userRole)
|
|
{
|
|
return db.Insertable(userRole).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 1 ? true : false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 物理删除
|
|
/// </summary>
|
|
/// <param name="guids"></param>
|
|
/// <returns></returns>
|
|
public bool Dels(dynamic[] guids)
|
|
{
|
|
//return db.DeleteByIds(guids);
|
|
return db.Deleteable<T_SYS_UserHospital>().In(new dynamic[] { guids }).ExecuteCommand() == 1 ? true : false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 逻辑删除
|
|
/// </summary>
|
|
/// <param name="guid"></param>
|
|
/// <param name="deleteFlag"></param>
|
|
/// <returns></returns>
|
|
public int LogicalDelete(string guid, int deleteFlag)
|
|
{
|
|
return db.Updateable<T_SYS_UserHospital>().SetColumns(it => new T_SYS_UserHospital() { DeleteFlag = deleteFlag }).Where(it => it.GUID == guid).ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据院区编号(GUID)物理删除
|
|
/// 用于删除院区时同时删除所有用户的关联信息
|
|
/// </summary>
|
|
/// <param name="hospitalGuid">院区编号(GUID)</param>
|
|
/// <returns></returns>
|
|
public int DeleteByHospitalGuid(string hospitalGuid)
|
|
{
|
|
return db.Deleteable<T_SYS_UserHospital>().Where(it => it.HospitalGUID == hospitalGuid).ExecuteCommand();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="userRole"></param>
|
|
/// <returns></returns>
|
|
public bool Update(T_SYS_UserHospital userRole)
|
|
{
|
|
return db.Updateable(userRole).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand() == 1 ? true : false;
|
|
}
|
|
|
|
public T_SYS_UserHospital Get(string guid)
|
|
{
|
|
return db.Queryable<T_SYS_UserHospital>().First(it => it.GUID == guid);
|
|
}
|
|
|
|
public TableModel<T_SYS_UserHospital> GetList()
|
|
{
|
|
List<T_SYS_UserHospital> data = db.Queryable<T_SYS_UserHospital>().Where(it => it.DeleteFlag == 0).ToList();
|
|
TableModel<T_SYS_UserHospital> t = new TableModel<T_SYS_UserHospital>();
|
|
t.Code = 0;
|
|
t.TotalNumber = data.Count;
|
|
t.Data = data;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据用户ID获取所拥有的院区列表
|
|
/// </summary>
|
|
/// <param name="userID">用户ID</param>
|
|
/// <returns></returns>
|
|
public TableModel<T_SYS_UserHospitalModel> GetListByUserID(long userID)
|
|
{
|
|
TableModel<T_SYS_UserHospitalModel> t = new TableModel<T_SYS_UserHospitalModel>();
|
|
|
|
var listMode = db.Queryable<T_SYS_UserHospital, T_Base_Hospital>((a, b) => new object[] {
|
|
JoinType.Left,a.HospitalGUID==b.GUID,
|
|
}).Where((a, b) => a.UserID == userID && a.DeleteFlag == 0 && b.DeleteFlag == 0)
|
|
.Select((a, b) => new T_SYS_UserHospitalModel
|
|
{
|
|
GUID = a.GUID.ToString(),
|
|
UserID = a.UserID,
|
|
HospitalGUID = a.HospitalGUID,
|
|
CreatorID = a.CreatorID,
|
|
Creator = a.Creator,
|
|
CreationDate = a.CreationDate,
|
|
EditorID = a.EditorID,
|
|
Editor = a.Editor,
|
|
EditTime = a.EditTime,
|
|
DeleteFlag = a.DeleteFlag,
|
|
HospitalName = b.Name.ToString(),
|
|
}).OrderBy((a) => a.CreationDate).ToList();
|
|
|
|
t.Code = 0;
|
|
t.TotalNumber = listMode.Count;
|
|
t.Data = listMode;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
}
|
|
}
|