Beispiel #1
0
        public List <CityUserMsg> getListByUserId(int aid, int userId, out int totalCount, int pageSize = 10, int pageIndex = 1, string appId = "")
        {
            string strWhere = $"aid={aid} and toUserId={userId}";

            base.ExecuteNonQuery($"update CityUserMsg set state=1 where aid={aid} and toUserId={userId}");//将该用户未读消息全部标记为已读

            totalCount = base.GetCount(strWhere);
            OpenAuthorizerConfig openAuthorizerConfig = OpenAuthorizerConfigBLL.SingleModel.GetModelByAppids(appId);

            List <CityUserMsg> list = base.GetList(strWhere, pageSize, pageIndex, "*", "addTime desc");

            string            userIds      = string.Join(",", list?.Select(s => s.fromUserId).Distinct());
            List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds);

            list.ForEach(x =>
            {
                //获取用户头像 昵称
                C_UserInfo c_UserInfo = userInfoList?.FirstOrDefault(f => f.Id == x.fromUserId);
                if (c_UserInfo != null)
                {
                    x.fromUserName = c_UserInfo.NickName;
                    x.fromUseImg   = c_UserInfo.HeadImgUrl;
                }
                else
                {
                    x.fromUserName = "******";
                    x.fromUseImg   = openAuthorizerConfig.head_img;
                }
                x.addTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime);
            });

            return(list);
        }
Beispiel #2
0
        /// <summary>
        /// 获取用户收藏帖子列表
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="userId"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public List <CityMsg> getListMyFavoriteMsg(int aid, int userId, out int totalCount, int pageSize = 10, int pageIndex = 1)
        {
            string strWhere = $"f.aid={aid} and f.userId={userId} and f.state=0 and f.actionType=0 and msg.state=1";

            string sql = $"select msg.*,f.Id as FavoriteId  from CityUserFavoriteMsg f left join CityMsg msg on f.msgId=msg.Id where {strWhere} order by addTime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize}";

            totalCount = GetMyFavoriteMsgCount(strWhere);
            List <CityMsg> listCity_Msg = new List <CityMsg>();

            using (var dr = SqlMySql.ExecuteDataReader(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, sql))
            {
                while (dr.Read())
                {
                    CityMsg x = CityMsgBLL.SingleModel.GetModel(dr);
                    if (x != null && x.Id > 0)
                    {
                        //获取用户头像
                        C_UserInfo c_UserInfo = C_UserInfoBLL.SingleModel.GetModel(x.userId);
                        if (c_UserInfo != null)
                        {
                            x.userName      = c_UserInfo.NickName;
                            x.userHeaderImg = c_UserInfo.HeadImgUrl;
                        }

                        //获取帖子类别
                        CityStoreMsgType city_StoreMsgType = CityStoreMsgTypeBLL.SingleModel.GetModel(x.msgTypeId);
                        if (city_StoreMsgType != null)
                        {
                            x.msgTypeName = city_StoreMsgType.name;
                        }

                        //根据帖子ID获取其浏览量-收藏量-分享量数据
                        CityMsgViewFavoriteShare city_MsgViewFavoriteShare = CityMsgViewFavoriteShareBLL.SingleModel.getModelByMsgId(x.Id);
                        if (city_MsgViewFavoriteShare != null)
                        {
                            x.ViewCount     = city_MsgViewFavoriteShare.ViewCount;
                            x.FavoriteCount = city_MsgViewFavoriteShare.FavoriteCount;
                            x.ShareCount    = city_MsgViewFavoriteShare.ShareCount;
                            x.DzCount       = city_MsgViewFavoriteShare.DzCount;
                        }
                        x.msgDetail   = HttpUtility.HtmlDecode(x.msgDetail);
                        x.showTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime);
                        x.FavoriteId  = (dr["FavoriteId"] != DBNull.Value?Convert.ToInt32(dr["FavoriteId"]):0);//收藏记录ID
                        listCity_Msg.Add(x);
                    }
                }
            }


            return(listCity_Msg);
        }
