Skip to content

Commit

Permalink
fix: 마스터 탈퇴 시 정상적으로 스터디 삭제되게 수정 (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevstevie authored Oct 14, 2023
1 parent 8fd23ac commit 716b01e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void update(Member member, Long studyId, StudyUpdateRequest request) {

@Transactional
public void deleteByMasterId(Long masterId) {
List<Study> studies = studyRepository.findAllByMasterIdAndProcessingStatus(masterId, ProcessingStatus.RECRUITING);
List<Study> studies = studyRepository.findAllByMasterIdAndProcessingStatus(masterId, ProcessingStatus.RECRUITING, Role.MASTER);
studyRepository.deleteAll(studies);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import com.yigongil.backend.domain.member.Member;
import com.yigongil.backend.domain.study.studyquery.StudyQueryRepository;
import com.yigongil.backend.domain.studymember.Role;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
Expand All @@ -19,10 +18,6 @@ public interface StudyRepository extends Repository<Study, Long>, StudyQueryRepo
@EntityGraph(attributePaths = {"rounds"})
Optional<Study> findById(Long studyId);

Page<Study> findAllByProcessingStatus(ProcessingStatus processingStatus, Pageable pageable);

Page<Study> findAllByProcessingStatusAndNameContainingIgnoreCase(ProcessingStatus processingStatus, String word, Pageable pageable);

List<Study> findAllByProcessingStatus(ProcessingStatus processingStatus);

@Query("""
Expand All @@ -37,13 +32,15 @@ public interface StudyRepository extends Repository<Study, Long>, StudyQueryRepo

@Query("""
select distinct s from Study s
join fetch s.rounds r
where r.master.id = :masterId
join StudyMember sm on s = sm.study
where sm.member.id = :masterId
and sm.role = :role
and s.processingStatus = :status
""")
List<Study> findAllByMasterIdAndProcessingStatus(
@Param("masterId") Long masterId,
@Param("status") ProcessingStatus status
@Param("status") ProcessingStatus status,
@Param("role") Role role
);

@Modifying
Expand Down

0 comments on commit 716b01e

Please sign in to comment.