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 })); }
public IActionResult GetArticleInfoAsync([FromBody] GetArticleInfoRequestDto request) { var articleBiz = new ArticleBiz(); var contentBiz = new RichtextBiz(); AccessoryBiz accessoryBiz = new AccessoryBiz(); CollectionBiz collection = new CollectionBiz(); var articleModel = articleBiz.GetModel(request.ArticleGuid); if (articleModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } var richtextModel = contentBiz.GetModel(articleModel.ContentGuid); var accessory = accessoryBiz.GetAccessoryModelByGuid(articleModel.PictureGuid); var likeCount = new LikeBiz().GetLikeNumByTargetGuid(articleModel.ArticleGuid); var pageViewCount = new ArticleViewBiz().CountNumByTargetIDAsync(articleModel.ArticleGuid).Result; int collectionCount = collection.GetListCountByTarget(articleModel.ArticleGuid); 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, ActcleReleaseStatus = articleModel.ActcleReleaseStatus.ToString(), CreationDate = articleModel.CreationDate, LikeCount = likeCount, VisitCount = pageViewCount, Collection = collectionCount })); }