Skip to content

Commit

Permalink
fix: 방의 exp 보내는 방법 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ymkim97 committed Dec 3, 2023
1 parent 1ea152c commit 8b60ff5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
public interface RoomRepository extends JpaRepository<Room, Long> {

@Lock(LockModeType.PESSIMISTIC_WRITE)
Optional<Room> findWithPessimisticLockById(Long id);
Optional<Room> 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<Room> searchByKeyword(@Param(value = "keyword") String keyword);

Expand All @@ -29,6 +30,7 @@ public interface RoomRepository extends JpaRepository<Room, Long> {
+ "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<Room> searchByKeywordAndRoomType(@Param(value = "keyword") String keyword,
@Param(value = "roomType") String roomType);
Expand All @@ -38,6 +40,7 @@ List<Room> 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<Room> searchByKeywordAndRoomId(@Param(value = "keyword") String keyword, @Param(value = "roomId") Long roomId);

Expand All @@ -47,6 +50,7 @@ List<Room> 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<Room> searchByKeywordAndRoomIdAndRoomType(@Param(value = "keyword") String keyword,
@Param(value = "roomType") String roomType, @Param(value = "roomId") Long roomId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public LocalDateTime times() {

@Override
public LocalDate date() {
return times().toLocalDate();
return LocalDateTime.now().toLocalDate();
}
}

0 comments on commit 8b60ff5

Please sign in to comment.