Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOT FIX] getMyReviewList bug fix #53

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

Expand All @@ -17,4 +18,6 @@ public interface QuizRepository extends JpaRepository<Quiz, Long> {
@Query("SELECT q FROM Quiz q WHERE q.tags LIKE %:tagName% ORDER BY q.quizId ASC, RAND() LIMIT 10")
List<Quiz> findByTagName(@Param("tagName") String tagName);

@Transactional
void deleteByPostId(Long postId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

Expand All @@ -29,4 +30,7 @@ public interface ReviewRepository extends JpaRepository<Review, Long> {
@Query("SELECT r FROM Review r " +
"WHERE r.reviewId = :reviewId")
List<Review> findReviewByReviewId(@Param("reviewId") String reviewId);

@Transactional
void deleteByPostId(Long postId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.beotkkot.qtudy.dto.response.posts.*;
import com.beotkkot.qtudy.repository.comments.CommentsRepository;
import com.beotkkot.qtudy.repository.posts.PostsRepository;
import com.beotkkot.qtudy.repository.quiz.QuizRepository;
import com.beotkkot.qtudy.repository.quiz.ReviewRepository;
import com.beotkkot.qtudy.repository.scrap.ScrapRepository;
import com.beotkkot.qtudy.repository.tags.TagsRepository;
import com.beotkkot.qtudy.repository.user.UserRepository;
Expand All @@ -36,6 +38,9 @@ public class PostsService {
private final ScrapRepository scrapRepo;
private final SummaryService summaryService;
private final CommentsRepository commentsRepo;
private final ReviewRepository reviewRepo;
private final QuizRepository quizRepo;


@Transactional
public ResponseEntity<? super PostsResponseDto> savePost(Long kakao_uid, PostsRequestDto dto) {
Expand Down Expand Up @@ -230,6 +235,8 @@ public ResponseEntity<? super PostsResponseDto> deletePost(Long postId, Long kak

scrapRepo.deleteByPostId(postId);
commentsRepo.deleteByPostId(postId);
reviewRepo.deleteByPostId(postId);
quizRepo.deleteByPostId(postId);

// 관련된 hash tag -1
List<String> tagNameList = Arrays.asList(post.getTag().split("\\s*,\\s*"));
Expand Down