Beispiel #3
0
        /// <summary>
        /// 根据用户Id也就是myCardId 获取该用户发布的帖子列表
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="myCardId"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public List <PlatMsg> GetListByUserId(int aid, int myCardId, out int totalCount, int pageSize = 10, int pageIndex = 1)
        {
            string         strWhere          = $"aid={aid} and state<>-1 and PayState=1 and MyCardId={myCardId}";
            List <PlatMsg> listPlatMsg       = base.GetList(strWhere, pageSize, pageIndex, "*", " addTime desc");
            int            commentTotalCount = 0;

            if (listPlatMsg != null && listPlatMsg.Count > 0)
            {
                string            cardIds        = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct());
                List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds);

                string             msgTypeIds      = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct());
                List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds);

                listPlatMsg.ForEach(x =>
                {
                    //获取用户头像
                    PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId);
                    if (platMyCard != null)
                    {
                        x.UserName      = platMyCard.Name;
                        x.UserHeaderImg = platMyCard.ImgUrl;
                    }

                    //获取帖子类别
                    PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId);
                    if (platMsgType != null)
                    {
                        x.MsgTypeName = platMsgType.Name;
                    }

                    //根据帖子ID获取其浏览量-收藏量-分享量数据
                    PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子);
                    if (_platMsgviewFavoriteShare != null)
                    {
                        x.ViewCount     = _platMsgviewFavoriteShare.ViewCount;
                        x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount;
                        x.ShareCount    = _platMsgviewFavoriteShare.ShareCount;
                        x.DzCount       = _platMsgviewFavoriteShare.DzCount;
                    }
                    x.Comments    = PlatMsgCommentBLL.SingleModel.GetPlatMsgComment(x.Aid, out commentTotalCount, 0, string.Empty, 1000, 1, x.Id, 0);
                    x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime);
                    x.MsgDetail   = HttpUtility.HtmlDecode(x.MsgDetail);
                });
            }

            totalCount = base.GetCount(strWhere);

            return(listPlatMsg);
        }
Beispiel #4
0
        /// <summary>
        /// 获取指定帖子详情 包含了 点赞数 分享数 收藏数 浏览量等...
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="msgId"></param>
        /// <returns></returns>
        public PlatMsg GetMsg(int aid, int msgId)
        {
            PlatMsg x = base.GetModel($"aid={aid} and Id={msgId}");

            if (x != null)
            {
                //获取用户头像
                PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(x.MyCardId);
                if (platMyCard != null)
                {
                    x.UserName      = platMyCard.Name;
                    x.UserHeaderImg = platMyCard.ImgUrl;
                    x.UserId        = platMyCard.UserId;
                }

                //获取帖子类别
                PlatMsgType platMsgType = PlatMsgTypeBLL.SingleModel.GetModel(x.MsgTypeId);
                if (platMsgType != null)
                {
                    x.MsgTypeName = platMsgType.Name;
                }

                //根据帖子ID获取其浏览量-收藏量-分享量数据
                PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子);
                if (_platMsgviewFavoriteShare != null)
                {
                    x.ViewCount     = _platMsgviewFavoriteShare.ViewCount;
                    x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount;
                    x.ShareCount    = _platMsgviewFavoriteShare.ShareCount;
                    x.DzCount       = _platMsgviewFavoriteShare.DzCount;
                }
                x.MsgDetail   = HttpUtility.HtmlDecode(x.MsgDetail);
                x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime);
            }


            return(x);
        }
