public Resp_Index <SysModuleDTO> Index(Req_Index request) { var response = new Resp_Index <SysModuleDTO>(); var limits = _sysRightRepository.GetRightByUserWithModule(request.userId, request.moduleId).ConvertoDto <SysUserRightView, SysModuleOperateIndexDTO>().ToList(); if (!limits.IsNullOrEmpty() && limits.Find(s => s.IsValid == 1).IsNotNull()) { response.allowVisit = true; response.moduleOperaties = limits.OrderByDescending(t => t.IsValid).GroupBy(t => new { t.KeyCode, t.KeyName }).Select(s => new SysModuleOperateIndexDTO { KeyCode = s.Key.KeyCode, KeyName = s.Key.KeyName, IsValid = s.Sum(x => x.IsValid), }).ToList(); var query_parameter = new SysMoudule_Query { ParentId = "" }; response.query = Query(query_parameter); } else { _sysRightRepository.UnitOfWork.Commite(); response.allowVisit = false; response.message = "无访问权限,请联系管理员"; } return(response); }
public Resp_Query <SysModuleDTO> Query(SysMoudule_Query request) { var response = new Resp_Query <SysModuleDTO>(); List <SysModule> recodes = null; //recodes = _sysModuleRepository.GetSysModules(request.ParentId).ToList(); if (string.IsNullOrEmpty(request.ParentId)) { recodes = _sysModuleRepository.GetByWhere(t => t.SuperSysModule == null).ToList(); } else { if (int.TryParse(request.ParentId, out int result)) { recodes = _sysModuleRepository.GetByWhere(t => t.SuperSysModule.ID == result).ToList(); } } recodes.ForEach(t => { if (t.SubSysModules.IsNullOrEmpty()) { t.IsLast = 1; } }); response.entities = recodes.IsNotNull() ? recodes.ConvertoDto <SysModule, SysModuleDTO>().ToList() : new List <SysModuleDTO>(); response.totalCounts = response.entities.Count(); response.totalRows = 1; return(response); }