-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…d/GAJI-139 ♻️ [refactor] 스터디룸 게시글(트러블슈팅 게시글, 게시글, 정보나눔 게시글) pathvriable 을 roomId 형태로 변경
- Loading branch information
Showing
21 changed files
with
199 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 25 additions & 7 deletions
32
src/main/java/gaji/service/domain/room/repository/RoomNoticeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
package gaji.service.domain.room.repository; | ||
|
||
import gaji.service.domain.room.entity.RoomNotice; | ||
import gaji.service.domain.room.web.dto.RoomResponseDto; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Modifying; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface RoomNoticeRepository extends JpaRepository<RoomNotice, Long> { | ||
@Modifying | ||
@Query("UPDATE RoomNotice rn SET rn.confirmCount = rn.confirmCount + 1 WHERE rn.id = :noticeId") | ||
void incrementConfirmCount(Long noticeId); | ||
@Query("SELECT NEW gaji.service.domain.room.web.dto.RoomResponseDto$NoticeDto(" + | ||
"rn.id, sm.user.name, rn.title, rn.body, CAST(COUNT(nc) AS Long), rn.createdAt, rn.viewCount) " + | ||
"FROM RoomNotice rn " + | ||
"JOIN rn.studyMate sm " + | ||
"LEFT JOIN NoticeConfirmation nc ON nc.roomNotice.id = rn.id " + | ||
"WHERE sm.room.id = :roomId AND rn.createdAt <= :lastCreatedAt " + | ||
"GROUP BY rn.id, sm.user.name, rn.title, rn.body, rn.createdAt, rn.viewCount " + | ||
"ORDER BY rn.createdAt DESC, rn.id DESC") | ||
List<RoomResponseDto.NoticeDto> findNoticeSummariesForInfiniteScroll( | ||
@Param("roomId") Long roomId, | ||
@Param("lastCreatedAt") LocalDateTime lastCreatedAt, | ||
Pageable pageable); | ||
|
||
@Modifying | ||
@Query("UPDATE RoomNotice rn SET rn.confirmCount = rn.confirmCount - 1 WHERE rn.id = :noticeId AND rn.confirmCount > 0") | ||
void decrementConfirmCount(Long noticeId); | ||
@Query("SELECT CASE " + | ||
"WHEN EXISTS (SELECT 1 FROM RoomNotice rn WHERE rn.studyMate.room.id = :roomId AND rn.id = :noticeId) " + | ||
"THEN (SELECT rn.createdAt FROM RoomNotice rn WHERE rn.studyMate.room.id = :roomId AND rn.id = :noticeId) " + | ||
"ELSE (SELECT MAX(rn.createdAt) FROM RoomNotice rn WHERE rn.studyMate.room.id = :roomId) " + | ||
"END") | ||
Optional<LocalDateTime> findCreatedAtByIdOrEarliest(@Param("roomId") Long roomId, @Param("noticeId") Long noticeId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.