/// <summary> /// 获取留言 /// </summary> /// <param name="page"></param> /// <param name="size"></param> /// <param name="cid"></param> /// <returns></returns> public ActionResult GetMsgs(int page = 1, int size = 10, int cid = 0) { UserInfoOutputDto user = HttpContext.Session.Get <UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto(); int total; if (cid != 0) { int pid = LeaveMessageService.GetParentMessageIdByChildId(cid); var single = LeaveMessageService.GetSelfAndAllChildrenMessagesByParentId(pid).ToList(); if (single.Any()) { total = 1; return(ResultData(new { total, parentTotal = total, page, size, rows = single.Mapper <IList <LeaveMessageViewModel> >() })); } } IEnumerable <LeaveMessage> parent = LeaveMessageService.LoadPageEntitiesNoTracking(page, size, out total, m => m.ParentId == 0 && (m.Status == Status.Pended || user.IsAdmin), m => m.PostDate, false); if (!parent.Any()) { return(ResultData(null, false, "没有留言")); } var list = new List <LeaveMessageViewModel>(); parent.ForEach(c => LeaveMessageService.GetSelfAndAllChildrenMessagesByParentId(c.Id).ForEach(result => list.Add(result.Mapper <LeaveMessageViewModel>()))); var qlist = list.Where(c => c.Status == Status.Pended || user.IsAdmin); if (total > 0) { return(ResultData(new { total, parentTotal = total, page, size, rows = qlist })); } return(ResultData(null, false, "没有留言")); }