You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

207 lines
4.9 KiB

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
{
/// <summary>
/// 版 本 EasyCode EC管理后台
/// Copyright (c) 2019-present EC管理有限公司
/// 创建人:tobin
/// 日 期:2019.09.24
/// 描 述:公司管理
/// </summary>
public class CompanyBLL : CompanyIBLL, BLL
{
#region 属性
private readonly CompanyService companyService = new CompanyService();
private readonly UserIBLL _userIBLL;
/// <summary>
///
/// </summary>
/// <param name="userIBLL"></param>
public CompanyBLL(UserIBLL userIBLL)
{
_userIBLL = userIBLL;
}
#endregion 属性
#region 获取数据
/// <summary>
/// 获取公司列表数据
/// </summary>
/// <param name="keyWord">查询关键字</param>
/// <returns></returns>
public Task<IEnumerable<CompanyEntity>> GetList(string keyWord = "")
{
return companyService.GetList(keyWord);
}
/// <summary>
/// 获取子公司列表信息
/// </summary>
/// <param name="pId">父级Id</param>
/// <returns></returns>
public Task<IEnumerable<CompanyEntity>> GetListByPId(string pId)
{
return companyService.GetListByPId(pId);
}
/// <summary>
/// 获取公司信息实体
/// </summary>
/// <param name="keyValue">主键</param>
/// <returns></returns>
public Task<CompanyEntity> GetEntity(string keyValue)
{
return companyService.GetEntity(keyValue);
}
/// <summary>
/// 获取树形数据
/// </summary>
/// <param name="parentId">父级id</param>
/// <returns></returns>
public async Task<IEnumerable<TreeModel>> GetTree(string parentId)
{
List<CompanyEntity> list = (List<CompanyEntity>)await GetList();
List<TreeModel> treeList = new List<TreeModel>();
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);
}
/// <summary>
/// 获取公司本身和子公司的id
/// </summary>
/// <param name="parentId">父级ID</param>
/// <returns></returns>
public async Task<IEnumerable<string>> GetSubNodes(string parentId)
{
if (string.IsNullOrEmpty(parentId))
{
return new List<string>();
}
List<string> res = new List<string>();
res.Add(parentId);
List<TreeModel> list = (List<TreeModel>)await GetTree(parentId);
GetSubNodes(list, res);
return res;
}
/// <summary>
/// 遍历树形数据获取全部子节点ID
/// </summary>
/// <param name="list">树形数据列表</param>
/// <param name="outList">输出数据列表</param>
private void GetSubNodes(List<TreeModel> list, List<string> outList)
{
foreach (var item in list)
{
outList.Add(item.id);
if (item.hasChildren)
{
GetSubNodes(item.ChildNodes, outList);
}
}
}
#endregion 获取数据
#region 2
/// <summary>
/// 获取公司列表数据
/// </summary>
/// <param name="queryParam">查询关键字</param>
/// <returns></returns>
public Task<IEnumerable<CompanyEntity>> GetList2(JObject queryParam)
{
return companyService.GetList2(queryParam);
}
/// <summary>
/// 获取子公司列表信息
/// </summary>
/// <param name="companyId">父级Id</param>
/// <returns></returns>
public Task<IEnumerable<CompanyEntity>> GetChildList(string companyId)
{
return companyService.GetChildList(companyId);
}
/// <summary>
/// 获取树形数据
/// </summary>
/// <param name="companyId">父级id</param>
/// <returns></returns>
public async Task<IEnumerable<TreeModel>> GetTree2(string companyId)
{
var list = (List<CompanyEntity>)await GetChildList(companyId);
var treeList = new List<TreeModel>();
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 提交数据
/// <summary>
/// 删除公司信息
/// </summary>
/// <param name="keyValue">主键</param>
public async Task Delete(string keyValue)
{
await companyService.Delete(keyValue);
}
/// <summary>
/// 保存公司信息(新增、修改)
/// </summary>
/// <param name="keyValue">主键值</param>
/// <param name="entity">公司实体</param>
/// <returns></returns>
public async Task SaveEntity(string keyValue, CompanyEntity entity)
{
await companyService.SaveEntity(keyValue, entity);
}
#endregion 提交数据
}
}