Skip to content

Commit

Permalink
refactor: Service단 Validate 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-so committed Feb 19, 2024
1 parent 3ea5f39 commit b97e65f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ValidateRoomService {
public void validateUserStatusIsActive(Long userId) {
Optional<User> checkUserStatusIsActive = userRepository.findByIdAndStatus(userId, ACTIVE);

if (!checkUserStatusIsActive.isPresent()) {
if (checkUserStatusIsActive.isEmpty()) {
throw new BussinessException(BAD_REQUEST);
}
}
Expand All @@ -55,15 +55,15 @@ public User validateUserIsExist(Long userId) {
public void validateRoomIsExist(Long roomId) {
Optional<Room> checkRoomIsExist = roomRepository.findById(roomId);

if (!checkRoomIsExist.isPresent()) {
if (checkRoomIsExist.isEmpty()) {
throw new BussinessException(BAD_REQUEST);
}
}

public void validateRoomStatusIsWait(Long roomId) {
Optional<Room> checkRoomStatusIsWait = roomRepository.findByIdAndStatus(roomId, WAIT);

if (!checkRoomStatusIsWait.isPresent()) {
if (checkRoomStatusIsWait.isEmpty()) {
throw new BussinessException(BAD_REQUEST);
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public void validateHostOfRoom(Long roomId, Long userId) {
public void validateUserIsInRoom(Long roomId, Long userId) {
Optional<UserRoom> checkUserParticipate = userRoomRepository.findByRoomId_IdAndUserId_Id(roomId, userId);

if (!checkUserParticipate.isPresent()) {
if (checkUserParticipate.isEmpty()) {
throw new BussinessException(BAD_REQUEST);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public void validateRoomIsExist(Long roomId) {
public void validateRoomStatusIsWait(Long roomId) {
Optional<Room> checkRoomStatusIsWait = roomRepository.findByIdAndStatus(roomId, WAIT);

if (!checkRoomStatusIsWait.isPresent()) {
if (checkRoomStatusIsWait.isEmpty()) {
throw new BussinessException(BAD_REQUEST);
}
}

public void validateUserParticipationInRoom(Long roomId, Long userId) {
Optional<UserRoom> checkUserIsParticipate = userRoomRepository.findByUserId_IdAndRoomId_Id(userId, roomId);

if (!checkUserIsParticipate.isPresent()) {
if (checkUserIsParticipate.isEmpty()) {
throw new BussinessException(BAD_REQUEST);
}
}
Expand Down

0 comments on commit b97e65f

Please sign in to comment.