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 /// 日 期:2020.04.07 /// 描 述:移动端功能管理 /// public class FunctionBLL : BLLBase, FunctionIBLL, BLL { private readonly FunctionSerivce functionSerivce = new FunctionSerivce(); private readonly AuthorizeIBLL _authorizeIBLL; private readonly DataItemIBLL _dataItemIBLL; /// /// /// /// /// public FunctionBLL(AuthorizeIBLL authorizeIBLL, DataItemIBLL dataItemIBLL) { _authorizeIBLL = authorizeIBLL; _dataItemIBLL = dataItemIBLL; } #region 获取数据 /// /// 获取分页列表 /// /// 分页参数 /// 关键字 /// 分类 /// public Task> GetPageList(Pagination pagination, string keyword, string type) { return functionSerivce.GetPageList(pagination, keyword, type); } /// /// 获取列表数据 /// /// public async Task> GetList() { var userInfo = await this.CurrentUser(); List list = (List)await functionSerivce.GetList(); /*关联权限*/ if (userInfo.F_SecurityLevel != 1) { string roleIds = await this.CurrentUserRoleIds(); string objectIds = userInfo.F_UserId + (string.IsNullOrEmpty(roleIds) ? "" : ("," + roleIds)); List itemIdList = (List)await _authorizeIBLL.GetItemIdListByobjectIds(objectIds, 5); list = list.FindAll(t => itemIdList.IndexOf(t.F_Id) >= 0); } return list; } /// /// 获取实体对象 /// /// 主键 /// public Task GetEntity(string keyValue) { return functionSerivce.GetEntity(keyValue); } /// /// 获取移动功能模板 /// /// 主键 /// public Task GetScheme(string keyValue) { return functionSerivce.GetScheme(keyValue); } /// /// 获取树形移动功能列表 /// /// public async Task> GetCheckTree() { List treeList = new List(); var dataItemList = await _dataItemIBLL.GetDetailList("function"); var list = await GetList(); Dictionary> map = new Dictionary>(); foreach (var item in list) { if (!map.ContainsKey(item.F_Type)) { map[item.F_Type] = new List(); } TreeModel treeItem = new TreeModel { id = item.F_Id, text = item.F_Name, value = item.F_Id, showcheck = true, checkstate = 0, parentId = item.F_Type + "_LRDataItem" }; map[item.F_Type].Add(treeItem); treeItem.complete = true; } foreach (var item in dataItemList) { if (map.ContainsKey(item.F_ItemValue)) { TreeModel treeItem = new TreeModel { id = item.F_ItemValue + "_LRDataItem", text = item.F_ItemName, value = item.F_ItemValue + "_LRDataItem", showcheck = true, checkstate = 0, parentId = "0", hasChildren = true, complete = true, isexpand = true, ChildNodes = map[item.F_ItemValue] }; treeList.Add(treeItem); } } return treeList; } #endregion 获取数据 #region 提交数据 /// /// 删除 /// /// 主键 public async Task Delete(string keyValue) { await functionSerivce.Delete(keyValue); } /// /// 保存 /// /// 主键 /// 功能信息 /// 功能模板信息 public async Task SaveEntity(string keyValue, FunctionEntity functionEntity, FunctionSchemeEntity functionSchemeEntity) { await functionSerivce.SaveEntity(keyValue, functionEntity, functionSchemeEntity); } /// /// 更新状态 /// /// 模板信息主键 /// 状态1启用0禁用 public async Task UpdateState(string keyValue, int state) { await functionSerivce.UpdateState(keyValue, state); } #endregion 提交数据 } }