コード例 #1
0
ファイル: apiPlatMsgController.cs プロジェクト: soon14/vzan
        /// <summary>
        /// 获取一条帖子的详情
        /// </summary>
        /// <returns></returns>
        public ActionResult GetMsgDetail()
        {
            returnObj = new Return_Msg_APP();
            string appId  = Utility.IO.Context.GetRequest("appId", string.Empty);
            int    msgId  = Utility.IO.Context.GetRequestInt("msgId", 0);  //帖子信息Id
            int    userId = Utility.IO.Context.GetRequestInt("userId", 0); // 类似用户Id

            if (string.IsNullOrEmpty(appId) || msgId <= 0)
            {
                returnObj.code = "200";
                returnObj.Msg  = "参数错误";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.code = "200";
                returnObj.Msg  = "小程序未授权";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }


            PlatMsg model = PlatMsgBLL.SingleModel.GetMsg(r.Id, msgId);

            if (model == null)
            {
                returnObj.code = "200";
                returnObj.Msg  = "找不到数据";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }



            PlatUserFavoriteMsg _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, msgId, userId, (int)PointsActionType.收藏);

            model.IsFavorited = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1);

            PlatUserFavoriteMsg _userFavoriteMsgDz = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, msgId, userId, (int)PointsActionType.点赞);

            model.IsDzed = (_userFavoriteMsgDz != null && _userFavoriteMsgDz.State != -1);

            PlatMsgReport _platMsgReport = PlatMsgReportBLL.SingleModel.GetMsgReport(userId, msgId);

            model.IsReported = (_platMsgReport != null);

            returnObj.isok    = true;
            returnObj.Msg     = "获取成功";
            returnObj.dataObj = new { msg = model };
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
ファイル: apiPlatMsgController.cs プロジェクト: soon14/vzan
        public ActionResult AddReportMsg()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            string appId        = Utility.IO.Context.GetRequest("appId", string.Empty);
            int    msgId        = Utility.IO.Context.GetRequestInt("msgId", 0);
            int    userId       = Utility.IO.Context.GetRequestInt("mycardId", 0);
            string reportReason = Utility.IO.Context.GetRequest("reportReason", string.Empty);

            if (string.IsNullOrEmpty(appId) || msgId <= 0 || userId <= 0 || string.IsNullOrEmpty(reportReason))
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj));
            }
            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj));
            }
            PlatMsgReport platMsgReport = new PlatMsgReport();

            platMsgReport.AddTime      = DateTime.Now;
            platMsgReport.Aid          = r.Id;
            platMsgReport.MsgId        = msgId;
            platMsgReport.ReportReason = HttpUtility.HtmlEncode(reportReason);//编码保存
            platMsgReport.ReportcardId = userId;

            int id = Convert.ToInt32(PlatMsgReportBLL.SingleModel.Add(platMsgReport));

            if (id <= 0)
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj));
            }

            returnObj.isok    = true;
            returnObj.Msg     = "举报成功";
            returnObj.dataObj = new { id = id };
            return(Json(returnObj));
        }
コード例 #3
0
ファイル: apiPlatMsgController.cs プロジェクト: soon14/vzan
        /// <summary>
        /// 获取帖子列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetMsgList()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            int    userId    = Context.GetRequestInt("userId", 0);
            string appId     = Context.GetRequest("appId", string.Empty);
            string keyMsg    = Context.GetRequest("keyMsg", string.Empty);
            int    orderType = Context.GetRequestInt("orderType", 0); //默认为0 表示最新发布  1表示距离最近
            int    msgTypeId = Context.GetRequestInt("msgTypeId", 0); //类别默认为0 表示获取所有
            int    pageSize  = Context.GetRequestInt("pageSize", 10);
            int    pageIndex = Context.GetRequestInt("pageIndex", 1);
            string latStr    = Context.GetRequest("lat", string.Empty);
            string lngStr    = Context.GetRequest("lng", string.Empty);

            if (string.IsNullOrEmpty(appId))
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            int totalCount        = 0;
            int commentTotalCount = 0; //帖子对应的评论条数
            int count             = 0; //帖子对应的点赞用户数

            List <PlatMsg> list = new List <PlatMsg>();

            if (orderType == 1)
            {
                double lat = 0.00;
                double lng = 0.00;
                //表示按照距离最近的
                //表示没有传坐标 通过客户端IP获取经纬度
                // log4net.LogHelper.WriteInfo(this.GetType(), $"!!!!orderType={orderType};{lat},{lng}");
                if (!double.TryParse(latStr, out lat) || !double.TryParse(lngStr, out lng) || lat == 0 || lng == 0)
                {
                    string IP = WebHelper.GetIP();

                    IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP);
                    if (iPToPoint != null)
                    {
                        lat = iPToPoint.result.location.lat;
                        lng = iPToPoint.result.location.lng;
                        //log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}");
                    }
                }
                //log4net.LogHelper.WriteInfo(this.GetType(),$"orderType={orderType};{lat},{lng}" );

                list = PlatMsgBLL.SingleModel.GetListMsg(r.Id, out totalCount, keyMsg, msgTypeId, pageSize, pageIndex, 1, lat, lng);

                list.ForEach(x =>
                {
                    PlatUserFavoriteMsg _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, x.Id, userId, (int)PointsActionType.收藏);
                    x.IsFavorited = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1);

                    _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, x.Id, userId, (int)PointsActionType.点赞);
                    x.IsDzed         = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1);

                    PlatMsgReport _platMsgReport = PlatMsgReportBLL.SingleModel.GetMsgReport(userId, x.Id);
                    x.IsReported = (_platMsgReport != null);


                    x.Comments = PlatMsgCommentBLL.SingleModel.GetPlatMsgComment(r.Id, out commentTotalCount, 0, string.Empty, 1000, 1, x.Id, 0);


                    x.DzUsers = PlatUserFavoriteMsgBLL.SingleModel.GetMsgUserFavoriteList(0, x.Aid, x.Id, (int)PointsActionType.点赞, (int)PointsDataType.帖子, 1, 1000, ref count);
                });
            }
            else
            {
                list = PlatMsgBLL.SingleModel.GetListMsg(r.Id, out totalCount, keyMsg, msgTypeId, pageSize, pageIndex);

                list.ForEach(x =>
                {
                    PlatUserFavoriteMsg _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, x.Id, userId, (int)PointsActionType.收藏);
                    x.IsFavorited = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1);

                    _userFavoriteMsg = PlatUserFavoriteMsgBLL.SingleModel.GetUserFavoriteMsg(r.Id, x.Id, userId, (int)PointsActionType.点赞);
                    x.IsDzed         = (_userFavoriteMsg != null && _userFavoriteMsg.State != -1);

                    PlatMsgReport _platMsgReport = PlatMsgReportBLL.SingleModel.GetMsgReport(userId, x.Id);
                    x.IsReported = (_platMsgReport != null);


                    x.Comments = PlatMsgCommentBLL.SingleModel.GetPlatMsgComment(r.Id, out commentTotalCount, 0, string.Empty, 1000, 1, x.Id, 0);

                    x.DzUsers = PlatUserFavoriteMsgBLL.SingleModel.GetMsgUserFavoriteList(0, x.Aid, x.Id, (int)PointsActionType.点赞, (int)PointsDataType.帖子, 1, 1000, ref count);
                });
            }

            returnObj.isok    = true;
            returnObj.Msg     = "获取成功";
            returnObj.dataObj = new { totalCount = totalCount, list = list };
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }