using ce.autofac.extension;
using learun.iapplication;
using learun.util;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace learun.application
{
///
/// 版 本 EasyCode EC管理后台
/// Copyright (c) 2019-present EC管理有限公司
/// 创建人:tobin
/// 日 期:2019.09.24
/// 描 述:公司管理
///
public class CompanyBLL : CompanyIBLL, BLL
{
#region 属性
private readonly CompanyService companyService = new CompanyService();
private readonly UserIBLL _userIBLL;
///
///
///
///
public CompanyBLL(UserIBLL userIBLL)
{
_userIBLL = userIBLL;
}
#endregion 属性
#region 获取数据
///
/// 获取公司列表数据
///
/// 查询关键字
///
public Task> GetList(string keyWord = "")
{
return companyService.GetList(keyWord);
}
///
/// 获取子公司列表信息
///
/// 父级Id
///
public Task> GetListByPId(string pId)
{
return companyService.GetListByPId(pId);
}
///
/// 获取公司信息实体
///
/// 主键
///
public Task GetEntity(string keyValue)
{
return companyService.GetEntity(keyValue);
}
///
/// 获取树形数据
///
/// 父级id
///
public async Task> GetTree(string parentId)
{
List list = (List)await GetList();
List treeList = new List();
foreach (var item in list)
{
TreeModel node = new TreeModel
{
id = item.F_CompanyId,
text = item.F_FullName,
value = item.F_CompanyId,
showcheck = false,
checkstate = 0,
isexpand = true,
parentId = item.F_ParentId
};
treeList.Add(node);
}
return treeList.ToTree(parentId);
}
///
/// 获取公司本身和子公司的id
///
/// 父级ID
///
public async Task> GetSubNodes(string parentId)
{
if (string.IsNullOrEmpty(parentId))
{
return new List();
}
List res = new List();
res.Add(parentId);
List list = (List)await GetTree(parentId);
GetSubNodes(list, res);
return res;
}
///
/// 遍历树形数据获取全部子节点ID
///
/// 树形数据列表
/// 输出数据列表
private void GetSubNodes(List list, List outList)
{
foreach (var item in list)
{
outList.Add(item.id);
if (item.hasChildren)
{
GetSubNodes(item.ChildNodes, outList);
}
}
}
#endregion 获取数据
#region 2
///
/// 获取公司列表数据
///
/// 查询关键字
///
public Task> GetList2(JObject queryParam)
{
return companyService.GetList2(queryParam);
}
///
/// 获取子公司列表信息
///
/// 父级Id
///
public Task> GetChildList(string companyId)
{
return companyService.GetChildList(companyId);
}
///
/// 获取树形数据
///
/// 父级id
///
public async Task> GetTree2(string companyId)
{
var list = (List)await GetChildList(companyId);
var treeList = new List();
foreach (var item in list)
{
TreeModel node = new TreeModel
{
id = item.F_CompanyId,
text = item.F_FullName,
value = item.F_CompanyId,
showcheck = false,
checkstate = 0,
isexpand = true,
parentId = item.F_ParentId
};
treeList.Add(node);
}
return treeList.ToTree();
//return treeList.ToTree(companyId);
}
#endregion 2
#region 提交数据
///
/// 删除公司信息
///
/// 主键
public async Task Delete(string keyValue)
{
await companyService.Delete(keyValue);
}
///
/// 保存公司信息(新增、修改)
///
/// 主键值
/// 公司实体
///
public async Task SaveEntity(string keyValue, CompanyEntity entity)
{
await companyService.SaveEntity(keyValue, entity);
}
#endregion 提交数据
}
}