diff --git a/src/main/java/com/moabam/api/application/room/RoomService.java b/src/main/java/com/moabam/api/application/room/RoomService.java index 5ad81780..1f2ccdce 100644 --- a/src/main/java/com/moabam/api/application/room/RoomService.java +++ b/src/main/java/com/moabam/api/application/room/RoomService.java @@ -90,7 +90,7 @@ public void modifyRoom(Long memberId, Long roomId, ModifyRoomRequest modifyRoomR @Transactional public void enterRoom(Long memberId, Long roomId, EnterRoomRequest enterRoomRequest) { - Room room = roomRepository.findWithPessimisticLockById(roomId).orElseThrow( + Room room = roomRepository.findWithPessimisticLockByIdAndDeletedAtIsNull(roomId).orElseThrow( () -> new NotFoundException(ROOM_NOT_FOUND)); validateRoomEnter(memberId, enterRoomRequest.password(), room); diff --git a/src/main/java/com/moabam/api/application/room/mapper/RoomMapper.java b/src/main/java/com/moabam/api/application/room/mapper/RoomMapper.java index aee5dd5d..143fac74 100644 --- a/src/main/java/com/moabam/api/application/room/mapper/RoomMapper.java +++ b/src/main/java/com/moabam/api/application/room/mapper/RoomMapper.java @@ -9,6 +9,7 @@ import com.moabam.api.domain.member.Member; import com.moabam.api.domain.room.Participant; import com.moabam.api.domain.room.Room; +import com.moabam.api.domain.room.RoomExp; import com.moabam.api.dto.room.CreateRoomRequest; import com.moabam.api.dto.room.GetAllRoomResponse; import com.moabam.api.dto.room.GetAllRoomsResponse; @@ -51,7 +52,8 @@ public static RoomDetailsResponse toRoomDetailsResponse(Long memberId, Room room .managerNickName(managerNickname) .roomImage(room.getRoomImage()) .level(room.getLevel()) - .exp(room.getExp()) + .currentExp(room.getExp()) + .totalExp(RoomExp.of(room.getLevel()).getTotalExp()) .roomType(room.getRoomType()) .certifyTime(room.getCertifyTime()) .currentUserCount(room.getCurrentUserCount()) @@ -149,7 +151,8 @@ public static UnJoinedRoomDetailsResponse toUnJoinedRoomDetails(Room room, List< .title(room.getTitle()) .roomImage(room.getRoomImage()) .level(room.getLevel()) - .exp(room.getExp()) + .currentExp(room.getExp()) + .totalExp(RoomExp.of(room.getLevel()).getTotalExp()) .roomType(room.getRoomType()) .certifyTime(room.getCertifyTime()) .currentUserCount(room.getCurrentUserCount()) diff --git a/src/main/java/com/moabam/api/domain/room/repository/RoomRepository.java b/src/main/java/com/moabam/api/domain/room/repository/RoomRepository.java index b086872f..6994356c 100644 --- a/src/main/java/com/moabam/api/domain/room/repository/RoomRepository.java +++ b/src/main/java/com/moabam/api/domain/room/repository/RoomRepository.java @@ -15,12 +15,13 @@ public interface RoomRepository extends JpaRepository { @Lock(LockModeType.PESSIMISTIC_WRITE) - Optional findWithPessimisticLockById(Long id); + Optional findWithPessimisticLockByIdAndDeletedAtIsNull(Long id); @Query(value = "select distinct rm.* from room rm left join routine rt on rm.id = rt.room_id " - + "where rm.title like %:keyword% " + + "where (rm.title like %:keyword% " + "or rm.manager_nickname like %:keyword% " - + "or rt.content like %:keyword% " + + "or rt.content like %:keyword%) " + + "and rm.deleted_at is null " + "order by rm.id desc limit 11", nativeQuery = true) List searchByKeyword(@Param(value = "keyword") String keyword); @@ -29,6 +30,7 @@ public interface RoomRepository extends JpaRepository { + "or rm.manager_nickname like %:keyword% " + "or rt.content like %:keyword%) " + "and rm.room_type = :roomType " + + "and rm.deleted_at is null " + "order by rm.id desc limit 11", nativeQuery = true) List searchByKeywordAndRoomType(@Param(value = "keyword") String keyword, @Param(value = "roomType") String roomType); @@ -38,6 +40,7 @@ List searchByKeywordAndRoomType(@Param(value = "keyword") String keyword, + "or rm.manager_nickname like %:keyword% " + "or rt.content like %:keyword%) " + "and rm.id < :roomId " + + "and rm.deleted_at is null " + "order by rm.id desc limit 11", nativeQuery = true) List searchByKeywordAndRoomId(@Param(value = "keyword") String keyword, @Param(value = "roomId") Long roomId); @@ -47,6 +50,7 @@ List searchByKeywordAndRoomType(@Param(value = "keyword") String keyword, + "or rt.content like %:keyword%) " + "and rm.room_type = :roomType " + "and rm.id < :roomId " + + "and rm.deleted_at is null " + "order by rm.id desc limit 11", nativeQuery = true) List searchByKeywordAndRoomIdAndRoomType(@Param(value = "keyword") String keyword, @Param(value = "roomType") String roomType, @Param(value = "roomId") Long roomId); diff --git a/src/main/java/com/moabam/api/dto/room/RoomDetailsResponse.java b/src/main/java/com/moabam/api/dto/room/RoomDetailsResponse.java index cd019558..466ceee6 100644 --- a/src/main/java/com/moabam/api/dto/room/RoomDetailsResponse.java +++ b/src/main/java/com/moabam/api/dto/room/RoomDetailsResponse.java @@ -17,7 +17,8 @@ public record RoomDetailsResponse( String managerNickName, String roomImage, int level, - int exp, + int currentExp, + int totalExp, RoomType roomType, int certifyTime, int currentUserCount, diff --git a/src/main/java/com/moabam/api/dto/room/UnJoinedRoomDetailsResponse.java b/src/main/java/com/moabam/api/dto/room/UnJoinedRoomDetailsResponse.java index d521ea30..3152a163 100644 --- a/src/main/java/com/moabam/api/dto/room/UnJoinedRoomDetailsResponse.java +++ b/src/main/java/com/moabam/api/dto/room/UnJoinedRoomDetailsResponse.java @@ -13,7 +13,8 @@ public record UnJoinedRoomDetailsResponse( String title, String roomImage, int level, - int exp, + int currentExp, + int totalExp, RoomType roomType, int certifyTime, int currentUserCount, diff --git a/src/test/java/com/moabam/support/common/TestClockHolder.java b/src/test/java/com/moabam/support/common/TestClockHolder.java index 48fafe3b..aa75977d 100644 --- a/src/test/java/com/moabam/support/common/TestClockHolder.java +++ b/src/test/java/com/moabam/support/common/TestClockHolder.java @@ -19,6 +19,6 @@ public LocalDateTime times() { @Override public LocalDate date() { - return times().toLocalDate(); + return LocalDateTime.now().toLocalDate(); } }