|
@@ -344,25 +344,24 @@ public class NewsArticleServiceImpl extends BaseService implements NewsArticleSe
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<NewsArticleBizVo> getNewsArticleByNavigationBarId(Long id) {
|
|
|
|
|
|
+ public IPage<NewsArticleBizVo> getNewsArticleByNavigationBarId(Page page, Long id) {
|
|
AssertUtils.assertNotNull(id, "id不能为空");
|
|
AssertUtils.assertNotNull(id, "id不能为空");
|
|
try {
|
|
try {
|
|
- List<NewsArticlePo> newsArticlePoList = mapper.getNewsArticleByNavigationBarId(id);
|
|
|
|
- List<NewsArticleBizVo> newsArticleVoList = new ArrayList<>();
|
|
|
|
- for (NewsArticlePo po : newsArticlePoList) {
|
|
|
|
- NewsArticleBizVo newsArticleVo = new NewsArticleBizVo();
|
|
|
|
- BeanUtil.copyProperties(newsArticleVo, po);
|
|
|
|
- if (po.getPhotoUrl() != null) {
|
|
|
|
- String url = accessPath + accessResource + po.getPhotoUrl().replace("/","");
|
|
|
|
- newsArticleVo.setPhotoUrl(url);
|
|
|
|
- }
|
|
|
|
- newsArticleVoList.add(newsArticleVo);
|
|
|
|
- }
|
|
|
|
- return newsArticleVoList;
|
|
|
|
|
|
+ IPage<NewsArticlePo> newsArticlePoList = mapper.getNewsArticleByNavigationBarId(page, id);
|
|
|
|
+ return newsArticlePoList.convert(this::convertNewsArticleBizVo);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("获取新闻数据失败,失败原因:{}", e.getMessage());
|
|
log.error("获取新闻数据失败,失败原因:{}", e.getMessage());
|
|
throw new ServiceException("获取新闻数据失败");
|
|
throw new ServiceException("获取新闻数据失败");
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ private NewsArticleBizVo convertNewsArticleBizVo(NewsArticlePo po) {
|
|
|
|
+ NewsArticleBizVo vo = new NewsArticleBizVo();
|
|
|
|
+ BeanUtils.copyProperties(po, vo);
|
|
|
|
+ if (po.getPhotoUrl() != null) {
|
|
|
|
+ String url = accessPath + accessResource + po.getPhotoUrl().replace("/","");
|
|
|
|
+ vo.setPhotoUrl(url);
|
|
|
|
+ }
|
|
|
|
+ return vo;
|
|
|
|
+ }
|
|
}
|
|
}
|