public Resp_Query <SysRightViewModel> GetRightByUser(SysRightGetByUser request) { var d = _sysRightRepository.GetRightByUser(request.UserId); var datas = d.ToList(); return(GetRightsByCondition(datas, request)); }
private Resp_Query <SysRightViewModel> GetRightsByCondition(List <SysUserRightView> datas, SysRightGetByUser request) { var response = new Resp_Query <SysRightViewModel>(); var views = new List <SysRightViewModel>(); if (datas.IsNotNull() && datas.Count > 0) { var groups = datas.GroupBy(t => new { t.ModuleName, t.SysModuleId, t.ParentId }); var sysModules = Cache.GetSysModules(); foreach (var group in groups) { var view = new SysRightViewModel(); view.ModuleName = GetModuleName(sysModules, group.Key.ParentId, group.Key.ModuleName);//group.Key.ModuleName; view.SysModuleId = group.Key.SysModuleId; view.ParentId = group.Key.ParentId; foreach (var temp in group) { view.Operaties.Add(new SysRightOperateViewModel { KeyCode = temp.KeyCode, Name = temp.Name, IsValid = temp.IsValid }); } views.Add(view); } response.entities = views.Skip((request.PgIndex - 1) * request.PgSize).Take(request.PgSize).ToList(); response.totalCounts = views.Count; response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); } return(response); }