/// <summary> /// 根据当前用户+请求uri 获取父菜单Id; /// </summary> /// <param name="userId"></param> /// <param name="uri"></param> /// <returns></returns> public Tuple <string, string, string> GetParentModuleIds(int userId, string uri) { string sqlstr = "select moduleid from moduleinfo where status=0 and moduleid in (SELECT DISTINCT moduleid FROM RoleModule WHERE roleid IN(select roleid from userrole where userID=@userId and status=0)) order by level desc"; //获取用户已经有的 moduleId; var userHaveModuleIds = _navigationDapperRepository.QueryBySql <string>(sqlstr, new { userId = userId }); var sysId = _configuration["ThisSysID"]; var nav2or3 = _navigationDapperRepository.Find(s => s.Status == 0 && s.SysID == sysId && s.Links.Contains(uri)); if (nav2or3 == null) { return(new Tuple <string, string, string>("", "", "")); } var b = userHaveModuleIds.Contains(nav2or3.ModuleID); //三级 if (nav2or3.ModuleID.Contains("SUB")) { var moduleId2 = _navigationDapperRepository.Where(s => s.ModuleID == nav2or3.ModuleID).Select(s => s.PID).FirstOrDefault(); var moduleId1 = _navigationDapperRepository.Where(s => s.ModuleID == moduleId2).Select(s => s.PID).FirstOrDefault(); return(new Tuple <string, string, string>(moduleId1, moduleId2, nav2or3.ModuleID)); } else { var moduleId1 = _navigationDapperRepository.Where(s => s.ModuleID == nav2or3.ModuleID).Select(s => s.PID).FirstOrDefault(); return(new Tuple <string, string, string>(moduleId1, nav2or3.ModuleID, "")); } }