using ce.autofac.extension; using learun.iapplication; using learun.util; using System.Collections.Generic; using System.Threading.Tasks; namespace learun.application { /// /// 版 本 EasyCode EC管理后台 /// Copyright (c) 2019-present EC管理有限公司 /// 创建人:tobin /// 日 期:2019.09.18 /// 描 述:行政区域 /// public class AreaBLL : BLLBase, AreaIBLL, BLL { private readonly AreaService areaService = new AreaService(); #region 获取数据 /// /// 获取区域列表数据 /// /// 父节点主键(0表示顶层) /// 关键字查询(名称/编号) /// public Task> GetList(string parentId, string keyword = "") { return areaService.GetList(parentId, keyword); } /// /// 区域实体 /// /// 主键值 /// public Task GetEntity(string keyValue) { return areaService.GetEntity(keyValue); } /// /// 获取区域数据树(某一级的) /// /// 父级主键 /// public async Task> GetTree(string parentId) { List treeList = new List(); var list = (List)await GetList(parentId); foreach (var item in list) { TreeModel node = new TreeModel(); node.id = item.F_AreaId; node.text = item.F_AreaName; node.value = item.F_AreaCode; node.showcheck = false; node.checkstate = 0; node.hasChildren = true; node.isexpand = false; node.complete = false; treeList.Add(node); } return treeList; } #endregion 获取数据 #region 提交数据 /// /// 删除区域 /// /// 主键 public async Task Delete(string keyValue) { await areaService.Delete(keyValue); } /// /// 保存区域表单(新增、修改) /// /// 主键值 /// 区域实体 /// public async Task SaveEntity(string keyValue, AreaEntity areaEntity) { if (areaEntity.F_ParentId != "0") { AreaEntity entity = await GetEntity(areaEntity.F_ParentId); if (entity != null) { areaEntity.F_Layer = entity.F_Layer + 1; } } else { areaEntity.F_Layer = 1; } await areaService.SaveEntity(keyValue, areaEntity); } #endregion 提交数据 } }