|
@@ -147,12 +147,18 @@ public class NewsArticleServiceImpl extends BaseService implements NewsArticleSe
|
|
|
}
|
|
|
if (newsArticleDto.getPhoto() != null) {
|
|
|
try {
|
|
|
-
|
|
|
+ photoService.deletePhoto(newsArticlePo.getPhotoId());
|
|
|
+
|
|
|
+ PhotoDto photoDto = new PhotoDto();
|
|
|
+ photoDto.setName(newsArticleDto.getTitle());
|
|
|
+ photoDto.setType(PhotoTypeEnum.NEWS_PHOTO.getValue());
|
|
|
+ photoDto.setStatus(PhotoStatusEnum.UPLOAD_SUCCESS_HAVE_USED.getValue());
|
|
|
+ PhotoVo photoVo = photoService.savePhoto(photoDto);
|
|
|
+ newsArticlePo.setPhotoId(photoVo.getId());
|
|
|
} catch (ServiceException e) {
|
|
|
-
|
|
|
+ log.error("更换新闻封面图失败,失败原因:{}", e.getMessage());
|
|
|
+ throw new ServiceException("更换新闻封面图失败");
|
|
|
}
|
|
|
- photoService.deletePhoto(newsArticlePo.getPhotoId());
|
|
|
- newsArticlePo.setPhotoId(newsArticleDto.getPhotoId());
|
|
|
}
|
|
|
mapper.updateById(newsArticlePo);
|
|
|
} catch (Exception e) {
|