예제 #1
0
        public ActionResult <Result> CloseComment([FromRoute] string articleLangId)
        {
            //获取用户信息
            string user_id = Token.GetUserId(HttpContext.Request.Headers["Authorization"].ToString().Substring(7));
            TUser  user    = userServer.Retrieve(new TUser()
            {
                UserId = user_id
            });

            TArticleLang tlang = articleServer.Retrieve(new TArticleLang()
            {
                ArticleLangId = articleLangId
            });

            if (tlang == null)
            {
                throw new ResultException("文章不存在");
            }

            if (user.UserId != tlang.UserId)
            {
                throw new ResultException("无法操作他人的文章");
            }

            articleServer.CloseComment(tlang);

            return(new Result(200, "成功"));
        }