修复取消收藏接口

This commit is contained in:
TinyAnts 2022-09-08 18:02:13 +08:00
parent ff167a56b3
commit db5588577b
3 changed files with 8 additions and 8 deletions

View File

@ -107,10 +107,10 @@ public class ArticleController {
*/ */
@PostMapping("/cancelCollect") @PostMapping("/cancelCollect")
public Object cancelCollect(@RequestBody Map<String, String> params) { public Object cancelCollect(@RequestBody Map<String, String> params) {
Assert.notNull(params.get("id"), "id参数缺失"); Assert.notNull(params.get("articleId"), "id参数缺失");
Integer id = Integer.parseInt(params.get("id")); Integer id = Integer.parseInt(params.get("articleId"));
Integer userId = LikeFrontThreadLocal.getUserId(); Integer userId = LikeFrontThreadLocal.getUserId();
iArticleService.cancelCollect(id, userId); iArticleService.cancelCollect(articleId, userId);
return AjaxResult.success(); return AjaxResult.success();
} }

View File

@ -66,9 +66,9 @@ public interface IArticleService {
* 取消收藏 * 取消收藏
* *
* @author fzr * @author fzr
* @param id 主键 * @param articleId 主键
* @param userId 用户ID * @param userId 用户ID
*/ */
void cancelCollect(Integer id, Integer userId); void cancelCollect(Integer articleId, Integer userId);
} }

View File

@ -230,14 +230,14 @@ public class ArticleServiceImpl implements IArticleService {
* 取消收藏 * 取消收藏
* *
* @author fzr * @author fzr
* @param id 主键 * @param articleId 文章ID
* @param userId 用户ID * @param userId 用户ID
*/ */
@Override @Override
public void cancelCollect(Integer id, Integer userId) { public void cancelCollect(Integer articleId, Integer userId) {
ArticleCollect articleCollect = articleCollectMapper.selectOne( ArticleCollect articleCollect = articleCollectMapper.selectOne(
new QueryWrapper<ArticleCollect>() new QueryWrapper<ArticleCollect>()
.eq("id", id) .eq("article_id", articleId)
.eq("user_id", userId) .eq("user_id", userId)
.eq("is_delete", 0) .eq("is_delete", 0)
.last("limit 1")); .last("limit 1"));