diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/category/controller/response/CategoryListResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/category/controller/response/CategoryListResDto.java index 1b1239fd9..daede31fd 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/category/controller/response/CategoryListResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/category/controller/response/CategoryListResDto.java @@ -5,8 +5,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class CategoryListResDto { private List categoryList; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/CommentResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/CommentResDto.java index abc61fab6..97988cc71 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/CommentResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/CommentResDto.java @@ -6,8 +6,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@NoArgsConstructor @Getter +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class CommentResDto { private Long commentId; private String nickname; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/LeaveRoomResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/LeaveRoomResDto.java index a1306dafa..a53ff0abb 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/LeaveRoomResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/LeaveRoomResDto.java @@ -3,8 +3,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class LeaveRoomResDto { private String nickname; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomCreateResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomCreateResDto.java index 21b831d11..696353964 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomCreateResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomCreateResDto.java @@ -3,8 +3,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class RoomCreateResDto { private Long roomId; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomDetailResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomDetailResDto.java index c9821521f..6afba6241 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomDetailResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomDetailResDto.java @@ -8,8 +8,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class RoomDetailResDto { private Long roomId; private String title; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomJoinResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomJoinResDto.java index f99a9dc12..478b7ab13 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomJoinResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomJoinResDto.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; @Getter -@NoArgsConstructor +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class RoomJoinResDto { private Long roomId; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomListResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomListResDto.java index 56b08368d..19e0e081a 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomListResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomListResDto.java @@ -5,8 +5,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class RoomListResDto { private List roomList; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomResDto.java index 84a325370..29fb4a92a 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomResDto.java @@ -7,7 +7,7 @@ import lombok.NoArgsConstructor; @Getter -@NoArgsConstructor +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class RoomResDto { private Long roomId; private String categoryName; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomStartResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomStartResDto.java index 317583279..7a557d927 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomStartResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/RoomStartResDto.java @@ -4,7 +4,7 @@ import lombok.NoArgsConstructor; @Getter -@NoArgsConstructor +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class RoomStartResDto { private Long roomId; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/UserRoomResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/UserRoomResDto.java index af934f7fd..90c042390 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/UserRoomResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/controller/response/UserRoomResDto.java @@ -4,8 +4,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class UserRoomResDto { private Long roomUserId; private String nickname; diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/service/RoomFindService.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/service/RoomFindService.java index aa32d872a..b9020b0a7 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/service/RoomFindService.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/service/RoomFindService.java @@ -1,16 +1,14 @@ package gg.party.api.user.room.service; -import java.util.Collections; +import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.transaction.Transactional; - -import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import gg.data.party.Room; import gg.data.party.UserRoom; @@ -38,18 +36,28 @@ public class RoomFindService { * 시작하지 않은 방과 시작한 방을 모두 조회한다 * @return 시작하지 않은 방 (최신순) + 시작한 방(끝나는 시간이 빠른 순) 전체 List */ - @Transactional + @Transactional(readOnly = true) public RoomListResDto findRoomList() { - Sort sortForNotStarted = Sort.by("createdAt").descending(); - Sort sortForStarted = Sort.by("startDate").descending(); + List statuses = Arrays.asList(RoomType.OPEN, RoomType.START, RoomType.FINISH); + List rooms = roomRepository.findByStatusIn(statuses); - List notStartedRooms = roomRepository.findByStatus(RoomType.OPEN, sortForNotStarted); - List startedRooms = roomRepository.findByStatus(RoomType.START, sortForStarted); - List finishRooms = roomRepository.findByStatus(RoomType.FINISH, sortForStarted); + List openRooms = rooms.stream() + .filter(room -> room.getStatus() == RoomType.OPEN) + .sorted(Comparator.comparing(Room::getCreatedAt).reversed()) + .collect(Collectors.toList()); - List limitedFinishRooms = finishRooms.stream().limit(10).collect(Collectors.toList()); + List startRooms = rooms.stream() + .filter(room -> room.getStatus() == RoomType.START) + .sorted(Comparator.comparing(Room::getStartDate).reversed()) + .collect(Collectors.toList()); + + List finishRooms = rooms.stream() + .filter(room -> room.getStatus() == RoomType.FINISH) + .sorted(Comparator.comparing(Room::getStartDate).reversed()) + .limit(10) + .collect(Collectors.toList()); - List combinedRooms = Stream.of(notStartedRooms, startedRooms, limitedFinishRooms) + List combinedRooms = Stream.of(openRooms, startRooms, finishRooms) .flatMap(List::stream) .collect(Collectors.toList()); @@ -62,25 +70,30 @@ public RoomListResDto findRoomList() { /** * 현재 참여중인 방을 모두 조회한다(만든 방 포함) + * 시작한 방 뒤에 시작하지 않은 방이 오게 작성 * @param userId 자신의 id * @return 참여한 방 전체 List */ - @Transactional + @Transactional(readOnly = true) public RoomListResDto findJoinedRoomList(Long userId) { List userRooms = userRoomRepository.findByUserId(userId); List joinedRooms = userRooms.stream() .map(UserRoom::getRoom) .collect(Collectors.toList()); - Collections.sort(joinedRooms, Comparator.comparing(Room::getDueDate)); + List openRoom = joinedRooms.stream() + .filter(room -> room.getStatus() == RoomType.OPEN) + .sorted(Comparator.comparing(Room::getDueDate)) + .collect(Collectors.toList()); - List playingRoom = joinedRooms.stream() - .filter(room -> room.getStatus() == RoomType.OPEN || room.getStatus() == RoomType.START) + List startRoom = joinedRooms.stream() + .filter(room -> room.getStatus() == RoomType.START) + .sorted(Comparator.comparing(Room::getStartDate)) .collect(Collectors.toList()); - Collections.sort(playingRoom, Comparator.comparing(Room::getDueDate)); + startRoom.addAll(openRoom); - List roomListResDto = playingRoom.stream() + List roomListResDto = openRoom.stream() .map(RoomResDto::new) .collect(Collectors.toList()); @@ -88,17 +101,17 @@ public RoomListResDto findJoinedRoomList(Long userId) { } /** - * 시간이 지나 보이지 않게 된 내가 플레이한(시작한) 방을 모두 조회한다 + * 시간이 지나 보이지 않게 된 내가 플레이한(FINISH) 방을 모두 조회한다 * @param userId 자신의 id - * user_room db에서 자신의 id와 isExist이 true(나가지 않았음) - * 이면서 status가 FINISH인 경우를 마감기한 최신순으로 정렬 - * @return 끝난 방 전체 List + * isExist이 true(나가지 않았음)이면서 status가 FINISH인 경우 + * @return 시작시간으로 정렬된 끝난 방 전체 List */ - @Transactional + @Transactional(readOnly = true) public RoomListResDto findMyHistoryRoomList(Long userId) { - List finishRooms = userRoomRepository.findFinishRoomsByUserId(userId, RoomType.FINISH); + List finishRooms = userRoomRepository.findByUserIdAndStatusAndIsExistTrue(userId, RoomType.FINISH); List roomListResDto = finishRooms.stream() + .sorted(Comparator.comparing(Room::getStartDate)) .map(RoomResDto::new) .collect(Collectors.toList()); @@ -110,11 +123,11 @@ public RoomListResDto findMyHistoryRoomList(Long userId) { * @param userId 자신의 id * @param roomId 방 id * @return 방 상세정보 dto - * @throws RoomNotFoundException 유효하지 않은 방 입력 - * @throws RoomReportedException 신고 받은 방 처리 | 시작한 방도 볼 수 있게 해야하므로 별도처리 + * @throws RoomNotFoundException 유효하지 않은 방 입력 - 404 + * @throws RoomReportedException 신고 받은 방 처리 - 403 * 익명성을 지키기 위해 nickname을 리턴 */ - @Transactional + @Transactional(readOnly = true) public RoomDetailResDto findRoomDetail(Long userId, Long roomId) { Room room = roomRepository.findById(roomId).orElseThrow(RoomNotFoundException::new); if (room.getStatus() == RoomType.HIDDEN) { @@ -125,37 +138,37 @@ public RoomDetailResDto findRoomDetail(Long userId, Long roomId) { String myNickname = null; if (userRoomOptional.isPresent()) { - UserRoom userRoom = userRoomOptional.get(); - myNickname = userRoom.getNickname(); + myNickname = userRoomOptional.get().getNickname(); } - Optional hostUserRoomOptional = userRoomRepository.findByUserIdAndRoomIdAndIsExistTrue( - room.getHost().getId(), roomId); - String hostNickname = hostUserRoomOptional.get().getNickname(); + Optional hostUserRoom = userRoomRepository.findByUserIdAndRoomIdAndIsExistTrue(room.getHost().getId(), + roomId); + String hostNickname = hostUserRoom.get().getNickname(); if ((room.getStatus() == RoomType.START || room.getStatus() == RoomType.FINISH) && userRoomOptional.isPresent()) { + List roomUsers = userRoomRepository.findByRoomIdAndIsExistTrue(roomId).stream() + .map(userRoom -> new UserRoomResDto(userRoom, userRoom.getUser().getIntraId(), + userRoom.getUser().getImageUri())) + .collect(Collectors.toList()); + List comments = commentRepository.findAllWithCommentFetchJoin(roomId).stream() + .filter(comment -> !comment.isHidden()) .map(comment -> new CommentResDto(comment, comment.getUser().getIntraId())) .collect(Collectors.toList()); - List roomUsers = userRoomRepository.findByRoomId(roomId).stream() - .filter(UserRoom::getIsExist) - .map(userRoom -> new UserRoomResDto(userRoom, userRoom.getUser().getIntraId(), - userRoom.getUser().getImageUri())) - .collect(Collectors.toList()); return new RoomDetailResDto(room, myNickname, hostNickname, roomUsers, comments); - } else { // if 참여자 && Start or Finish 상태인 경우 intraID || else intraId == null + } else { // if 참여자 && Start or Finish 상태인 경우 intraID 제공 || else intraId == null + List roomUsers = userRoomRepository.findByRoomIdAndIsExistTrue(roomId).stream() + .map(UserRoomResDto::new) + .collect(Collectors.toList()); + List comments = commentRepository.findAllWithCommentFetchJoin(roomId).stream() + .filter(comment -> !comment.isHidden()) .map(CommentResDto::new) .collect(Collectors.toList()); - List roomUsers = userRoomRepository.findByRoomId(roomId).stream() - .filter(UserRoom::getIsExist) - .map(UserRoomResDto::new) - .collect(Collectors.toList()); return new RoomDetailResDto(room, myNickname, hostNickname, roomUsers, comments); } } - } diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/service/RoomManagementService.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/service/RoomManagementService.java index 18b37cd47..cee1d1b5a 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/service/RoomManagementService.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/service/RoomManagementService.java @@ -102,16 +102,6 @@ public LeaveRoomResDto modifyLeaveRoom(Long roomId, UserDto user) { UserRoom targetUserRoom = userRoomRepository.findByUserAndRoom(userRepository.findById(user.getId()).get(), targetRoom).orElseThrow(RoomNotParticipantException::new); - // 모두 나갈 때 방 fail처리 - if (targetRoom.getCurrentPeople() == 1) { - targetRoom.updateCurrentPeople(0); - targetRoom.updateRoomStatus(RoomType.FAIL); - targetUserRoom.updateIsExist(false); - roomRepository.save(targetRoom); - userRoomRepository.save(targetUserRoom); - return new LeaveRoomResDto(targetUserRoom.getNickname()); - } - targetRoom.updateCurrentPeople(targetRoom.getCurrentPeople() - 1); targetUserRoom.updateIsExist(false); @@ -124,8 +114,17 @@ public LeaveRoomResDto modifyLeaveRoom(Long roomId, UserDto user) { targetRoom.updateHost(null); } } - userRoomRepository.save(targetUserRoom); + + // 모두 나갈 때 방 fail처리 + if (targetRoom.getCurrentPeople() == 0) { + targetRoom.updateRoomStatus(RoomType.FAIL); + roomRepository.save(targetRoom); + userRoomRepository.save(targetUserRoom); + return new LeaveRoomResDto(targetUserRoom.getNickname()); + } + roomRepository.save(targetRoom); + userRoomRepository.save(targetUserRoom); return new LeaveRoomResDto(targetUserRoom.getNickname()); } @@ -136,27 +135,27 @@ public LeaveRoomResDto modifyLeaveRoom(Long roomId, UserDto user) { * @param roomId, user * @return 방 id * @throws RoomNotFoundException 방 없음 - 404 - * @throws RoomNotOpenException 방이 열리지 않은 상태 - 400 - * @throws RoomNotEnoughPeopleException 방에 충분한 인원이 없음 - 400 * @throws RoomNotParticipantException 방에 참가하지 않은 유저 - 400 * @throws UserNotHostException 방장이 아닌 경우 - 403 + * @throws RoomNotOpenException 방이 열리지 않은 상태 - 400 + * @throws RoomNotEnoughPeopleException 방에 충분한 인원이 없음 - 400 */ @Transactional public RoomStartResDto modifyStartRoom(Long roomId, UserDto user) { Room targetRoom = roomRepository.findById(roomId) .orElseThrow(RoomNotFoundException::new); - if (!targetRoom.getStatus().equals(RoomType.OPEN)) { - throw new RoomNotOpenException(); - } - if (targetRoom.getMinPeople() > targetRoom.getCurrentPeople() - || targetRoom.getMaxPeople() < targetRoom.getCurrentPeople()) { - throw new RoomNotEnoughPeopleException(); - } UserRoom targetUserRoom = userRoomRepository.findByUserAndRoom(userRepository.findById(user.getId()).get(), targetRoom).orElseThrow(RoomNotParticipantException::new); if (targetRoom.getHost() != targetUserRoom.getUser()) { throw new UserNotHostException(); } + if (!targetRoom.getStatus().equals(RoomType.OPEN)) { + throw new RoomNotOpenException(); + } + if (targetRoom.getMinPeople() > targetRoom.getCurrentPeople()) { + throw new RoomNotEnoughPeopleException(); + } + targetRoom.updateRoomStatus(RoomType.START); List users = userRoomRepository.findByIsExist(roomId); targetRoom.startRoom(LocalDateTime.now()); diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/room/utils/GenerateRandomNickname.java b/gg-pingpong-api/src/main/java/gg/party/api/user/room/utils/GenerateRandomNickname.java index ab5b86b30..42683fd52 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/room/utils/GenerateRandomNickname.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/room/utils/GenerateRandomNickname.java @@ -2,18 +2,22 @@ import java.util.Random; +/* + * 익명 닉네임을 만드는 클래스입니다. + * PREFIX와 SUFFIX 배열에서 랜덤으로 단어를 선택하여 조합합니다. + * 둘 중 중복되는 요소도 가능하게 작성했습니다. ex) 용감한 int, 용감한 string이 공존할 수 있습니다. + * 최대 4글자 || 7글자로 작성했습니다. + */ public class GenerateRandomNickname { - private String nickname; - - private static final String[] PREFIX = {"용감한", "대담한", "밝은", "뛰어난", "쾌활한", "영리한", "도망가는", + private static final String[] PREFIX = {"용감한", "대담한", "밝은", "뛰어난", "쾌활한", "영리한", "도망가는", "든든한", "대담한", "열심인", "힘찬", "불같은", "신선한", "관대한", "유쾌한", "행복한", "희망찬", "명랑한", "친절한", "활기찬", - "착한", "이상한", "자랑스러운", "빠른", "안도하는", "수줍은", "어리석은", "강한", "감사하는", "힘든", "용감한", "열정적인", + "착한", "이상한", "빠른", "안도하는", "수줍은", "어리석은", "강한", "감사하는", "힘든", "용감한", "열정적인", "졸린", "똑똑한", "즐거운", "굉장한", "고수", "엄청난", "뜬금없는", "충무공", "제너럴", "엠페러", "마제스티", "판타스틱", "레전더리", - "먼치킨", "다크호스", "슈퍼루키", "엘리트", "정점", "전교회장", "베테랑"}; + "먼치킨", "다크호스", "슈퍼루키", "엘리트", "정점", "전교회장", "베테랑", "킹", "퀸", "챔피언"}; - private static final String[] SUFFIX = {"list", "vector", "string", "boolean", "number", "object", "array", - "set", "map", "date", "function", "null", "undefined", "buffer", "json", "error", "stack", "queue", "deque", - "tree", "graph", "pair", "int", "char", "float", "double", "long", "longlong", "size_t", "short", "struct"}; + private static final String[] SUFFIX = {"list", "vector", "string", "bool", "number", "object", "array", + "set", "map", "date", "null", "buffer", "json", "error", "stack", "queue", "deque", "struct", "tree", + "graph", "pair", "int", "char", "float", "double", "long", "size_t", "short", "byte", "bit", "pointer"}; public static String generateRandomNickname() { Random random = new Random(); diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/template/controller/TemplateController.java b/gg-pingpong-api/src/main/java/gg/party/api/user/template/controller/TemplateController.java index cb3db5719..37b5d237d 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/template/controller/TemplateController.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/template/controller/TemplateController.java @@ -17,8 +17,8 @@ public class TemplateController { private final TemplateService templateService; /** - * 탬플릿 목록을 조회한다 - * @return 탬플릿 전체 List + * 템플릿 전체 조회 + * @return 템플릿 전체 리스트 (가나다 순으로 정렬) 200 */ @GetMapping public ResponseEntity templateList() { diff --git a/gg-pingpong-api/src/main/java/gg/party/api/user/template/controller/response/TemplateListResDto.java b/gg-pingpong-api/src/main/java/gg/party/api/user/template/controller/response/TemplateListResDto.java index 5a8ac4c23..f593b6e24 100644 --- a/gg-pingpong-api/src/main/java/gg/party/api/user/template/controller/response/TemplateListResDto.java +++ b/gg-pingpong-api/src/main/java/gg/party/api/user/template/controller/response/TemplateListResDto.java @@ -5,8 +5,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) @Getter +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) public class TemplateListResDto { private List templateList; diff --git a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackPartybotService.java b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackPartybotService.java index d3c5f91f9..fe401b27e 100644 --- a/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackPartybotService.java +++ b/gg-pingpong-api/src/main/java/gg/pingpong/api/user/noti/service/sns/SlackPartybotService.java @@ -40,10 +40,9 @@ private String getSlackUserId(String intraId) { MultiValueMap parameters = new LinkedMultiValueMap<>(); parameters.add("email", userEmail); - SlackPartybotService.SlackUserInfoResponse res = apiUtil.apiCall(userIdGetUrl, - SlackPartybotService.SlackUserInfoResponse.class, + SlackPartybotService.SlackUserInfoRes res = apiUtil.apiCall(userIdGetUrl, SlackUserInfoRes.class, headers, parameters, HttpMethod.POST); - return res.user.getId(); + return res.user.id; } private String createGroupChannelId(List slackUserIds) { @@ -54,10 +53,10 @@ private String createGroupChannelId(List slackUserIds) { Map bodyMap = new HashMap<>(); bodyMap.put("users", String.join(",", slackUserIds)); - SlackPartybotService.ConversationResponse res = apiUtil.apiCall(conversationsUrl, - SlackPartybotService.ConversationResponse.class, httpHeaders, bodyMap, HttpMethod.POST); + ConversationRes res = apiUtil.apiCall(conversationsUrl, ConversationRes.class, + httpHeaders, bodyMap, HttpMethod.POST); - return res.channel.getId(); + return res.channel.id; } @Async("asyncExecutor") @@ -86,9 +85,9 @@ private void sendGroupMessage(String channelId, String message) { } @Getter - static class ConversationResponse { + static class ConversationRes { private Boolean ok; - private SlackbotService.ConversationResponse.Channel channel; + private Channel channel; @Getter static class Channel { @@ -97,9 +96,9 @@ static class Channel { } @Getter - static class SlackUserInfoResponse { + static class SlackUserInfoRes { private Boolean ok; - private SlackbotService.SlackUserInfoResponse.SlackUser user; + private SlackUser user; @Getter static class SlackUser { diff --git a/gg-repo/src/main/java/gg/repo/party/RoomRepository.java b/gg-repo/src/main/java/gg/repo/party/RoomRepository.java index bf043d18c..12e30523b 100644 --- a/gg-repo/src/main/java/gg/repo/party/RoomRepository.java +++ b/gg-repo/src/main/java/gg/repo/party/RoomRepository.java @@ -16,6 +16,9 @@ public interface RoomRepository extends JpaRepository { List findByStatus(RoomType status, Sort sort); + @Query("SELECT r FROM Room r WHERE r.status IN :statuses") + List findByStatusIn(@Param("statuses") List statuses); + Long findById(Long id, Sort sort); Page findAll(Pageable pageable); diff --git a/gg-repo/src/main/java/gg/repo/party/UserRoomRepository.java b/gg-repo/src/main/java/gg/repo/party/UserRoomRepository.java index 555974bd4..8425c4cb5 100644 --- a/gg-repo/src/main/java/gg/repo/party/UserRoomRepository.java +++ b/gg-repo/src/main/java/gg/repo/party/UserRoomRepository.java @@ -17,15 +17,17 @@ public interface UserRoomRepository extends JpaRepository { List findByRoomId(Long roomId); - @Query("SELECT ur.user FROM UserRoom ur WHERE ur.room.id = :roomId AND ur.isExist = true " - + "ORDER BY ur.modifiedAt ASC") + @Query("SELECT ur FROM UserRoom ur WHERE ur.room.id = :roomId AND ur.isExist = true") + List findByRoomIdAndIsExistTrue(@Param("roomId") Long roomId); + + @Query("SELECT ur.user FROM UserRoom ur WHERE ur.room.id = :roomId AND ur.isExist = true") List findByIsExist(@Param("roomId") Long roomId); Optional findByUserAndRoom(User user, Room room); @Query("SELECT ur.room FROM UserRoom ur WHERE ur.user.id = :userId AND ur.isExist = true " - + "AND ur.room.status = :status ORDER BY ur.room.dueDate ASC") - List findFinishRoomsByUserId(@Param("userId") Long userId, @Param("status") RoomType status); + + "AND ur.room.status = :status") + List findByUserIdAndStatusAndIsExistTrue(@Param("userId") Long userId, @Param("status") RoomType status); @Query("SELECT ur.room FROM UserRoom ur WHERE ur.user.id = :userId " + "AND ur.isExist = true AND ur.room.status = 'OPEN'")