From 8b02c916fec8819f4f1b27b21a26cca6c41b5f5d Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期一, 14 七月 2025 09:54:05 +0800
Subject: [PATCH] add:定时任务配置,热门城市
---
src/main/java/com/mzl/flower/service/film/impl/CommentLikesServiceImpl.java | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/mzl/flower/service/film/impl/CommentLikesServiceImpl.java b/src/main/java/com/mzl/flower/service/film/impl/CommentLikesServiceImpl.java
index 392b493..f61c5c7 100644
--- a/src/main/java/com/mzl/flower/service/film/impl/CommentLikesServiceImpl.java
+++ b/src/main/java/com/mzl/flower/service/film/impl/CommentLikesServiceImpl.java
@@ -1,6 +1,7 @@
package com.mzl.flower.service.film.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.dto.request.film.CommentLikesDTO;
import com.mzl.flower.dto.request.film.CommentLikesQueryDTO;
@@ -37,16 +38,32 @@
//查询有没有对应人员的点赞信息
CommentLikes commentLikes = commentLikesMapper.getCommentLikeByUserIdAndCommentId(SecurityUtils.getUserId(), commentLikesDTO.getCommentId());
if (commentLikes == null) {
- CommentLikes commentLikes1 = new CommentLikes();
- commentLikes1.setCommentId(commentLikesDTO.getCommentId());
- commentLikes1.setStatus(true);
- commentLikes1.create();
- commentLikesMapper.insert(commentLikes1);
+ commentLikes = new CommentLikes();
+ commentLikes.setCommentId(commentLikesDTO.getCommentId());
+ commentLikes.setStatus(true);
+ commentLikes.setCreateBy(SecurityUtils.getUserId());
+ commentLikes.create();
+ if (commentLikesMapper.insert(commentLikes) <= 0) {
+ throw new ValidationException("添加评论点赞失败");
+ }
} else {
// 状态取反
commentLikes.setStatus(!commentLikes.getStatus());
commentLikes.update(SecurityUtils.getUserId());
- commentLikesMapper.updateById(commentLikes);
+
+ // 校验主键是否存在
+ if (commentLikes.getId() == null) {
+ throw new ValidationException("主键 ID 不能为空");
+ }
+ int affectedRows = commentLikesMapper.updateStatusById(
+ commentLikes.getId(), // 确保 id 是 Long 类型
+ commentLikes.getStatus(),
+ SecurityUtils.getUserId() // 更新人
+ );
+ if (affectedRows <= 0) {
+ throw new ValidationException("更新作品点赞状态失败");
+ }
+
}
}
--
Gitblit v1.9.3