Beispiel #5
0
        public CityMsg getMsg(int aid, int msgId)
        {
            CityMsg x = base.GetModel($"aid={aid} and Id={msgId}");

            if (x != null)
            {
                //获取用户头像
                C_UserInfo c_UserInfo = C_UserInfoBLL.SingleModel.GetModel(x.userId);
                if (c_UserInfo != null)
                {
                    x.userName      = c_UserInfo.NickName;
                    x.userHeaderImg = c_UserInfo.HeadImgUrl;
                }

                //获取帖子类别
                CityStoreMsgType city_StoreMsgType = CityStoreMsgTypeBLL.SingleModel.GetModel(x.msgTypeId);
                if (city_StoreMsgType != null)
                {
                    x.msgTypeName = city_StoreMsgType.name;
                }

                //根据帖子ID获取其浏览量-收藏量-分享量数据
                CityMsgViewFavoriteShare city_MsgViewFavoriteShare = CityMsgViewFavoriteShareBLL.SingleModel.getModelByMsgId(x.Id);
                if (city_MsgViewFavoriteShare != null)
                {
                    x.ViewCount     = city_MsgViewFavoriteShare.ViewCount;
                    x.FavoriteCount = city_MsgViewFavoriteShare.FavoriteCount;
                    x.ShareCount    = city_MsgViewFavoriteShare.ShareCount;
                    x.DzCount       = city_MsgViewFavoriteShare.DzCount;
                }

                x.showTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime);
                x.msgDetail   = HttpUtility.HtmlDecode(x.msgDetail);
            }


            return(x);
        }
Beispiel #6
0
        /// <summary>
        /// 获取帖子评论列表
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="totalCount"></param>
        /// <param name="keyMsg"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="Id"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public List <CityMsgComment> GetCityMsgComment(int aid, out int totalCount, string keyMsg = "", int pageSize = 10, int pageIndex = 1, int Id = 0, int userId = 0)
        {
            string strWhere = $"aid={aid} and State=0 ";
            List <MySqlParameter> parameters = new List <MySqlParameter>();

            if (userId > 0)
            {
                strWhere += $"  and FromUserId={userId} ";
            }

            if (Id > 0)
            {
                strWhere += $"  and MsgId={Id}";
            }

            if (!string.IsNullOrEmpty(keyMsg))
            {
                strWhere += $" and CommentDetail like @keyMsg ";
                parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%"));
            }

            totalCount = base.GetCount(strWhere, parameters.ToArray());

            List <CityMsgComment> listCityMsgComment = base.GetListByParam(strWhere, parameters.ToArray(), pageSize, pageIndex, "*", " AddTime Desc");

            if (listCityMsgComment != null && listCityMsgComment.Count > 0)
            {
                string fuserIds = string.Join(",", listCityMsgComment.Select(s => s.FromUserId));
                string tuserIds = string.Join(",", listCityMsgComment.Select(s => s.ToUserId));
                if (!string.IsNullOrEmpty(tuserIds))
                {
                    if (!string.IsNullOrEmpty(fuserIds))
                    {
                        fuserIds += "," + tuserIds;
                    }
                    else
                    {
                        fuserIds = tuserIds;
                    }
                }
                List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(fuserIds);

                string         cityMsgIds  = string.Join(",", listCityMsgComment.Select(s => s.MsgId));
                List <CityMsg> cityMsgList = CityMsgBLL.SingleModel.GetListByIds(cityMsgIds);

                listCityMsgComment.ForEach(x =>
                {
                    C_UserInfo c_userInfo = userInfoList?.FirstOrDefault(f => f.Id == x.FromUserId);
                    if (c_userInfo != null)
                    {
                        x.NickName  = c_userInfo.NickName;
                        x.HeaderImg = c_userInfo.HeadImgUrl;
                    }
                    else
                    {
                        x.NickName = "匿名";
                    }

                    C_UserInfo to_userInfo = userInfoList?.FirstOrDefault(f => f.Id == x.ToUserId);
                    if (to_userInfo != null)
                    {
                        x.ToNickName  = to_userInfo.NickName;
                        x.ToHeaderImg = to_userInfo.HeadImgUrl;
                    }

                    CityMsg cityMsg = cityMsgList?.FirstOrDefault(f => f.Id == x.MsgId);
                    if (cityMsg != null)
                    {
                        x.MsgTxt      = cityMsg.msgDetail.Length > 20 ? cityMsg.msgDetail.Substring(0, 20) + "..." : cityMsg.msgDetail;
                        x.MsgFirstImg = cityMsg.imgList.FirstOrDefault();
                    }

                    x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime);
                });
            }

            return(listCityMsgComment);
        }
