/// <summary> /// 我的回复列表Json方式获取 /// </summary> /// <param name="pageIndex"></param> /// <returns></returns> public JsonResult MyReplyJsonList(int pageIndex) { int CurrentUserId = GetCurrentUser().Id; PageResultModel model = new PageResultModel(); //获取验证过的小区Ids var verifiedPlaceIds = GetVerifiedPlaceIds(); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); // 获取我的回复列表 var list = topicDiscussBLL.GetPageList(m => (m.ReplyId == CurrentUserId || m.PostUserId == CurrentUserId) && verifiedPlaceIds.Contains(m.PostBarTopic.PropertyPlaceId), "PostTime", false, pageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, PostUserId = m.PostUserId, PostDate = TimeFormat(m.PostTime), UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Title = m.PostBarTopic.Title, Content = m.Content, PicList = m.ImgPath, TopicType = m.PostBarTopic.PostBarTopicType.Name, CommentCount = m.PostBarTopic.PostBarTopicDiscusss.Count(o => o.ParentId == null), ParentId = m.ParentId, TopicId = m.TopicId, PropertyPlaceId = m.PostBarTopic.PropertyPlaceId, FloorId = m.ParentId == null ? m.Id : m.ParentId, PropertyName = m.PostBarTopic.PropertyPlace.Name, ReplyId = m.ParentId == null ? m.PostUserId : m.ParentReply.PostUserId }).ToList(); model.Result = list; model.Total = topicDiscussBLL.Count(m => (m.ReplyId == CurrentUserId || m.PostUserId == CurrentUserId) && verifiedPlaceIds.Contains(m.PostBarTopic.PropertyPlaceId)); return(Json(model, JsonRequestBehavior.AllowGet)); }
public ApiPageResultModel GetMyRepliesList([FromUri] PagedSearchModel model) { ApiPageResultModel resultModel = new ApiPageResultModel(); try { //根据用户ID查找业主 IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (owner != null) { //如果验证Token不通过或已过期 if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 owner.LatelyLoginTime = DateTime.Now; owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); ownerBll.Update(owner); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); // 获取我的回复列表 var list = topicDiscussBLL.GetPageList(m => m.ReplyId == owner.Id || m.PostUserId == owner.Id, "PostTime", false, model.PageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, PostUserId = m.PostUserId, PostDate = m.PostTime.ToString("yyyy-MM-dd HH:mm:ss"), UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Title = m.PostBarTopic.Title, Content = m.Content, PicList = m.ImgPath, TopicType = m.PostBarTopic.PostBarTopicType.Name, CommentCount = m.PostBarTopic.PostBarTopicDiscusss.Count(), PostTopicUserImage = m.PostBarTopic.PostUser.HeadPath, PostTopicUserName = m.PostBarTopic.PostUser.UserName, PostTopicDate = m.PostBarTopic.PostDate.ToString("yyyy-MM-dd HH:mm:ss"), IsTop = m.PostBarTopic.IsTop, TopicId = m.TopicId, PropertyPlaceId = m.PostBarTopic.PropertyPlaceId, PlaceName = m.PostBarTopic.PropertyPlace.Name }).ToList(); resultModel.result = list; resultModel.Total = topicDiscussBLL.Count(m => m.ReplyId == owner.Id || m.PostUserId == owner.Id); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiPageResultModel GetMyTopicReplyList([FromUri] TopicDetailsModel model) { ApiPageResultModel resultModel = new ApiPageResultModel(); try { //根据用户ID查找业主 IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (owner != null) { //如果验证Token不通过或已过期 if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 owner.LatelyLoginTime = DateTime.Now; owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); ownerBll.Update(owner); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == model.TopicId && m.ParentId == null).OrderBy(m => m.PostTime).Select(m => m.Id).ToList(); // 获取我的帖子回复列表 var list = topicDiscussBLL.GetPageList(m => m.TopicId == model.TopicId && m.ParentId == null, "PostTime", true, model.PageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, UserId = m.PostUserId, PostDate = m.PostTime.ToString("yyyy-MM-dd HH:mm:ss"), UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Content = m.Content, PicList = m.ImgPath, RepliedUserName = m.ReplyUser.UserName, Level2Count = m.PostBarTopicDiscusses.Count(), PropertyPlaceId = m.PostBarTopic.PropertyPlaceId, FloorNo = level1Ids.FindIndex(l => l == m.Id) + 1, Level2DiscussList = m.PostBarTopicDiscusses.Select(o => new { Level2Id = o.Id, Level2ParentId = o.ParentId, Level2UserName = o.PostUser.UserName, Level2Content = o.Content, Level2PostDate = o.PostTime.ToString("yyyy-MM-dd HH:mm:ss"), Level2RepliedUserName = o.ReplyUser.UserName, Level2PicList = o.ImgPath }).OrderBy(o => o.Level2PostDate).Take(2).ToList() }).ToList(); resultModel.result = list; resultModel.Total = topicDiscussBLL.Count(m => m.TopicId == model.TopicId && m.ParentId == null); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }