Exemplo n.º 1
0
        public async Task <IActionResult> GetArticleInfoAsync([FromBody] GetArticleInfoRequestDto request)
        {
            var          articleBiz   = new ArticleBiz();
            var          contentBiz   = new RichtextBiz();
            AccessoryBiz accessoryBiz = new AccessoryBiz();
            var          articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }
            var richtextModel = await contentBiz.GetAsync(articleModel.ContentGuid);

            var accessory = await accessoryBiz.GetAsync(articleModel.PictureGuid);

            return(Success(new GetArticleInfoResponseDto
            {
                ArticleTypeDic = articleModel.ArticleTypeDic,
                Abstract = articleModel.Abstract,
                Content = richtextModel.Content,
                PictureGuid = articleModel.PictureGuid,
                Title = articleModel.Title,
                Visible = articleModel.Visible,
                PictureUrl = $"{accessory?.BasePath}{accessory?.RelativePath}",
                ArticleGuid = articleModel.ArticleGuid,
                Enable = articleModel.Enable,
                ActcleReleaseStatus = Enum.Parse <Dtos.Article.ReleaseStatus>(articleModel.ActcleReleaseStatus.ToString()),
                Keyword = JsonConvert.DeserializeObject <string[]>(string.IsNullOrWhiteSpace(articleModel.Keyword) ? "[]" : articleModel.Keyword),
                ExternalLink = articleModel.ExternalLink
            }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> SetArticleVisibleAsync([FromBody] SetArticleVisibleRequestDto request)
        {
            var articleBiz   = new ArticleBiz();
            var articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }
            articleModel.Visible = request.Visible;
            var response = await articleBiz.UpdateAsync(articleModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "跟新失败"));
            }
            return(Success());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> RemoveArticleAsync(string articleId)
        {
            var articleBiz   = new ArticleBiz();
            var articleModel = await articleBiz.GetAsync(articleId);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查询到该文章数据"));
            }
            articleModel.LastUpdatedBy   = UserID;
            articleModel.LastUpdatedDate = DateTime.Now;
            var result = await articleBiz.DeleteArticleAsync(articleModel);

            if (result && articleModel.ActcleReleaseStatus == ReleaseStatus.Release)
            {
                new DoctorActionBiz().DeleteArticleAsync(this.UserID);
            }
            return(Success(result));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> UpdateArticleAsync([FromBody] UpdateArticleRequestDto request)
        {
            var articleBiz   = new ArticleBiz();
            var contentBiz   = new RichtextBiz();
            var articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }

            var richtextModel = await contentBiz.GetAsync(articleModel.ContentGuid);

            richtextModel.Content         = request.Content;
            richtextModel.LastUpdatedBy   = UserID;
            richtextModel.LastUpdatedDate = DateTime.Now;
            richtextModel.OrgGuid         = string.Empty;
            richtextModel.OwnerGuid       = request.ArticleGuid;

            articleModel.Abstract            = request.Abstract;
            articleModel.ArticleTypeDic      = request.ArticleTypeDic;
            articleModel.LastUpdatedBy       = UserID;
            articleModel.LastUpdatedDate     = DateTime.Now;
            articleModel.Sort                = 1;
            articleModel.Title               = request.Title;
            articleModel.Visible             = request.Visible;
            articleModel.PictureGuid         = request.PictureGuid;
            articleModel.ActcleReleaseStatus = Enum.Parse <ReleaseStatus>(request.ActcleReleaseStatus);

            var response = await new ArticleBiz().UpdateAsync(richtextModel, articleModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "修改失败"));
            }
            //发布时才添加积分
            if (articleModel.ActcleReleaseStatus == ReleaseStatus.Release)
            {
                new DoctorActionBiz().AddArticleAsync(this.UserID);
            }
            return(Success(response));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> UpdateArticleAsync([FromBody] UpdateArticleRequestDto request)
        {
            var articleBiz   = new ArticleBiz();
            var contentBiz   = new RichtextBiz();
            var articleModel = await articleBiz.GetAsync(request.ArticleGuid);

            if (articleModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }
            var richtextModel = await contentBiz.GetAsync(articleModel.ContentGuid);

            richtextModel.Content         = request.Content;
            richtextModel.LastUpdatedBy   = UserID;
            richtextModel.LastUpdatedDate = DateTime.Now;
            richtextModel.OrgGuid         = string.Empty;
            richtextModel.OwnerGuid       = request.ArticleGuid;

            articleModel.Abstract            = request.Abstract;
            articleModel.ArticleTypeDic      = request.ArticleTypeDic;
            articleModel.LastUpdatedBy       = UserID;
            articleModel.LastUpdatedDate     = DateTime.Now;
            articleModel.Sort                = 1;
            articleModel.Title               = request.Title;
            articleModel.Enable              = request.Enable;
            articleModel.Visible             = request.Visible;
            articleModel.PictureGuid         = request.PictureGuid;
            articleModel.ActcleReleaseStatus = Enum.Parse <Models.Utility.ReleaseStatus>(request.ActcleReleaseStatus.ToString());
            articleModel.Keyword             = JsonConvert.SerializeObject(request.Keyword);
            articleModel.ExternalLink        = request.ExternalLink ?? string.Empty;

            var response = await new ArticleBiz().UpdateAsync(richtextModel, articleModel);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "修改失败"));
            }
            return(Success(response));
        }