Beispiel #7
0
        /// <summary>
        /// 获取帖子列表 排列顺序为 置顶未失效>时间降序
        /// 然后再到前端进行排序 如果时间按照最近则不需要排序
        /// 如果是按距离则再排一次先是置顶的然后 距离有限 再按时间降序
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>

        public List <PlatMsg> GetListMsg(int aid, out int totalCount, string keyMsg = "", int msgTypeId = 0, int pageSize = 10, int pageIndex = 1, int orderType = 0, double ws_lat = 0, double ws_lng = 0)
        {
            string strWhere = $" aid={aid} and state=1 and PayState=1 ";

            if (msgTypeId > 0)
            {
                strWhere += $"  and MsgTypeId={msgTypeId} ";
            }

            List <MySqlParameter> parameters = new List <MySqlParameter>();

            if (!string.IsNullOrEmpty(keyMsg))
            {
                strWhere += $" and msgDetail like @keyMsg ";
                parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%"));
            }

            totalCount = base.GetCount(strWhere, parameters.ToArray());

            string sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now()) as tspan from platmsg where (DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY addtime desc LIMIT 100000)t1 
UNION
 SELECT* FROM(
SELECT*, (DATE_ADD(ReviewTime, INTERVAL topDay DAY)-now()) as tspan from platmsg where (DATE_ADD(ReviewTime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere}  ORDER BY addtime desc LIMIT 100000) t2
) t3 limit {(pageIndex - 1) * pageSize},{pageSize}";

            if (orderType > 0)
            {//表示附近
                sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from platmsg where (DATE_ADD(ReviewTime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY distance asc,addtime desc LIMIT 100000)t1 
UNION
 SELECT* FROM(
SELECT*, (DATE_ADD(ReviewTime, INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from platmsg where (DATE_ADD(ReviewTime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere}  ORDER BY distance asc, addtime desc LIMIT 100000) t2
) t3 limit {(pageIndex - 1) * pageSize},{pageSize}";
            }

            //   log4net.LogHelper.WriteInfo(this.GetType(),sql);
            List <PlatMsg> listPlatMsg = base.GetListBySql(sql, parameters.ToArray());

            if (listPlatMsg != null && listPlatMsg.Count > 0)
            {
                string            cardIds        = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct());
                List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds);

                string             msgTypeIds      = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct());
                List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds);

                listPlatMsg.ForEach(x =>
                {
                    //获取用户头像
                    PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId);
                    if (platMyCard != null)
                    {
                        x.UserName      = platMyCard.Name;
                        x.UserHeaderImg = platMyCard.ImgUrl;
                        x.UserId        = platMyCard.UserId;
                    }

                    //获取帖子类别
                    PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId);
                    if (platMsgType != null)
                    {
                        x.MsgTypeName = platMsgType.Name;
                    }

                    //根据帖子ID获取其浏览量-收藏量-分享量数据
                    PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子);
                    if (_platMsgviewFavoriteShare != null)
                    {
                        x.ViewCount     = _platMsgviewFavoriteShare.ViewCount;
                        x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount;
                        x.ShareCount    = _platMsgviewFavoriteShare.ShareCount;
                        x.DzCount       = _platMsgviewFavoriteShare.DzCount;
                    }

                    x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime);
                    x.MsgDetail   = HttpUtility.HtmlDecode(x.MsgDetail);
                });
            }

            totalCount = base.GetCount(strWhere, parameters.ToArray());
            return(listPlatMsg);
        }
