|
@@ -69,8 +69,8 @@ public class WechatArticleServiceImpl implements WechatArticleService {
|
|
|
@Override
|
|
|
public ResponseJson<WechatArticle> getArticle(Integer id) {
|
|
|
WechatArticle article = weChatDao.getWechatArticle(id);
|
|
|
- List<WechatArticleDetail> articleList = weChatDao.getArticleDetailList(article.getId());
|
|
|
- article.setDetailList(articleList);
|
|
|
+ List<WechatArticleDetail> detailList = weChatDao.getArticleDetailList(article.getId());
|
|
|
+ article.setDetailList(detailList);
|
|
|
return ResponseJson.success(article);
|
|
|
}
|
|
|
|
|
@@ -146,13 +146,21 @@ public class WechatArticleServiceImpl implements WechatArticleService {
|
|
|
log.error("文章列表JSON数据解析异常try-catch:", e);
|
|
|
return ResponseJson.error("文章列表JSON数据解析异常!", null);
|
|
|
}
|
|
|
+ List<Integer> dbDetailIds = weChatDao.getArticleDetailIds(article.getId());
|
|
|
+ List<Integer> detailIds = new ArrayList<>();
|
|
|
for (WechatArticleDetail detail : detailList) {
|
|
|
if (null != detail.getId() && detail.getId() > 0) {
|
|
|
weChatDao.updateWechatArticleDetail(detail);
|
|
|
+ detailIds.add(detail.getId());
|
|
|
} else {
|
|
|
weChatDao.insertWechatArticleDetail(detail);
|
|
|
}
|
|
|
}
|
|
|
+ for (Integer id : dbDetailIds) {
|
|
|
+ if (!detailIds.contains(id)){
|
|
|
+ weChatDao.deleteWechatArticleDetail(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -186,7 +194,7 @@ public class WechatArticleServiceImpl implements WechatArticleService {
|
|
|
@Override
|
|
|
public ResponseJson<Void> deleteArticle(Integer id) {
|
|
|
weChatDao.deleteWechatArticle(id);
|
|
|
- weChatDao.deleteWechatArticleDetail(id);
|
|
|
+ weChatDao.deleteDetailByArticleId(id);
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
}
|