public IActionResult GetUserArticles([FromBody] GetUserArticleRequestDto requestDto) { ArticleBiz articleBiz = new ArticleBiz(); var sourceTypeWhere = string.Empty; if (requestDto.SourceType != null) { sourceTypeWhere = $"and source_type='{requestDto.SourceType.Value.ToString()}'"; } var models = articleBiz.GetArticles(requestDto.PageIndex, requestDto.PageSize, $"where author_guid=@author_guid and actcle_release_status='Release' {sourceTypeWhere}", "last_updated_date desc", new { author_guid = requestDto.AuthorGuid }); if (models == null) { return(Failed(ErrorCode.Empty)); } var accessoryBiz = new AccessoryBiz(); var dictionaryBiz = new DictionaryBiz(); var responseDtos = new List <GetUserArticlesResponseDto>(); foreach (var model in models) { var dto = model.ToDto <GetUserArticlesResponseDto>(); var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(model.PictureGuid); dto.Picture = $"{accessoryModel?.BasePath}{accessoryModel?.RelativePath}"; dto.ArticleType = dictionaryBiz.GetModelById(model.ArticleTypeDic)?.ConfigName; dto.PageView = new ArticleViewBiz().CountNumByTargetIDAsync(model.ArticleGuid).Result; responseDtos.Add(dto); } return(Success(responseDtos)); }
public IActionResult GetCupationalDiseaseKnowledge([FromBody] GetCcupationalDiseaseKnowledgeRequestDto dto) { ArticleBiz articleBiz = new ArticleBiz(); var condition = "where article_type_dic=@article_type_dic and visible=true and enable=true "; var lst = articleBiz.GetArticles(dto.PageNumber, dto.PageSize, condition, "creation_date desc", new { article_type_dic = DictionaryType.OccupationalDiseaseKnowledge }); var accessoryBiz = new AccessoryBiz(); var dtos = new List <GetCcupationalDiseaseKnowledgeResponseDto>(); foreach (var item in lst) { var model = item.ToDto <GetCcupationalDiseaseKnowledgeResponseDto>(); var picture = MySqlHelper.GetModelById <AccessoryModel>(item.PictureGuid); model.Picture = $"{picture?.BasePath}{picture?.RelativePath}"; dtos.Add(model); } if (dtos.Count == 0) { return(Failed(ErrorCode.Empty)); } return(Success(dtos)); }