public async Task <MSSResult <MenuTree> > GetMenu() { User u = await _repo.GetByID(userID); MSSResult <MenuTree> mRet = new MSSResult <MenuTree>(); try { List <ActionAll> laa = new List <ActionAll>(); //允许勾选和不对外开放的且为菜单的url if (u.IsSuper) { laa = await _ActionRepo.GetActionAll(); mRet.data = ActionHelper.GetMenuTree(laa.Where( a => (a.Level == (int)ACTION_LEVEL.AllowSelection || a.Level == (int)ACTION_LEVEL.NotAllowAll) && a.GroupID > 0).ToList()); } //根据用户ID获取对应菜单权限 else { laa = await _ActionRepo.GetActionByUser(userID); mRet.data = ActionHelper.GetMenuTree(laa.Where(a => a.GroupID > 0).ToList()); } mRet.code = (int)ErrType.OK; return(mRet); } catch (Exception ex) { mRet.code = (int)ErrType.SystemErr; mRet.msg = ex.Message; return(mRet); } }
/// <summary> /// 非超级用户可配置的所有权限 /// </summary> /// <returns></returns> public async Task <MSSResult <ActionTree> > GetActionTree() { MSSResult <ActionTree> mRet = new MSSResult <ActionTree>(); try { List <ActionAll> laa = new List <ActionAll>(); //允许勾选 laa = await _ActionRepo.GetActionAll(); //mRet.data = ActionHelper.GetActionTree(laa.Where( // a => a.Level == (int)ACTION_LEVEL.AllowSelection).ToList()); var list = laa.Where( a => a.Level == (int)ACTION_LEVEL.AllowSelection).ToList(); var trees = ActionHelper.ConvertToTree(list); var treenodes = ActionHelper.BuildTreeRecursive(trees, 0); mRet.code = (int)ErrType.OK; return(mRet); } catch (Exception ex) { mRet.code = (int)ErrType.SystemErr; mRet.msg = ex.Message; return(mRet); } }
public async Task <ApiResult> GetActionTree() { ApiResult ret = new ApiResult(); try { var list = await _ActionRepo.GetActionAll(); var tmp = ActionHelper.ConvertToTree(list); var result = ActionHelper.BuildTreeRecursive(tmp, 0); ret.data = result; return(ret); } catch (Exception ex) { ret.code = Code.Failure; return(ret); } }