|
@@ -106,9 +106,9 @@ public class ArticleServiceImpl implements ArticleService
|
|
|
if (!as.isEmpty()){
|
|
|
for (Article a : as) {
|
|
|
ArticleCoverImg articleCoverImg= coverImgMapper.selectByArticleId(a.getId());
|
|
|
- if(null!=articleCoverImg&&articleCoverImg.getCoverImgData()!=null){
|
|
|
- a.setCoverImg(articleCoverImg.getCoverImgData());
|
|
|
- }
|
|
|
+// if(null!=articleCoverImg&&articleCoverImg.getCoverImgData()!=null){
|
|
|
+// a.setCoverImg(articleCoverImg.getCoverImgData());
|
|
|
+// }
|
|
|
|
|
|
if (a.getCategoryIds()!=null&&!a.getCategoryIds().isEmpty()) {
|
|
|
List<String> categoryIds = JSONObject.parseArray(a.getCategoryIds(), String.class);
|
|
@@ -138,7 +138,7 @@ public class ArticleServiceImpl implements ArticleService
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public void insertOrUpdateArticle(String title, String categoryIds,String profile, String content, String state, MultipartFile coverImage, Integer id,String productId) {
|
|
|
+ public void insertOrUpdateArticle(String title, String categoryIds,String profile, String content, String state, String coverImage, Integer id,String productId) {
|
|
|
Optional.ofNullable(title).orElseThrow(() -> new RuntimeException("请传标题"));
|
|
|
Optional.ofNullable(content).orElseThrow(() -> new RuntimeException("请书写文章内容"));
|
|
|
Optional.ofNullable(state).orElseThrow(() -> new RuntimeException("请传递发布类型"));
|
|
@@ -160,13 +160,15 @@ public class ArticleServiceImpl implements ArticleService
|
|
|
article.setUpdateTime(LocalDateTime.now());
|
|
|
article.setCreateUser(6);
|
|
|
article.setProductId(productId);
|
|
|
+ article.setCoverImgUrl(coverImage);
|
|
|
|
|
|
articleMapper.insert(article);
|
|
|
log.info("文章的id{}", article.getId());
|
|
|
|
|
|
- if (coverImage != null) {
|
|
|
- handleCoverImage(coverImage, article.getId());
|
|
|
- }
|
|
|
+// if (coverImage != null) {
|
|
|
+//// handleCoverImage(coverImage, article.getId());
|
|
|
+//
|
|
|
+// }
|
|
|
}
|
|
|
// 修改
|
|
|
else {
|
|
@@ -182,14 +184,9 @@ public class ArticleServiceImpl implements ArticleService
|
|
|
article.setUpdateTime(LocalDateTime.now());
|
|
|
article.setId(id);
|
|
|
article.setProductId(productId);
|
|
|
+ article.setCoverImgUrl(coverImage);
|
|
|
articleMapper.update(article);
|
|
|
|
|
|
- if (coverImage != null) {
|
|
|
- coverImgMapper.deleteByArticleId(id);
|
|
|
- handleCoverImage(coverImage, article.getId());
|
|
|
- } else {
|
|
|
- coverImgMapper.deleteByArticleId(id);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -250,7 +247,7 @@ public class ArticleServiceImpl implements ArticleService
|
|
|
byte[] bytes = coverImage.getBytes();
|
|
|
ArticleCoverImg articleCoverImg = new ArticleCoverImg();
|
|
|
articleCoverImg.setArticleId(articleId);
|
|
|
- articleCoverImg.setCoverImgData(bytes);
|
|
|
+// articleCoverImg.setCoverImgData(bytes);
|
|
|
coverImgMapper.insert(articleCoverImg);
|
|
|
} catch (IOException e) {
|
|
|
throw new RuntimeException("保存封面图片失败", e);
|