diff --git a/Network-Office/src/main/java/dev/office/networkoffice/gathering/controller/dto/request/GatheringDto.java b/Network-Office/src/main/java/dev/office/networkoffice/gathering/controller/dto/request/GatheringDto.java index a3d0eff..c8a570b 100644 --- a/Network-Office/src/main/java/dev/office/networkoffice/gathering/controller/dto/request/GatheringDto.java +++ b/Network-Office/src/main/java/dev/office/networkoffice/gathering/controller/dto/request/GatheringDto.java @@ -1,6 +1,5 @@ package dev.office.networkoffice.gathering.controller.dto.request; -import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; diff --git a/Network-Office/src/main/java/dev/office/networkoffice/gathering/entity/Gathering.java b/Network-Office/src/main/java/dev/office/networkoffice/gathering/entity/Gathering.java index 1bda848..d06aa18 100644 --- a/Network-Office/src/main/java/dev/office/networkoffice/gathering/entity/Gathering.java +++ b/Network-Office/src/main/java/dev/office/networkoffice/gathering/entity/Gathering.java @@ -105,6 +105,10 @@ public List getConfiremedUserList() { .toList(); } + public int getPresentGatheringMemberCount(){ + return getConfiremedUserList().size(); + } + private boolean isConfirmedUser(GatheringUser gatheringUser) { return gatheringUser.getGatheringUserStatus() .equals(GatheringUserStatus.CONFIRMED_USER); diff --git a/Network-Office/src/main/java/dev/office/networkoffice/gathering/service/GatheringService.java b/Network-Office/src/main/java/dev/office/networkoffice/gathering/service/GatheringService.java index 2d6ad83..932bf9f 100644 --- a/Network-Office/src/main/java/dev/office/networkoffice/gathering/service/GatheringService.java +++ b/Network-Office/src/main/java/dev/office/networkoffice/gathering/service/GatheringService.java @@ -10,7 +10,6 @@ import dev.office.networkoffice.gatheringUser.domain.GatheringUser; import dev.office.networkoffice.gatheringUser.domain.GatheringUserStatus; import dev.office.networkoffice.gatheringUser.repository.GatheringUserRepository; -import dev.office.networkoffice.gatheringUser.service.GatheringUserService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -38,7 +37,7 @@ public GatheringResponseDto createGathering(Long userId, GatheringDto dto) { User host = findUserById(userId); Gathering gathering = createGatheringByRequest(dto, host); Gathering savedGathering = gatheringRepository.save(gathering); - GatheringUser gatheringUser= gatheringUserRepository.save( + GatheringUser gatheringUser = gatheringUserRepository.save( savedGathering.createGatheringUserByHost() ); gatheringUser.updateApplicantStatus(GatheringUserStatus.CONFIRMED_USER, "호스트입니다."); diff --git a/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/domain/GatheringUser.java b/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/domain/GatheringUser.java index 4af977e..eeca1b1 100644 --- a/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/domain/GatheringUser.java +++ b/Network-Office/src/main/java/dev/office/networkoffice/gatheringUser/domain/GatheringUser.java @@ -78,6 +78,7 @@ private void deportApplicants(String reason) { } private void confirmApplicants() { + checkMaxMembers(); this.gatheringUserStatus = GatheringUserStatus.CONFIRMED_USER; } @@ -90,4 +91,8 @@ public boolean isEligibleForReapplication() { GatheringUserStatus status = gatheringUserStatus; return !(status == GatheringUserStatus.DEPORTATION_USER || status == GatheringUserStatus.BLOCKED_USER); } + + private void checkMaxMembers() { + Assert.isTrue(gathering.getPresentGatheringMemberCount() + 1 <= gathering.getMaxMembers(), "모임 최대 인원을 초과했습니다."); + } }