public ApiPageResultModel GetMyLevel2RepliesList([FromUri] Level2RepliedListModel 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 level1Disscuss = topicDiscussBLL.GetEntity(m => m.Id == model.Id); // 获取我的二级回复列表 var list = topicDiscussBLL.GetPageList(m => m.ParentId == model.Id && m.TopicId == model.TopicId, "PostTime", true, model.PageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, PostDate = m.PostTime.ToString("yyyy-MM-dd HH:mm:ss"), UserId = m.PostUserId, UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Content = m.Content, PicList = m.ImgPath, RepliedUserName = m.ReplyUser.UserName, Level2ParentId = m.ParentId }).ToList(); resultModel.result = list; resultModel.Total = topicDiscussBLL.Count(m => m.ParentId == model.Id && m.TopicId == model.TopicId); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
/// <summary> /// 主题详细列表Json方式获取 /// </summary> /// <param name="topicId"></param> /// <param name="isTag"> 0表示所有楼层都显示 其它Id代表具体那楼层Id。</param> /// <param name="pageIndex"></param> /// <returns></returns> public JsonResult TopicDetailJsonList(int topicId, int floorId, int pageIndex) { PageResultModel model = new PageResultModel(); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); //主题下面所有的一级Ids var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicId && m.ParentId == null, "PostTime", true).Select(m => m.Id).ToList(); Expression <Func <T_PostBarTopicDiscuss, bool> > where = m => true; if (floorId > 0) { where = PredicateBuilder.And(where, m => m.TopicId == topicId && m.Id == floorId); } else { where = PredicateBuilder.And(where, m => m.TopicId == topicId && m.ParentId == null); } // 获取我的帖子回复列表 var list = topicDiscussBLL.GetPageList(where, "PostTime", true, pageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, UserId = m.PostUserId, PostDate = TimeFormat(m.PostTime), UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Content = m.Content == null ? "" : 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, Level2UserId = o.PostUserId, Level2UserName = o.PostUser.UserName, Level2Content = o.Content, Level2PostDate = TimeFormat(o.PostTime), Level2RepliedUserName = o.ReplyUser.UserName, Level2PicList = o.ImgPath }).OrderByDescending(o => o.Level2PostDate).Take(2).ToList(), Level2DiscussListCount = m.PostBarTopicDiscusses.Count() }).ToList(); model.Result = list; model.Total = topicDiscussBLL.Count(m => m.TopicId == topicId && m.ParentId == null); return(Json(model, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 楼层详细列表 /// </summary> /// <param name="floorId">一级回复的主键Id</param> /// <param name="replyId">准备要回复对方的Id</param> /// <returns></returns> public ActionResult FloorDetailList(int floorId, int replyId) { int CurrentUserId = GetCurrentUser().Id; WeixinApiInit(); //获取当前楼层(也就是一级回复的)信息 IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var topicDiscuss = topicDiscussBLL.GetEntity(m => m.Id == floorId); //主题下面所有的一级Ids var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicDiscuss.TopicId && m.ParentId == null).OrderBy(m => m.PostTime).Select(m => m.Id).ToList(); //当前是第几楼 int FloorNo = level1Ids.FindIndex(m => m == floorId) + 1; ViewBag.FloorNo = string.Format("{0}楼", FloorNo); IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); var replidUserName = ""; var replyUser = userBll.GetEntity(m => m.Id == replyId); replidUserName = string.Format("回复{0}:", replyUser.UserName); var model = new TopicFloorDetailModel() { FloorId = topicDiscuss.Id, FloorNo = string.Format("第{0}楼", FloorNo), PostUserId = topicDiscuss.PostUserId, PostUserName = topicDiscuss.PostUser.UserName, PostUserHeadPath = topicDiscuss.PostUser.HeadPath, ImgPath = topicDiscuss.ImgPath, ImgThumbnail = topicDiscuss.ImgThumbnail, PostDate = string.Format("第{0}楼 {1}", FloorNo, TimeFormat(topicDiscuss.PostTime)), Content = topicDiscuss.Content, PropertyPlaceId = topicDiscuss.PostBarTopic.PropertyPlaceId, TopicId = topicDiscuss.PostBarTopic.Id, LevelTwoReplyCount = topicDiscussBLL.Count(m => m.ParentId == topicDiscuss.Id && m.TopicId == topicDiscuss.TopicId), ReplyId = replyId, ReplidUserName = replidUserName, CurrentUserId = CurrentUserId, CanDelete = topicDiscuss.PostUserId == CurrentUserId }; return(View(model)); }
/// <summary> /// 楼层详细列表Json方式获取 /// </summary> /// <param name="floorId"></param> /// <param name="topicId"></param> /// <param name="pageIndex"></param> /// <returns></returns> public JsonResult FloorDetailJsonList(int floorId, int topicId, int pageIndex) { PageResultModel model = new PageResultModel(); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); // 获取我的帖子回复列表 var list = topicDiscussBLL.GetPageList(m => m.TopicId == topicId && m.ParentId == floorId, "PostTime", true, pageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Level2Id = m.Id, Level2UserName = m.PostUser.UserName, Level2Content = m.Content, Level2PostDate = TimeFormat(m.PostTime), Level2PostUserId = m.PostUserId, Level2RepliedUserName = string.Format("回复 {0}:", m.ReplyUser.UserName), CanDelete = GetCurrentUser().Id == m.PostUserId }).ToList(); model.Result = list; model.Total = topicDiscussBLL.Count(m => m.TopicId == topicId && m.ParentId == floorId); return(Json(model, JsonRequestBehavior.AllowGet)); }
/// <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)); }