コード例 #1
0
        /// <summary>
        /// 图片详情接口
        /// </summary>
        /// <returns></returns>
        public void GetItem(HttpContext context)
        {
            int            pid = GetInt("pid");
            SourceMaterial sm  = SourceMaterialHelper.GetItem(pid);

            if (sm == null)
            {
                ReturnErrorMsg("图片墙不存在id:" + pid);
                return;
            }

            var url  = Utility.GetSizePicUrl(sm.Url, 500, 0, context);
            var data = new
            {
                pid         = sm.Id,
                title       = sm.Title,
                img         = url,
                description = sm.Description,
                views       = sm.Views,
                commentnum  = sm.Commentnum,
                height      = Utility.GetImgHeight(url, context)
            };

            sm.Views += 1;
            SourceMaterialHelper.Update(sm);
            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            jt.Add("data", data);
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
コード例 #2
0
        /// <summary>
        /// 图片评论
        /// </summary>
        /// <returns></returns>
        public void ImgComment()
        {
            int            userId = GetInt("uid");
            int            imgId  = GetInt("pid");
            string         msg    = GetString("message");
            var            user   = AccountHelper.GetUser(userId);
            SourceMaterial sm     = SourceMaterialHelper.GetItem(imgId);
            Comment        c      = new Comment();

            c.SellerId = sm.SellerId;
            c.TypeId   = sm.Id;
            c.UserId   = userId;
            c.Content  = msg;
            c.Type     = CommentType.Img;
            //冗余两个字段
            c.Img   = sm.Url;
            c.Title = sm.Title;
            try
            {
                CommentHelper.Create(c);
                sm.Commentnum += 1;
                SourceMaterialHelper.Update(sm);
            }
            catch
            {
                ReturnErrorMsg("fail");
                throw;
            }
            ExtcreditLog log = new ExtcreditLog();

            if (!ExtcreditLogHelper.JudgeExtcreditGet(ExtcreditSourceType.CommentImg, imgId, userId))
            {
                //积分获得
                log.UserId   = userId;
                log.SellerId = user.SellerId;
                log.SourceId = imgId;
                var setting = SystemHelper.GetMerchantExtend(user.SellerId);
                log.Extcredit  = setting != null ? setting.CommentIntegral : 0;
                log.Type       = ExtcreditSourceType.CommentImg;
                log.CreateTime = DateTime.Now;

                ExtcreditLogHelper.AddExtcreditLog(log);

                user.Integral += log.Extcredit;
                AccountHelper.SaveAccount(user);
            }

            //ReturnCorrectMsg("评论成功");
            JsonTransfer jt = new JsonTransfer();

            jt.Add("data", new IntegralData(log.Extcredit));
            jt.AddSuccessParam();
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
コード例 #3
0
        private void Update()
        {
            var id = GetInt("id");
            var sm = SourceMaterialHelper.GetItem(id);

            sm.Title = GetString("title");
            sm.Url   = GetString("thumbnail");
            var text = GetString("text");

            //sm.Summary = text.Length > 20 ? text.Substring(0, 20) : text;
            sm.Description = GetString("content");
            SourceMaterialHelper.Update(sm);
        }
コード例 #4
0
        /// <summary>
        /// 图片评论列表
        /// </summary>
        /// <returns></returns>
        public void ImgCommentList(HttpContext context)
        {
            int pid   = GetInt("pid");
            int index = GetInt("start");
            int size  = GetInt("limit");

            if (pid == 0)
            {
                ReturnErrorMsg("请传入正确的pid");
                return;
            }
            SourceMaterial sm   = SourceMaterialHelper.GetItem(pid);
            var            cms  = CommentHelper.GetPagings(sm.SellerId, CommentType.Img, pid, index * size, size, "order by CreateTime desc");
            var            data = new CommentsForApis();

            data.Commentnum = cms.TotalCount;
            JsonTransfer jt = new JsonTransfer();

            if (cms.Results.Count < 1)
            {
                jt.AddSuccessParam();
                jt.Add("data", data);
                Response.Write(DesEncrypt(jt).ToLower());
                Response.End();
                return;
            }
            var users = AccountHelper.GetUserList(cms.Results.Select(c => c.UserId).ToList());

            foreach (var cm in cms.Results)
            {
                var user = users.FirstOrDefault(u => u.Id == cm.UserId);
                if (user == null)
                {
                    throw new ArgumentNullException(string.Format("userId:{0}", cm.UserId));
                }
                var result = new ComentsForApi
                {
                    Avatar   = Utility.GetSizePicUrl(user.Avatar, 100, 100, context),
                    UserName = user.UserName,
                    Sex      = (int)user.Sex,
                    Dateline = cm.CreateTime.GetUnixTime(),
                    Message  = cm.Content
                };
                data.Comments.Add(result);
            }

            jt.AddSuccessParam();
            jt.Add("data", data);
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
コード例 #5
0
        /// <summary>
        /// 图片详情接口
        /// </summary>
        /// <returns></returns>
        public void GetItem()
        {
            int            pid  = GetInt("pid");
            SourceMaterial data = SourceMaterialHelper.GetItem(pid);

            if (data == null)
            {
                ReturnErrorMsg("图片墙不存在pid:" + pid);
                return;
            }
            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            jt.Add("data", data);
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }