From 81ed513cbaa0eebf40d76c9fbe7546221273fdb9 Mon Sep 17 00:00:00 2001 From: soohyun Date: Fri, 6 Dec 2024 17:40:01 +0900 Subject: [PATCH] =?UTF-8?q?[#30]=20refactor:=20=EB=AA=A8=EC=9E=84=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=20=ED=99=95=EC=A0=95=EC=8B=9C=20=EC=B5=9C?= =?UTF-8?q?=EB=8C=80=EC=9D=B8=EC=9B=90=EC=88=98=20=EC=B4=88=EA=B3=BC=20val?= =?UTF-8?q?idation=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gathering/controller/dto/request/GatheringDto.java | 1 - .../dev/office/networkoffice/gathering/entity/Gathering.java | 4 ++++ .../networkoffice/gathering/service/GatheringService.java | 3 +-- .../networkoffice/gatheringUser/domain/GatheringUser.java | 5 +++++ 4 files changed, 10 insertions(+), 3 deletions(-) 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(), "모임 최대 인원을 초과했습니다."); + } }