Skip to content

Commit 5007f21

Browse files
committed
[EA3-168] feature: 신청서 조회 시 isRead 변경 로직 추가
1 parent ab2971b commit 5007f21

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/main/java/grep/neogulcoder/domain/studyapplication/repository/ApplicationRepository.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import grep.neogulcoder.domain.studyapplication.StudyApplication;
44
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.data.jpa.repository.Modifying;
6+
import org.springframework.data.jpa.repository.Query;
7+
import org.springframework.data.repository.query.Param;
58

69
import java.util.List;
710
import java.util.Optional;
@@ -12,4 +15,8 @@ public interface ApplicationRepository extends JpaRepository<StudyApplication, L
1215
boolean existsByRecruitmentPostIdAndUserId(Long recruitmentPostId, Long userId);
1316

1417
Optional<StudyApplication> findByIdAndActivatedTrue(Long applicationId);
18+
19+
@Modifying(clearAutomatically = true)
20+
@Query("update StudyApplication sa set sa.isRead = true where sa.recruitmentPostId = :recruitmentPostId and sa.isRead = false")
21+
void markAllAsReadByRecruitmentPostId(@Param("recruitmentPostId") Long recruitmentPostId);
1522
}

src/main/java/grep/neogulcoder/domain/studyapplication/service/ApplicationService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ public class ApplicationService {
4040
private final StudyMemberRepository studyMemberRepository;
4141
private final StudyRepository studyRepository;
4242

43+
@Transactional
4344
public ReceivedApplicationPagingResponse getReceivedApplicationsPaging(Long recruitmentPostId, Pageable pageable, Long userId) {
4445
RecruitmentPost recruitmentPost = findValidRecruitmentPost(recruitmentPostId);
4546

4647
validateOwner(userId, recruitmentPost);
48+
applicationRepository.markAllAsReadByRecruitmentPostId(recruitmentPostId);
4749

4850
Page<ReceivedApplicationResponse> page = applicationQueryRepository.findReceivedApplicationsPaging(recruitmentPostId, pageable);
4951
return ReceivedApplicationPagingResponse.of(page);

0 commit comments

Comments
 (0)