feat: 处理添加评论偶现失败的问题

This commit is contained in:
tim
2025-08-03 20:10:14 +08:00
parent 3a0cea8cd4
commit d70433ff93

View File

@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@@ -35,6 +36,7 @@ public class CommentService {
private final NotificationRepository notificationRepository;
private final ImageUploader imageUploader;
@Transactional
public Comment addComment(String username, Long postId, String content) {
long recent = commentRepository.countByAuthorAfter(username,
java.time.LocalDateTime.now().minusMinutes(1));