public Resp_Index <SysChannelDTO> Index(Req_Index index) { var response = new Resp_Index <SysChannelDTO>(); var limits = _sysRightRepository.GetRightByUserWithModule(index.userId, index.moduleId).ConvertoDto <SysUserRightView, SysModuleOperateIndexDTO>().ToList(); if (limits.IsNotNull() && limits.Count > 0 && 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 SysRole_Query { PgIndex = 1, PgSize = index.PgSize }; response.query = Query(query_parameter); } else { _sysRightRepository.UnitOfWork.Commite(); response.allowVisit = false; response.message = "无访问权限,请联系管理员"; } return(response); }
public Resp_Query <SysChannelDTO> Query(SysRole_Query request) { var response = new Resp_Query <SysChannelDTO>(); var records = sysChannelRepository.GetAll(); records.ToMaybe() .Do(d => 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.ConvertoDto <SysChannel, SysChannelDTO>().ToList(); response.entities.ForEach(f => { var temp = entities.Find(t => t.ID == f.ID); var UserName = new StringBuilder(); if (temp.IsNotNull()) { temp.SysUsers.ToList().ForEach(s => UserName.Append("[" + s.Name + "]")); } f.UserName = UserName.ToString(); }); return(response); }