From 6d8e44627f832bb16c346bb7429e6a2528871823 Mon Sep 17 00:00:00 2001 From: LingandRX <56020800+LingandRX@users.noreply.github.com> Date: Sun, 11 May 2025 22:03:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor(service):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84=E5=92=8C=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了未使用的导入语句 - 删除了不必要的变量和注释 -简化了一些代码逻辑 --- .../copykamanotes/service/impl/CommentServiceImpl.java | 5 ----- .../copykamanotes/service/impl/NoteLikeServiceImpl.java | 2 -- .../example/copykamanotes/service/impl/NoteServiceImpl.java | 2 -- 3 files changed, 9 deletions(-) diff --git a/src/main/java/com/example/copykamanotes/service/impl/CommentServiceImpl.java b/src/main/java/com/example/copykamanotes/service/impl/CommentServiceImpl.java index a68bee7..65b930e 100644 --- a/src/main/java/com/example/copykamanotes/service/impl/CommentServiceImpl.java +++ b/src/main/java/com/example/copykamanotes/service/impl/CommentServiceImpl.java @@ -14,7 +14,6 @@ import com.example.copykamanotes.model.entity.Comment; import com.example.copykamanotes.model.entity.Note; import com.example.copykamanotes.model.entity.User; import com.example.copykamanotes.model.vo.comment.CommentVO; -import com.example.copykamanotes.model.vo.note.NoteVO; import com.example.copykamanotes.model.vo.user.UserActionVO; import com.example.copykamanotes.scope.RequestScopeData; import com.example.copykamanotes.service.CommentService; @@ -26,9 +25,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; -import java.util.Date; import java.util.List; -import java.util.stream.Collectors; @Slf4j @Service @@ -217,8 +214,6 @@ public class CommentServiceImpl implements CommentService { @NeedLogin @Transactional public ApiResponse unlikeComment(Integer commentId) { - Long userId= requestScopeData.getUserId(); - Comment comment = commentMapper.findById(commentId); if (comment == null) { return ApiResponse.error(HttpStatus.NOT_FOUND.value(), "评论不存在"); diff --git a/src/main/java/com/example/copykamanotes/service/impl/NoteLikeServiceImpl.java b/src/main/java/com/example/copykamanotes/service/impl/NoteLikeServiceImpl.java index fe71285..f4755fe 100644 --- a/src/main/java/com/example/copykamanotes/service/impl/NoteLikeServiceImpl.java +++ b/src/main/java/com/example/copykamanotes/service/impl/NoteLikeServiceImpl.java @@ -1,7 +1,6 @@ package com.example.copykamanotes.service.impl; import com.example.copykamanotes.annotation.NeedLogin; -import com.example.copykamanotes.mapper.MessageMapper; import com.example.copykamanotes.mapper.NoteLikeMapper; import com.example.copykamanotes.mapper.NoteMapper; import com.example.copykamanotes.model.base.ApiResponse; @@ -13,7 +12,6 @@ import com.example.copykamanotes.service.MessageService; import com.example.copykamanotes.service.NoteLikeService; import com.example.copykamanotes.utils.ApiResponseUtils; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/com/example/copykamanotes/service/impl/NoteServiceImpl.java b/src/main/java/com/example/copykamanotes/service/impl/NoteServiceImpl.java index 94563a6..ad7ad74 100644 --- a/src/main/java/com/example/copykamanotes/service/impl/NoteServiceImpl.java +++ b/src/main/java/com/example/copykamanotes/service/impl/NoteServiceImpl.java @@ -17,10 +17,8 @@ import com.example.copykamanotes.service.*; import com.example.copykamanotes.utils.ApiResponseUtils; import com.example.copykamanotes.utils.MarkdownUtils; import com.example.copykamanotes.utils.PaginationUtils; -import com.google.protobuf.Api; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.relational.core.sql.In; import org.springframework.stereotype.Service; import java.util.*;