Beispiel #8
0
        public List <CityMsg> getListCity_Msg(int aid, out int totalCount, int pageSize = 10, int pageIndex = 1, int msgTypeId = 0, string keyMsg = "", int orderType = 0, double ws_lat = 0, double ws_lng = 0)
        {
            string strWhere      = $"  aid={aid} and state=1 ";
            string strWhereCount = $" aid={aid} and state=1 ";

            if (msgTypeId > 0)
            {
                strWhere      += $"  and msgTypeId={msgTypeId}";
                strWhereCount += $"  and msgTypeId={msgTypeId}";
            }
            List <MySqlParameter> parameters = new List <MySqlParameter>();

            if (!string.IsNullOrEmpty(keyMsg))
            {
                strWhere      += $" and msgDetail like @keyMsg ";
                strWhereCount += $" and msgDetail like @keyMsg ";
                parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%"));
            }
            //TODO 测试时的时间单位为分钟MINUTE  线上为天DAY
            string sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(addtime,INTERVAL topDay DAY)-now()) as tspan from CityMsg where (DATE_ADD(addtime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY addtime desc LIMIT 100000)t1 
UNION
 SELECT* FROM(
SELECT*, (DATE_ADD(addtime, INTERVAL topDay DAY)-now()) as tspan from CityMsg where (DATE_ADD(addtime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere}  ORDER BY addtime desc LIMIT 100000) t2
) t3 limit {(pageIndex - 1) * pageSize},{pageSize}";

            if (orderType > 0)
            {//表示附近
                sql = $@"SELECT * FROM( SELECT * FROM (SELECT *,(DATE_ADD(addtime,INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from CityMsg where (DATE_ADD(addtime,INTERVAL topDay DAY)-now())>0 and { strWhere} ORDER BY distance asc,addtime desc LIMIT 100000)t1 
UNION
 SELECT* FROM(
SELECT*, (DATE_ADD(addtime, INTERVAL topDay DAY)-now()) as tspan,ROUND(6378.138*2*ASIN(SQRT(POW(SIN(({ws_lat}*PI()/180-lat*PI()/180)/2),2)+COS({ws_lat}*PI()/180)*COS(lat*PI()/180)*POW(SIN(({ws_lng}*PI()/180-lng*PI()/180)/2),2)))*1000) AS distance from CityMsg where (DATE_ADD(addtime, INTERVAL topDay DAY) - now()) <= 0 and { strWhere}  ORDER BY distance asc, addtime desc LIMIT 100000) t2
) t3 limit {(pageIndex - 1) * pageSize},{pageSize}";
            }
            List <CityMsg> listCity_Msg = base.GetListBySql(sql, parameters.ToArray());

            if (listCity_Msg != null && listCity_Msg.Count > 0)
            {
                string            userIds      = string.Join(",", listCity_Msg.Select(s => s.userId).Distinct());
                List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds);

                string cityMsgIds = string.Join(",", listCity_Msg.Select(s => s.msgTypeId));
                List <CityStoreMsgType> cityStoreMsgTypeList = CityStoreMsgTypeBLL.SingleModel.GetListByIds(cityMsgIds);

                string msgShareIds = string.Join(",", listCity_Msg.Select(s => s.Id));
                List <CityMsgViewFavoriteShare> cityMsgViewFavoriteShareList = CityMsgViewFavoriteShareBLL.SingleModel.GetListByMsgIds(msgShareIds);

                listCity_Msg.ForEach(x =>
                {
                    //获取用户头像 昵称
                    C_UserInfo c_UserInfo = userInfoList?.FirstOrDefault(f => f.Id == x.userId);
                    if (c_UserInfo != null)
                    {
                        x.userName      = c_UserInfo.NickName;
                        x.userHeaderImg = c_UserInfo.HeadImgUrl;
                    }

                    //获取帖子类别
                    CityStoreMsgType city_StoreMsgType = cityStoreMsgTypeList?.FirstOrDefault(f => f.Id
                                                                                              == x.msgTypeId);
                    if (city_StoreMsgType != null)
                    {
                        x.msgTypeName = city_StoreMsgType.name;
                    }

                    //根据帖子ID获取其浏览量-收藏量-分享量数据
                    CityMsgViewFavoriteShare city_MsgViewFavoriteShare = cityMsgViewFavoriteShareList?.FirstOrDefault(f => f.Id == x.Id);
                    if (city_MsgViewFavoriteShare != null)
                    {
                        x.ViewCount     = city_MsgViewFavoriteShare.ViewCount;
                        x.FavoriteCount = city_MsgViewFavoriteShare.FavoriteCount;
                        x.ShareCount    = city_MsgViewFavoriteShare.ShareCount;
                        x.DzCount       = city_MsgViewFavoriteShare.DzCount;
                    }

                    x.showTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime);
                    x.msgDetail   = HttpUtility.HtmlDecode(x.msgDetail);
                });
            }



            totalCount = base.GetCount(strWhereCount, parameters.ToArray());


            return(listCity_Msg);
        }
