using LeaRun.Application.Busines.BaseManage;
using LeaRun.Application.Entity.BaseManage;
using LeaRun.Cache.Factory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LeaRun.Application.Cache
{
///
/// 版 本 6.1
/// Copyright (c) 2013-2016 上海力软信息技术有限公司
/// 创建人:佘赐雄
/// 日 期:2016.3.4 9:56
/// 描 述:部门信息缓存
///
public class DepartmentCache
{
private DepartmentBLL busines = new DepartmentBLL();
///
/// 部门列表
///
///
public IEnumerable GetList()
{
var cacheList = CacheFactory.Cache().GetCache>(busines.cacheKey);
if (cacheList == null)
{
var data = busines.GetList();
CacheFactory.Cache().WriteCache(data, busines.cacheKey);
return data;
}
else
{
return cacheList;
}
}
///
/// 部门列表
///
/// 公司Id
///
public IEnumerable GetList(string organizeId)
{
var data = this.GetList();
if (!string.IsNullOrEmpty(organizeId))
{
data = data.Where(t => t.OrganizeId == organizeId);
}
return data;
}
public DepartmentEntity GetEntity(string departmentId)
{
var data = this.GetList();
if(!string.IsNullOrEmpty(departmentId))
{
var d = data.Where(t => t.DepartmentId == departmentId).ToList();
if (d.Count > 0)
{
return d[0];
}
}
return new DepartmentEntity();
}
}
}