using WcsMain.Common; using WcsMain.DataBase.TableEntity; using WcsMain.WcsAttribute.AutoFacAttribute; namespace WcsMain.DataBase.Dao; /// /// tbl_app_settings 表的增删改查 /// [Component] public class AppSettingsDao { /// /// 添加一条记录 /// /// /// public int Insert(AppSettings appSetting) { try { int insertResult = CommonTool.DbServe.Insertable(appSetting).ExecuteCommand(); return insertResult; } catch (Exception ex) { _ = ex; return 0; } } /// /// 更新一条记录,主键:SettingKey /// /// /// public int Update(AppSettings appSetting) { try { var sqlFuc = CommonTool.DbServe.Updateable(appSetting).IgnoreColumns(ignoreAllNullColumns: true); return sqlFuc.ExecuteCommand(); } catch (Exception ex) { _ = ex; return 0; } } /// /// 删除一条记录,以主键为条件 /// /// /// public int Delete(AppSettings appSetting) { try { var sqlFuc = CommonTool.DbServe.Deleteable(appSetting); return sqlFuc.ExecuteCommand(); } catch (Exception ex) { _ = ex; return 0; } } /// /// 以不为 null 为条件查询 /// /// /// public List? Select(AppSettings appSetting) { try { var sqlFuc = CommonTool.DbServe.Queryable(); if (appSetting.SettingKey != null) { sqlFuc = sqlFuc.Where(w => w.SettingKey == appSetting.SettingKey); } if (appSetting.SettingName != null) { sqlFuc = sqlFuc.Where(w => w.SettingName == appSetting.SettingName); } if (appSetting.SettingValue != null) { sqlFuc = sqlFuc.Where(w => w.SettingValue == appSetting.SettingValue); } if (appSetting.SettingType != null) { sqlFuc = sqlFuc.Where(w => w.SettingType == appSetting.SettingType); } if (appSetting.Remark != null) { sqlFuc = sqlFuc.Where(w => w.Remark == appSetting.Remark); } return sqlFuc.ToList(); } catch (Exception ex) { _ = ex; return default; } } /// /// 查找所有数据 /// /// public List? Select() => Select(new AppSettings()); /// /// 返回设置信息 /// /// public List? GetSetting(string settingKey) { try { List settings = CommonTool.DbServe.Queryable().Where(w => w.SettingKey == settingKey).ToList(); return settings; } catch (Exception ex) { _ = ex; return default; } } }