public Resp_Index <RecordMGrade> Index(Req_Index request) { var response = new Resp_Index <RecordMGrade>(); 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 RMG_Query { PgIndex = 1, PgSize = request.PgSize }; response.query = Query(query_parameter); } else { _sysRightRepository.UnitOfWork.Commite(); response.allowVisit = false; response.message = "无访问权限,请联系管理员"; } return(response); }
public Resp_Query <RecordMGrade> Query(RMG_Query request) { var response = new Resp_Query <RecordMGrade>(); var records = _recordMGradeRepository.GetAll(); records.ToMaybe() .Do(t => request.Verify()) .DoWhen(t => !string.IsNullOrEmpty(request.QueryStr), d => records = records.Where(s => s.Name.Contains(request.QueryStr))); response.totalCounts = records.Count(); response.totalRows = (int)Math.Ceiling((double)response.totalCounts / request.PgSize); if (!string.IsNullOrEmpty(request.Order)) { records = records.DataSorting(request.Order, request.Esc); } else { records = records.OrderByDescending(t => t.ID); } var entities = records.Skip(request.PgSize * (request.PgIndex - 1)).Take(request.PgSize).ToList(); response.entities = entities; return(response); }