|
@@ -640,16 +640,29 @@ public class CommunityArticleController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 1.查询当前用户有没有这个合集
|
|
|
- * 2.情况1 如果文章在合集下,更新这个合集的删除状态,在插入到新的合集
|
|
|
+ * 1.查询当前文章是不是属于该用户的
|
|
|
+ * 2.查询当前用户有没有这个合集
|
|
|
+ * 3.情况1 如果文章在合集下,更新这个合集的删除状态,在插入到新的合集
|
|
|
* 4.情况2 如果文章就在需要添加的合集下,则返回 该文章在合集已经存在
|
|
|
- * 3.如果没有在合集下,直接插入
|
|
|
+ * .如果没有在合集下,直接插入
|
|
|
*/
|
|
|
Long collectionId = collectionArticle.getCollectionId();
|
|
|
Long articleId = collectionArticle.getArticleId();
|
|
|
Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
|
|
|
- //查询该用户有没有这个合集
|
|
|
+ //查询当前文章是不是属于该用户的
|
|
|
+ List<CommunityArticle> communityArticles = communityArticleMapper.selectList(new QueryWrapper<CommunityArticle>()
|
|
|
+ .eq("user_id",userId)
|
|
|
+ .eq("id",articleId)
|
|
|
+ .and((wrapper) -> {
|
|
|
+ wrapper.ne("is_delete", 1).or().isNull("is_delete");
|
|
|
+ }));
|
|
|
+
|
|
|
+ if (communityArticles.isEmpty()) {
|
|
|
+ return AjaxResult.success("文章ID不属于当前用户!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询当前用户有没有这个合集
|
|
|
List<CommunityCollection> communityCollections = communityCollectionMapper.selectList(new QueryWrapper<CommunityCollection>()
|
|
|
.eq("user_id", userId)
|
|
|
.eq("id",collectionId)
|