Skip to content

Commit

Permalink
Merge pull request #53 from goormthon-Univ/feature/52
Browse files Browse the repository at this point in the history
[HOT FIX] getMyReviewList bug fix
  • Loading branch information
chaeeun-Han committed Mar 23, 2024
2 parents 8aa8fce + 85e55b8 commit 629b2af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
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

0 comments on commit 629b2af

Please sign in to comment.