| | |
| | | import com.ruoyi.article.controller.forepart.dto.ArticleDTO; |
| | | import com.ruoyi.article.controller.forepart.vo.ArticleCommentsVO; |
| | | import com.ruoyi.article.controller.forepart.vo.ArticleVO; |
| | | import com.ruoyi.article.controller.management.dto.MgtArticleDTO; |
| | | import com.ruoyi.article.controller.management.dto.MgtArticleQuery; |
| | | import com.ruoyi.article.controller.management.vo.MgtArticleVO; |
| | | import com.ruoyi.article.domain.Article; |
| | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.ArticleTypeEnum; |
| | | import com.ruoyi.common.core.enums.AuditStatusEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.core.utils.page.BeanUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.system.api.domain.Member; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | |
| | | @Override |
| | | public ArticleVO getMemberArticleInfo(ArticleDTO articleDTO) { |
| | | Article article=this.getById(articleDTO.getId()); |
| | | ArticleVO articleVO=new ArticleVO(); |
| | | |
| | | BeanUtils.copyProperties(article, articleVO); |
| | | |
| | | ArticleVO articleVO = BeanUtils.copyBean(article, |
| | | ArticleVO.class); |
| | | R<Member> membeOne = memberClient.getMembeOne(articleVO.getMemberId(), |
| | | SecurityConstants.INNER); |
| | | Member data = membeOne.getData(); |
| | |
| | | R<Member> membeOne = memberClient.getMembeOne(articleDTO.getMemberId(), |
| | | SecurityConstants.INNER); |
| | | Member data = membeOne.getData(); |
| | | article.setReportBy(data.getNickname()); |
| | | article.setReportBy(data.getId()); |
| | | article.setReportedTime(LocalDateTime.now()); |
| | | article.setReported(Boolean.TRUE); |
| | | this.saveOrUpdate(article); |
| | | } |
| | | |
| | | /** |
| | | * 获取资讯列表的分页数据 |
| | | * |
| | | * @param query 资讯管理查询条件 |
| | | * @return PageDTO<ArticleVO> |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtArticleVO> getArticlePage(MgtArticleQuery query) { |
| | | // 构建查询条件 |
| | |
| | | } |
| | | return pageVO; |
| | | } |
| | | |
| | | /** |
| | | * "添加/编辑资讯 |
| | | * |
| | | * @param dto 管理后台-资讯传输对象 |
| | | */ |
| | | @Override |
| | | public void saveArticle(MgtArticleDTO dto) { |
| | | Article article = BeanUtils.copyBean(dto, Article.class); |
| | | if (StringUtils.isNull(article.getId())) { |
| | | article.setStatus(AuditStatusEnum.PASSED); |
| | | this.save(article); |
| | | } else { |
| | | Article articleById = this.getById(article.getId()); |
| | | if (StringUtils.isNull(articleById)) { |
| | | throw new ServiceException("资讯不存在"); |
| | | } |
| | | this.updateById(article); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理举报 |
| | | * |
| | | * @param id 资讯id |
| | | */ |
| | | @Override |
| | | public void handleReport(Long id) { |
| | | Article article = this.getById(id); |
| | | if (StringUtils.isNull(article)) { |
| | | throw new ServiceException("资讯不存在"); |
| | | } |
| | | if (Boolean.FALSE.equals(article.getReported())) { |
| | | throw new ServiceException("该资讯未举报"); |
| | | } |
| | | article.setReported(Boolean.FALSE); |
| | | this.updateById(article); |
| | | } |
| | | |
| | | /** |
| | | * 查看详情 |
| | | * |
| | | * @param id 资讯id |
| | | * @return MgtArticleVO |
| | | */ |
| | | @Override |
| | | public MgtArticleVO getDetail(Long id) { |
| | | Article article = this.getById(id); |
| | | if (StringUtils.isNull(article)) { |
| | | throw new ServiceException("资讯不存在"); |
| | | } |
| | | return BeanUtils.copyBean(article, MgtArticleVO.class); |
| | | } |
| | | } |