/// <summary> /// 修改部门信息(修改部门名称) /// 根据主键和父类编号修改部门信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int UpdateDepart(SysDepartEntity entity) { entity.ThrowIfNull("修改部门信息对象为空"); entity.IncludeDepartName(true) ; //entity.Where<SysDepartEntity>("ID", ECondition.Eth) // .And<SysDepartEntity>("ParentNum", ECondition.Eth); entity.Where(a => a.DepartNum == entity.DepartNum); int line = this.SysDepart.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_SYSDEPART_CACHE); } return line; }
/// <summary> /// 根据主键编号修改部门信息(修改部门名和部门级别) /// </summary> /// <param name="entity"></param> /// <returns></returns> public int UpdateDepartByID(SysDepartEntity entity) { entity.IncludeDepartName(true) .IncludeParentNum(true); entity.Where<SysDepartEntity>("ID", ECondition.Eth); int line = this.SysDepart.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_SYSDEPART_CACHE); } return line; }
/// <summary> /// 获得所有的部门信息 /// </summary> /// <returns></returns> public List<SysDepartEntity> GetList() { List<SysDepartEntity> listResult = CacheHelper.Get(CacheKey.JOOSHOW_SYSDEPART_CACHE) as List<SysDepartEntity>; if (!listResult.IsNullOrEmpty()) { return listResult; } SysDepartEntity temp = new SysDepartEntity(); temp.IncludeID(true) .IncludeChildCount(true) .IncludeCreateTime(true) .IncludeDepartName(true) .IncludeDepartNum(true) .IncludeDepth(true) .IncludeParentNum(true) ; temp.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); listResult = this.SysDepart.GetList(temp); if (!listResult.IsNullOrEmpty()) { foreach (SysDepartEntity entity in listResult.Where(itemParent => !string.IsNullOrEmpty(itemParent.ParentNum))) { SysDepartEntity tempEntity = listResult.SingleOrDefault(item => item.DepartNum == entity.ParentNum); if (!tempEntity.IsNull()) { entity.ParentName = tempEntity.DepartName; } } CacheHelper.Insert(CacheKey.JOOSHOW_SYSDEPART_CACHE, listResult, null, DateTime.Now.AddHours(5)); } return listResult; }