Beispiel #9
0
        /// <summary>
        /// 根据用户Id获取该用户的帖子信息
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="totalCount"></param>
        /// <param name="userId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="orderType">帖子排序字段 默认为0表示按照时间降序排列 1表示先按照置顶排序 然后再按照时间</param>
        /// <returns></returns>
        public List <CityMsg> getListByUserId(int aid, out int totalCount, int userId, int pageSize = 10, int pageIndex = 1, int orderType = 0)
        {
            List <string> listMsgId = new List <string>();

            List <CityMorders> listCityMorder = new CityMordersBLL().GetList($"MinisnsId={aid} and payment_status=1 and Status=1");

            if (listCityMorder != null && listCityMorder.Count > 0)
            {
                foreach (CityMorders item in listCityMorder)
                {
                    listMsgId.Add(item.CommentId.ToString());
                }
            }
            else
            {
                listMsgId.Add("0");
            }

            string strWhere   = $"aid={aid} and userId={userId} and ( (state<>-1 and topDay=0) or (state<>-1 and Id in({string.Join(",",listMsgId)}))) ";
            string orderWhere = " addTime desc";//默认按照时间降序排序

            //if (orderType == 1)
            //{
            //    orderWhere = " topDay desc,addTime desc";//先按照置顶排序 然后再按照时间



            //    strWhere += "";
            //}


            totalCount = base.GetCount(strWhere);

            List <CityMsg> listCity_Msg = base.GetList(strWhere, pageSize, pageIndex, "*", orderWhere);

            if (listCity_Msg != null && listCity_Msg.Count > 0)
            {
                string            userIds      = string.Join(",", listCity_Msg.Select(s => s.userId).Distinct());
                List <C_UserInfo> userInfoList = C_UserInfoBLL.SingleModel.GetListByIds(userIds);

                string cityMsgIds = string.Join(",", listCity_Msg.Select(s => s.msgTypeId));
                List <CityStoreMsgType> cityStoreMsgTypeList = CityStoreMsgTypeBLL.SingleModel.GetListByIds(cityMsgIds);

                string msgShareIds = string.Join(",", listCity_Msg.Select(s => s.Id));
                List <CityMsgViewFavoriteShare> cityMsgViewFavoriteShareList = CityMsgViewFavoriteShareBLL.SingleModel.GetListByMsgIds(msgShareIds);

                listCity_Msg.ForEach(x =>
                {
                    //获取用户头像
                    C_UserInfo c_UserInfo = userInfoList?.FirstOrDefault(f => f.Id == x.userId);
                    if (c_UserInfo != null)
                    {
                        x.userName      = c_UserInfo.NickName;
                        x.userHeaderImg = c_UserInfo.HeadImgUrl;
                    }

                    //获取帖子类别
                    CityStoreMsgType city_StoreMsgType = cityStoreMsgTypeList?.FirstOrDefault(f => f.Id == x.msgTypeId);
                    if (city_StoreMsgType != null)
                    {
                        x.msgTypeName = city_StoreMsgType.name;
                    }

                    //根据帖子ID获取其浏览量-收藏量-分享量数据
                    CityMsgViewFavoriteShare city_MsgViewFavoriteShare = cityMsgViewFavoriteShareList?.FirstOrDefault(f => f.Id == x.Id);
                    if (city_MsgViewFavoriteShare != null)
                    {
                        x.ViewCount     = city_MsgViewFavoriteShare.ViewCount;
                        x.FavoriteCount = city_MsgViewFavoriteShare.FavoriteCount;
                        x.ShareCount    = city_MsgViewFavoriteShare.ShareCount;
                        x.DzCount       = city_MsgViewFavoriteShare.DzCount;
                    }

                    x.showTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.addTime);
                    x.msgDetail   = HttpUtility.HtmlDecode(x.msgDetail);
                });
            }

            return(listCity_Msg);
        }
