| | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public partial class AssetsFourlinkCoefficient |
| | | public partial class AssetsFourlinkFactor |
| | | { |
| | | #region Cache |
| | | |
| | | //获取缓存 |
| | | private static List<Model.AssetsFourlinkCoefficient> GetCache() |
| | | private static List<Model.AssetsFourlinkFactor> GetCache() |
| | | { |
| | | var all = AssetsFourlinkCoefficientCacheHelper.GetSet(() => |
| | | var all = AssetsFourlinkFactorCacheHelper.GetSet(() => |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var entity_list = dal.GetAll(); |
| | | var model_list = Entity2Models(entity_list); |
| | | if (model_list == null) |
| | | { |
| | | model_list = new List<Model.AssetsFourlinkCoefficient>(); |
| | | model_list = new List<Model.AssetsFourlinkFactor>(); |
| | | } |
| | | return model_list; |
| | | }, Yw.Service.ConfigHelper.CacheKeepTime, Yw.Service.ConfigHelper.CacheRandomTime); |
| | |
| | | //通过 ID 更新缓存 |
| | | private static void UpdateCache(long ID) |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var entity_ds = dal.GetByID(ID); |
| | | var model_ds = Entity2Model(entity_ds); |
| | | var all = GetCache(); |
| | |
| | | { |
| | | model.Reset(model_ds); |
| | | } |
| | | AssetsFourlinkSeriesCacheHelper.Trigger(); |
| | | AssetsFourlinkFactorCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //通过 Ids 更新缓存 |
| | |
| | | { |
| | | return; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var entity_list = dal.GetByIds(Ids); |
| | | var model_list = Entity2Models(entity_list); |
| | | var all = GetCache(); |
| | |
| | | { |
| | | all.AddRange(model_list); |
| | | } |
| | | AssetsFourlinkSeriesCacheHelper.Trigger(); |
| | | AssetsFourlinkFactorCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //移除缓存 |
| | |
| | | { |
| | | var all = GetCache(); |
| | | all.RemoveAll(x => x.ID == ID); |
| | | AssetsFourlinkSeriesCacheHelper.Trigger(); |
| | | AssetsFourlinkFactorCacheHelper.Trigger(); |
| | | } |
| | | |
| | | //移除所有缓存 |
| | |
| | | { |
| | | var all = GetCache(); |
| | | all.Clear(); |
| | | AssetsFourlinkSeriesCacheHelper.Trigger(); |
| | | AssetsFourlinkFactorCacheHelper.Trigger(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public static void PublishCache(string key) |
| | | { |
| | | AssetsFourlinkSeriesCacheHelper.Publish(key); |
| | | AssetsFourlinkFactorCacheHelper.Publish(key); |
| | | } |
| | | |
| | | #endregion Cache |
| | |
| | | /// <summary> |
| | | /// 获取所有 |
| | | /// </summary> |
| | | public List<Model.AssetsFourlinkCoefficient> GetAll() |
| | | public List<Model.AssetsFourlinkFactor> GetAll() |
| | | { |
| | | var all = GetCache(); |
| | | return all; |
| | | return all?.OrderBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ID 获取 |
| | | /// </summary> |
| | | public Model.AssetsFourlinkCoefficient GetByID(long ID) |
| | | public Model.AssetsFourlinkFactor GetByID(long ID) |
| | | { |
| | | var all = GetAll(); |
| | | return all.Find(x => x.ID == ID); |
| | |
| | | /// <summary> |
| | | /// 通过 ID 获取 |
| | | /// </summary> |
| | | public List<Model.AssetsFourlinkCoefficient> GetByIds(List<long> Ids) |
| | | public List<Model.AssetsFourlinkFactor> GetByIds(List<long> Ids) |
| | | { |
| | | if (Ids == null || Ids.Count < 1) |
| | | { |
| | | return default; |
| | | } |
| | | var all = GetAll(); |
| | | return all.Where(x => Ids.Contains(x.ID)).ToList(); |
| | | return all.Where(x => Ids.Contains(x.ID))?.OrderBy(x => x.SortCode).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取最大排序码 |
| | | /// </summary> |
| | | public int GetMaxSortCode() |
| | | { |
| | | var all = GetAll(); |
| | | if (all == null || all.Count < 1) |
| | | { |
| | | return 0; |
| | | } |
| | | return all.Max(x => x.SortCode); |
| | | } |
| | | |
| | | #endregion Query |
| | |
| | | /// <summary> |
| | | /// 插入一条数据 |
| | | /// </summary> |
| | | public long Insert(Model.AssetsFourlinkCoefficient model) |
| | | public long Insert(Model.AssetsFourlinkFactor model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return default; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var entity = Model2Entity(model); |
| | | var id = dal.Insert(entity); |
| | | if (id > 0) |
| | |
| | | /// <summary> |
| | | /// 插入多条 |
| | | /// </summary> |
| | | public bool Inserts(List<Model.AssetsFourlinkCoefficient> list) |
| | | public bool Inserts(List<Model.AssetsFourlinkFactor> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var entity_list = Model2Entities(list); |
| | | var ids = dal.InsertsR(entity_list); |
| | | if (ids != null && ids.Count > 0) |
| | |
| | | /// <summary> |
| | | /// 更新一条 |
| | | /// </summary> |
| | | public bool Update(Model.AssetsFourlinkCoefficient model) |
| | | public bool Update(Model.AssetsFourlinkFactor model) |
| | | { |
| | | if (model == null) |
| | | { |
| | | return false; |
| | | } |
| | | var entity = Model2Entity(model); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var bol = dal.Update(entity); |
| | | if (bol) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 批量更新 |
| | | /// </summary> |
| | | public bool Updates(List<Model.AssetsFourlinkCoefficient> list) |
| | | public bool Updates(List<Model.AssetsFourlinkFactor> list) |
| | | { |
| | | if (list == null || list.Count < 1) |
| | | { |
| | |
| | | return false; |
| | | } |
| | | var entity_list = Model2Entities(list); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var bol = dal.Updates(entity_list); |
| | | if (bol) |
| | | { |
| | | UpdateCache(list.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新排序码 |
| | | /// </summary> |
| | | public bool UpdateSortCode(long ID, int SortCode) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var bol = dal.UpdateSortCode(ID, SortCode); |
| | | if (bol) |
| | | { |
| | | UpdateCache(ID); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新排序 |
| | | /// </summary> |
| | | public bool UpdateSorter(List<Yw.Model.Sorter> sorters) |
| | | { |
| | | if (sorters == null || sorters.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | if (sorters.Exists(x => x.ID < 1)) |
| | | { |
| | | return false; |
| | | } |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var bol = dal.UpdateSorter(sorters.ToEntityList()); |
| | | if (bol) |
| | | { |
| | | UpdateCache(sorters.Select(x => x.ID).ToList()); |
| | | } |
| | | return bol; |
| | | } |
| | |
| | | public bool DeleteByID(long ID, out string Msg) |
| | | { |
| | | Msg = string.Empty; |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkFactor>(); |
| | | var bol = dal.DeleteByID(ID); |
| | | if (bol) |
| | | { |
| | | RemoveCache(ID); |
| | | } |
| | | return bol; |
| | | } |
| | | |
| | | public bool DeleteAll() |
| | | { |
| | | var dal = DALCreateHelper.CreateDAL<HStation.DAL.IAssetsFourlinkCoefficient>(); |
| | | var bol = dal.DeleteAll(); |
| | | if (bol) |
| | | { |
| | | RemoveAllCache(); |
| | | } |
| | | return bol; |
| | | } |