using HL_FristAidPlatform_Help; using HL_FristAidPlatform_IDataBase; using HL_FristAidPlatform_Models; using SqlSugar; using System; using System.Collections.Generic; namespace HL_FristAidPlatform_DataBase { /// /// 公用字典:用于系统中各个下拉选项值 /// public class T_Base_PublicDictionaryDB : BaseDB, IT_Base_PublicDictionary { public SqlSugarClient db = GetClient(); /// /// 新增 /// /// 实体 /// public bool Add(T_Base_PublicDictionary model) { return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 1 ? true : false; } /// /// 更新一条数据 /// public bool Update(T_Base_PublicDictionary model) { return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand() == 1 ? true : false; } /// /// 删除一条数据 /// public bool Delete(long ID) { return db.Deleteable().Where(new T_Base_PublicDictionary() { ID = Convert.ToInt32(ID) }).ExecuteCommand() == 1 ? true : false; } /// /// 得到一个对象实体 /// public T_Base_PublicDictionary GetModel(long ID) { return db.Queryable().First(it => it.ID == ID); } /// /// 获得前几行数据 /// /// 起始页 /// 每页条数 /// public TableModel GetPageList(int pageIndex, int pageSize) { int total = 0; List data = db.Queryable().Where(it => it.IsEnable == 0).ToPageList(pageIndex, pageSize, ref total); TableModel t = new TableModel(); t.Code = 0; t.PageCount = data.Count; t.TotalNumber = total; t.Data = data; t.Msg = "成功"; return t; } /// /// 根据条件获得数据列表 /// /// 所属系统模块 /// 类型: 参考枚举HL_FristAidPlatform_Public.Enumerate.PublicDictionaryType /// public TableModel GetList(long systemModuleID, int type) { TableModel t = new TableModel(); var listMode = db.Queryable() .Where(it => it.SystemModuleID == systemModuleID && it.IsEnable == 0) .WhereIF(type > 0, it => it.Type == type) .OrderBy((it) => it.OrderBy).ToList(); t.Code = 0; t.PageCount = listMode.Count; t.TotalNumber = listMode.Count; t.Data = listMode; t.Msg = "成功"; return t; } } }