Beispiel #10
0
        /// <summary>
        /// 获取帖子评论列表
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="totalCount"></param>
        /// <param name="DataType"></param>
        /// <param name="keyMsg"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="Id">帖子Id 可空 如果大于0则表示是获取某条帖子的</param>
        /// <param name="userId">用户Id 获取用户帖子所属评论</param>
        /// <returns></returns>
        public List <PlatMsgComment> GetPlatMsgComment(int aid, out int totalCount, int DataType = 0, string keyMsg = "", int pageSize = 10, int pageIndex = 1, int Id = 0, int userId = 0)
        {
            string strWhere = $"aid={aid} and State=0 and DataType={DataType}  ";
            List <MySqlParameter> parameters = new List <MySqlParameter>();

            if (userId > 0)
            {
                strWhere += $"  and UserId={userId} ";
            }

            if (Id > 0)
            {
                strWhere += $"  and MsgId={Id}";
            }

            if (!string.IsNullOrEmpty(keyMsg))
            {
                strWhere += $" and CommentDetail like @keyMsg ";
                parameters.Add(new MySqlParameter("keyMsg", $"%{keyMsg}%"));
            }
            //  log4net.LogHelper.WriteInfo(this.GetType(),strWhere);
            totalCount = base.GetCount(strWhere, parameters.ToArray());

            List <PlatMsgComment> listPlatMsgComment = base.GetListByParam(strWhere, parameters.ToArray(), pageSize, pageIndex, "*", " AddTime Desc");

            if (listPlatMsgComment != null && listPlatMsgComment.Count > 0)
            {
                listPlatMsgComment.ForEach(x =>
                {
                    PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModelByUserId(x.UserId, aid);
                    if (platMyCard != null)
                    {
                        x.NickName  = platMyCard.Name;
                        x.HeaderImg = platMyCard.ImgUrl;
                    }
                    else
                    {
                        C_UserInfo c_UserInfoFrom = C_UserInfoBLL.SingleModel.GetModel(x.UserId);
                        if (c_UserInfoFrom != null)
                        {
                            x.NickName  = c_UserInfoFrom.NickName;
                            x.HeaderImg = c_UserInfoFrom.HeadImgUrl;
                        }
                    }

                    PlatMyCard platMyCardTo = PlatMyCardBLL.SingleModel.GetModel(x.ToUserId);
                    if (platMyCardTo != null)
                    {
                        x.ToNickName  = platMyCardTo.Name;
                        x.ToHeaderImg = platMyCardTo.ImgUrl;
                    }
                    else
                    {
                        C_UserInfo c_UserInfo = C_UserInfoBLL.SingleModel.GetModel(x.ToUserId);
                        if (c_UserInfo != null)
                        {
                            x.NickName  = c_UserInfo.NickName;
                            x.HeaderImg = c_UserInfo.HeadImgUrl;
                        }
                    }

                    PlatMsg platMsg = PlatMsgBLL.SingleModel.GetModel(x.MsgId);
                    if (platMsg != null)
                    {
                        x.MsgTxt      = platMsg.MsgDetail.Length > 20 ? platMsg.MsgDetail.Substring(0, 20) + "..." : platMsg.MsgDetail;
                        x.MsgFirstImg = platMsg.Imgs == null ? "" : platMsg.ImgList.FirstOrDefault();
                    }


                    x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime);
                });
            }

            return(listPlatMsgComment);
        }
Beispiel #11
0
        /// <summary>
        /// 获取用户收藏帖子列表
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="userId"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public List <PlatMsg> GetListMyFavoriteMsg(int aid, int myCardId, out int totalCount, int pageSize = 10, int pageIndex = 1)
        {
            string strWhere = $"aid={aid} and userId={myCardId} and state=0 and actionType={(int)PointsActionType.收藏} and Datatype={(int)PointsDataType.帖子}";

            totalCount = base.GetCount(strWhere);
            List <PlatMsg>             listPlatMsg             = new List <PlatMsg>();
            List <PlatUserFavoriteMsg> listPlatUserFavoriteMsg = base.GetList(strWhere, pageSize, pageIndex, "*", "addTime desc");

            if (listPlatUserFavoriteMsg != null && listPlatUserFavoriteMsg.Count > 0)
            {
                List <string> listMsgId = new List <string>();
                foreach (var item in listPlatUserFavoriteMsg)
                {
                    listMsgId.Add(item.MsgId.ToString());//获取到需要获取帖子的Id
                }
                if (listMsgId != null && listMsgId.Count > 0)
                {
                    listPlatMsg = PlatMsgBLL.SingleModel.GetListByIds(aid, string.Join(",", listMsgId.ToArray()));
                    if (listPlatMsg != null && listPlatMsg.Count > 0)
                    {
                        string            cardIds        = string.Join(",", listPlatMsg.Select(s => s.MyCardId).Distinct());
                        List <PlatMyCard> platMyCardList = PlatMyCardBLL.SingleModel.GetListByIds(cardIds);

                        string             msgTypeIds      = string.Join(",", listPlatMsg.Select(s => s.MsgTypeId).Distinct());
                        List <PlatMsgType> platMsgTypeList = PlatMsgTypeBLL.SingleModel.GetListByIds(msgTypeIds);

                        listPlatMsg.ForEach(x =>
                        {
                            //获取用户头像
                            PlatMyCard platMyCard = platMyCardList?.FirstOrDefault(f => f.Id == x.MyCardId);
                            if (platMyCard != null)
                            {
                                x.UserName      = platMyCard.Name;
                                x.UserHeaderImg = platMyCard.ImgUrl;
                            }

                            //获取帖子类别
                            PlatMsgType platMsgType = platMsgTypeList?.FirstOrDefault(f => f.Id == x.MsgTypeId);
                            if (platMsgType != null)
                            {
                                x.MsgTypeName = platMsgType.Name;
                            }

                            //根据帖子ID获取其浏览量-收藏量-分享量数据
                            PlatMsgviewFavoriteShare _platMsgviewFavoriteShare = PlatMsgviewFavoriteShareBLL.SingleModel.GetModelByMsgId(x.Aid, x.Id, (int)PointsDataType.帖子);
                            if (_platMsgviewFavoriteShare != null)
                            {
                                x.ViewCount     = _platMsgviewFavoriteShare.ViewCount;
                                x.FavoriteCount = _platMsgviewFavoriteShare.FavoriteCount;
                                x.ShareCount    = _platMsgviewFavoriteShare.ShareCount;
                                x.DzCount       = _platMsgviewFavoriteShare.DzCount;
                            }

                            x.ShowTimeStr = CommondHelper.GetTimeSpan(DateTime.Now - x.AddTime);
                            x.FavoriteId  = listPlatUserFavoriteMsg.FirstOrDefault(y => y.MsgId == x.Id).Id;//收藏记录ID
                        });
                    }
                }
            }

            return(listPlatMsg);
        }