From 7a546f6d8e118aeb350799207bd4fb435fa60c67 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:15:02 +0900 Subject: [PATCH 01/14] =?UTF-8?q?feat=20:=20=EC=B0=B8=EC=84=9D=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EC=A0=80=EC=9E=A5=ED=95=98=EC=A7=80=20?= =?UTF-8?q?=EB=AA=BB=20=ED=95=A0=20=EA=B2=BD=EC=9A=B0=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/DeniedSaveAttendException.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/exception/DeniedSaveAttendException.java diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/exception/DeniedSaveAttendException.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/exception/DeniedSaveAttendException.java new file mode 100644 index 00000000..d245d937 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/exception/DeniedSaveAttendException.java @@ -0,0 +1,18 @@ +package com.blackcompany.eeos.attend.application.exception; + +import com.blackcompany.eeos.common.exception.BusinessException; +import org.springframework.http.HttpStatus; + +/** 해당 프로그램의 참석 대상자가 아닌데 참석 정보를 입력하려고 할 때 발생하는 예외 */ +public class DeniedSaveAttendException extends BusinessException { + private static final String FAIL_CODE = "2005"; + + public DeniedSaveAttendException() { + super(FAIL_CODE, HttpStatus.NOT_FOUND); + } + + @Override + public String getMessage() { + return String.format(" 프로그램의 참석 대상자가 아닙니다."); + } +} From b46b8265d557c6f9a7d4a2023371f9bbebf914a2 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:14:44 +0900 Subject: [PATCH 02/14] =?UTF-8?q?chore=20:=20=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=EB=AA=85=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/CandidateService.java | 4 +-- .../service/SelectCandidateService.java | 28 ++++++++----------- ...java => ChangeAllAttendStatusRequest.java} | 2 +- .../application/dto/UpdateProgramRequest.java | 2 +- .../application/service/ProgramService.java | 4 +-- 5 files changed, 18 insertions(+), 22 deletions(-) rename BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/{ChangeAttendStatusRequest.java => ChangeAllAttendStatusRequest.java} (84%) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/CandidateService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/CandidateService.java index e6de6137..d1347804 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/CandidateService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/CandidateService.java @@ -1,6 +1,6 @@ package com.blackcompany.eeos.attend.application.service; -import com.blackcompany.eeos.program.application.dto.ChangeAttendStatusRequest; +import com.blackcompany.eeos.program.application.dto.ChangeAllAttendStatusRequest; import com.blackcompany.eeos.program.application.dto.ProgramMembers; import java.util.List; @@ -8,5 +8,5 @@ public interface CandidateService { void saveCandidate(final Long programId, final List members); - void updateCandidate(final Long programId, final List requests); + void updateCandidate(final Long programId, final List requests); } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/SelectCandidateService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/SelectCandidateService.java index 815d64bd..ef647fd4 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/SelectCandidateService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/SelectCandidateService.java @@ -9,7 +9,7 @@ import com.blackcompany.eeos.member.application.exception.NotFoundMemberException; import com.blackcompany.eeos.member.persistence.MemberEntity; import com.blackcompany.eeos.member.persistence.MemberRepository; -import com.blackcompany.eeos.program.application.dto.ChangeAttendStatusRequest; +import com.blackcompany.eeos.program.application.dto.ChangeAllAttendStatusRequest; import com.blackcompany.eeos.program.application.dto.ProgramMembers; import com.blackcompany.eeos.program.application.model.AttendManager; import java.util.List; @@ -21,7 +21,6 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -/** 관련있는 대상자를 지정하여 선택한다. */ @Service @RequiredArgsConstructor @Slf4j @@ -44,7 +43,7 @@ public void saveCandidate(final Long programId, final List membe @Override @Transactional(propagation = Propagation.REQUIRED) public void updateCandidate( - final Long programId, final List requests) { + final Long programId, final List requests) { List models = findAttends(programId, requests).stream() .map(entityConverter::from) @@ -67,9 +66,11 @@ private List findMembers(final List members) { } private List findAttends( - final Long programId, final List members) { + final Long programId, final List requests) { List memberIds = - members.stream().map(ChangeAttendStatusRequest::getMemberId).collect(Collectors.toList()); + requests.stream() + .map(ChangeAllAttendStatusRequest::getMemberId) + .collect(Collectors.toList()); List attendMembers = attendRepository.findAllByProgramMember(programId, memberIds); @@ -97,31 +98,26 @@ private List findDifferent( } private void updateAttendStatus( - AttendModel model, List requests, AttendManager attendManager) { - ChangeAttendStatusRequest request = findUpdateRequest(model.getMemberId(), requests); - - validateSameBeforeStatus(model, request); + AttendModel model, List requests, AttendManager attendManager) { + ChangeAllAttendStatusRequest request = findUpdateRequest(model.getMemberId(), requests); + model.changeStatus(request.getBeforeAttendStatus(), request.getAfterAttendStatus()); if (Objects.equals(request.getAfterAttendStatus(), AttendStatus.NONRELATED.getStatus())) { attendManager.addNonRelated(model); return; } - model.changeStatus(request.getAfterAttendStatus()); + attendManager.addRelated(model); } - private ChangeAttendStatusRequest findUpdateRequest( - Long attendId, List requests) { + private ChangeAllAttendStatusRequest findUpdateRequest( + Long attendId, List requests) { return requests.stream() .filter(request -> request.getMemberId().equals(attendId)) .findAny() .orElseThrow(NotFoundMemberException::new); } - private void validateSameBeforeStatus(AttendModel model, ChangeAttendStatusRequest request) { - model.validateSame(request.getBeforeAttendStatus()); - } - private void deleteNonRelated(AttendManager attendManager) { List nonRelated = attendManager.getNonRelated().stream() diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/ChangeAttendStatusRequest.java b/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/ChangeAllAttendStatusRequest.java similarity index 84% rename from BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/ChangeAttendStatusRequest.java rename to BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/ChangeAllAttendStatusRequest.java index ef2f9263..52118469 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/ChangeAttendStatusRequest.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/ChangeAllAttendStatusRequest.java @@ -10,7 +10,7 @@ @AllArgsConstructor @NoArgsConstructor @Builder(toBuilder = true) -public class ChangeAttendStatusRequest implements AbstractRequestDto { +public class ChangeAllAttendStatusRequest implements AbstractRequestDto { private Long memberId; private String beforeAttendStatus; private String afterAttendStatus; diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/UpdateProgramRequest.java b/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/UpdateProgramRequest.java index ca828777..9dd585c3 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/UpdateProgramRequest.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/dto/UpdateProgramRequest.java @@ -20,5 +20,5 @@ public class UpdateProgramRequest implements CommandProgramRequest { private @NotNull String content; private @NotNull String category; private @NotNull String type; - private List members; + private List members; } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/service/ProgramService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/service/ProgramService.java index be932955..27db52a0 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/service/ProgramService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/program/application/service/ProgramService.java @@ -2,7 +2,7 @@ import com.blackcompany.eeos.attend.application.service.CandidateService; import com.blackcompany.eeos.common.utils.DateConverter; -import com.blackcompany.eeos.program.application.dto.ChangeAttendStatusRequest; +import com.blackcompany.eeos.program.application.dto.ChangeAllAttendStatusRequest; import com.blackcompany.eeos.program.application.dto.CommandProgramResponse; import com.blackcompany.eeos.program.application.dto.CreateProgramRequest; import com.blackcompany.eeos.program.application.dto.PageResponse; @@ -133,7 +133,7 @@ private ProgramModel findProgram(final Long programId) { } private void updateAttend( - final List members, + final List members, final ProgramModel model, final Long memberId) { if (members.isEmpty()) { From e98b842db761f31d12735b2b2cd5498c2fb50fae Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:17:53 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat=20:=20=EB=8B=A8=EC=9D=BC=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=EC=B0=B8=EC=84=9D=20=EC=A0=95=EB=B3=B4=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=9A=94=EC=B2=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/ChangeAttendStatusRequest.java | 16 ++++++++++++++++ .../usecase/ChangeAttendStatusUsecase.java | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/ChangeAttendStatusRequest.java diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/ChangeAttendStatusRequest.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/ChangeAttendStatusRequest.java new file mode 100644 index 00000000..dd437fb5 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/ChangeAttendStatusRequest.java @@ -0,0 +1,16 @@ +package com.blackcompany.eeos.attend.application.dto; + +import com.blackcompany.eeos.common.support.dto.AbstractRequestDto; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder(toBuilder = true) +public class ChangeAttendStatusRequest implements AbstractRequestDto { + private String beforeAttendStatus; + private String afterAttendStatus; +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/ChangeAttendStatusUsecase.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/ChangeAttendStatusUsecase.java index 7325b049..1d0bf47e 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/ChangeAttendStatusUsecase.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/ChangeAttendStatusUsecase.java @@ -1,7 +1,8 @@ package com.blackcompany.eeos.attend.application.usecase; -import com.blackcompany.eeos.program.application.dto.ChangeAttendStatusRequest; +import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; public interface ChangeAttendStatusUsecase { - void changeStatus(final ChangeAttendStatusRequest request, final Long programId); + void changeStatus( + final Long memberId, final ChangeAttendStatusRequest request, final Long programId); } From f590e21f2c30891c4d65c064066cb9431fe36846 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:14:01 +0900 Subject: [PATCH 04/14] =?UTF-8?q?feat=20:=20=EC=B0=B8=EC=97=AC=EB=8C=80?= =?UTF-8?q?=EC=83=81=EC=9E=90=EA=B0=80=20=EC=95=84=EB=8B=90=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=B0=B8=EC=84=9D=20=EC=83=81=ED=83=9C=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=ED=95=98=EC=A7=80=20=EB=AA=BB=20?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20validation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attend/application/model/AttendModel.java | 23 +++++++++++--- .../application/model/AttendService.java | 13 ++++---- .../application/model/AttendModelTest.java | 31 ++++++++++--------- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendModel.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendModel.java index 93c8cfb8..7f5c14cc 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendModel.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendModel.java @@ -1,5 +1,6 @@ package com.blackcompany.eeos.attend.application.model; +import com.blackcompany.eeos.attend.application.exception.DeniedSaveAttendException; import com.blackcompany.eeos.attend.application.exception.NotSameBeforeAttendStatusException; import com.blackcompany.eeos.common.support.AbstractModel; import lombok.AllArgsConstructor; @@ -19,14 +20,26 @@ public class AttendModel implements AbstractModel { private Long programId; private AttendStatus status; - public void validateSame(String status) { + public void changeStatus(String beforeStatus, String afterStatus) { + validateChange(beforeStatus); + this.status = AttendStatus.findByAttendStatus(afterStatus); + } + + private void validateChange(String beforeStatus) { + validateCanChange(beforeStatus); + validateSame(beforeStatus); + } + + private void validateCanChange(String beforeStatus) { + if (AttendStatus.isSame(beforeStatus, AttendStatus.NONRELATED)) { + throw new DeniedSaveAttendException(); + } + } + + private void validateSame(String status) { if (AttendStatus.isSame(status, this.status)) { return; } throw new NotSameBeforeAttendStatusException(memberId); } - - public void changeStatus(String status) { - this.status = AttendStatus.findByAttendStatus(status); - } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendService.java index e990a6f0..d37baeee 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendService.java @@ -1,16 +1,15 @@ package com.blackcompany.eeos.attend.application.model; import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; +import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; import com.blackcompany.eeos.attend.application.dto.converter.AttendInfoConverter; import com.blackcompany.eeos.attend.application.exception.NotFoundAttendException; -import com.blackcompany.eeos.attend.application.exception.NotSameBeforeAttendStatusException; import com.blackcompany.eeos.attend.application.model.converter.AttendEntityConverter; import com.blackcompany.eeos.attend.application.usecase.ChangeAttendStatusUsecase; import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; import com.blackcompany.eeos.attend.persistence.AttendEntity; import com.blackcompany.eeos.attend.persistence.AttendRepository; import com.blackcompany.eeos.member.persistence.MemberRepository; -import com.blackcompany.eeos.program.application.dto.ChangeAttendStatusRequest; import com.blackcompany.eeos.program.application.service.ProgramValidService; import java.util.List; import java.util.stream.Collectors; @@ -65,15 +64,15 @@ public List findAttendInfo(final Long programId, final Strin @Transactional @Override - public void changeStatus(final ChangeAttendStatusRequest request, final Long programId) { + public void changeStatus( + final Long memberId, final ChangeAttendStatusRequest request, final Long programId) { AttendModel model = attendRepository - .findByProgramIdAndMemberId(programId, request.getMemberId()) + .findByProgramIdAndMemberId(programId, memberId) .map(attendEntityConverter::from) - .orElseThrow(() -> new NotSameBeforeAttendStatusException(request.getMemberId())); + .orElseThrow(() -> new NotFoundAttendException(programId)); - model.validateSame(request.getBeforeAttendStatus()); - model.changeStatus(request.getAfterAttendStatus()); + model.changeStatus(request.getBeforeAttendStatus(), request.getAfterAttendStatus()); attendRepository.save(attendEntityConverter.toEntity(model)); } diff --git a/BE/eeos/src/test/java/com/blackcompany/eeos/attend/application/model/AttendModelTest.java b/BE/eeos/src/test/java/com/blackcompany/eeos/attend/application/model/AttendModelTest.java index c1076f60..5aad7c7a 100644 --- a/BE/eeos/src/test/java/com/blackcompany/eeos/attend/application/model/AttendModelTest.java +++ b/BE/eeos/src/test/java/com/blackcompany/eeos/attend/application/model/AttendModelTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.*; +import com.blackcompany.eeos.attend.application.exception.DeniedSaveAttendException; import com.blackcompany.eeos.attend.application.exception.NotSameBeforeAttendStatusException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; @@ -10,36 +11,36 @@ class AttendModelTest { @Test - @DisplayName("다른 참석 상태일 때 예외가 발생한다.") - void differentAttendStatus() { + @DisplayName("이전 참석 정보가 변경전 참석정보와 일치하지 않으면 참석 상태를 변경한다.") + void fail_change_status() { // given AttendModel model = AttendModel.builder().status(AttendStatus.NONRESPONSE).build(); // when & then Assertions.assertThrows( - NotSameBeforeAttendStatusException.class, () -> model.validateSame("attend")); + NotSameBeforeAttendStatusException.class, () -> model.changeStatus("late", "attend")); } @Test - @DisplayName("같은 참석 상태일 때 예외가 발생하지 않는다.") - void validateSame() { + @DisplayName("이전 참석 정보가 변경전 참석정보와 일치하면 참석 상태를 변경한다.") + void success_change_status() { // given AttendModel model = AttendModel.builder().status(AttendStatus.NONRESPONSE).build(); - // when & then - Assertions.assertDoesNotThrow(() -> model.validateSame("attend")); + // when + model.changeStatus("nonResponse", "attend"); + + // then + assertEquals(AttendStatus.ATTEND, model.getStatus()); } @Test - @DisplayName("참석 상태를 변경한다.") - void changeStatus() { + @DisplayName("이전 참석 정보가 참석 대상자가 아니라면 참석 상태를 변경하지 못 한다.") + void fail_change_status_when_noRelated() { // given - AttendModel model = AttendModel.builder().status(AttendStatus.NONRESPONSE).build(); + AttendModel model = AttendModel.builder().status(AttendStatus.NONRELATED).build(); - // when - model.changeStatus("attend"); - - // then - assertEquals(AttendStatus.ATTEND, model.getStatus()); + // when & then + assertThrows(DeniedSaveAttendException.class, () -> model.changeStatus("nonRelated", "attend")); } } From b47c7a201feba0f916e7cbdc95cc950a66e3b399 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:19:41 +0900 Subject: [PATCH 05/14] =?UTF-8?q?feat=20:=20=EB=B3=B8=EC=9D=B8=EC=9D=98=20?= =?UTF-8?q?=EC=B0=B8=EC=84=9D=20=EC=A0=95=EB=B3=B4=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eeos/attend/presentation/AttendController.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java index e11415e5..e4956161 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java @@ -1,19 +1,20 @@ package com.blackcompany.eeos.attend.presentation; import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; +import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; import com.blackcompany.eeos.attend.application.usecase.ChangeAttendStatusUsecase; import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; +import com.blackcompany.eeos.auth.presentation.support.Member; import com.blackcompany.eeos.common.presentation.respnose.ApiResponse; import com.blackcompany.eeos.common.presentation.respnose.ApiResponseBody.SuccessBody; import com.blackcompany.eeos.common.presentation.respnose.ApiResponseGenerator; import com.blackcompany.eeos.common.presentation.respnose.MessageCode; -import com.blackcompany.eeos.program.application.dto.ChangeAttendStatusRequest; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -34,10 +35,12 @@ public ApiResponse>> findAttendMemberInfo( return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.GET); } - @PostMapping("/programs/{programId}") + @PutMapping("/programs/{programId}") public ApiResponse> changeAttendStatus( - @PathVariable("programId") Long programId, @RequestBody ChangeAttendStatusRequest request) { - changeAttendStatusUsecase.changeStatus(request, programId); + @Member Long memberId, + @PathVariable("programId") Long programId, + @RequestBody ChangeAttendStatusRequest request) { + changeAttendStatusUsecase.changeStatus(memberId, request, programId); return ApiResponseGenerator.success(HttpStatus.OK, MessageCode.UPDATE); } From d8e5d9c313dc4b1c3390753f8d7a781eafb4c1b1 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:21:01 +0900 Subject: [PATCH 06/14] =?UTF-8?q?chore=20:=20=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=20=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attend/application/{model => service}/AttendService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/{model => service}/AttendService.java (94%) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java similarity index 94% rename from BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendService.java rename to BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java index d37baeee..2a80cb77 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/model/AttendService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java @@ -1,9 +1,11 @@ -package com.blackcompany.eeos.attend.application.model; +package com.blackcompany.eeos.attend.application.service; import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; import com.blackcompany.eeos.attend.application.dto.converter.AttendInfoConverter; import com.blackcompany.eeos.attend.application.exception.NotFoundAttendException; +import com.blackcompany.eeos.attend.application.model.AttendModel; +import com.blackcompany.eeos.attend.application.model.AttendStatus; import com.blackcompany.eeos.attend.application.model.converter.AttendEntityConverter; import com.blackcompany.eeos.attend.application.usecase.ChangeAttendStatusUsecase; import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; From afac0e657884a0cd7f804aad72dbbe8cf5e909c6 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:42:20 +0900 Subject: [PATCH 07/14] =?UTF-8?q?refactor=20:=20=EB=B3=B8=EC=9D=B8?= =?UTF-8?q?=EC=9D=98=20=EC=B0=B8=EC=84=9D=EC=83=81=ED=83=9C=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=B3=80=EA=B2=BD=EC=8B=9C=20response=20=ED=98=95?= =?UTF-8?q?=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/ChangeAttendStatusResponse.java | 16 +++++++++ .../ChangeAttendStatusConverter.java | 11 ++++++ .../application/service/AttendService.java | 34 +++++++++++-------- .../usecase/ChangeAttendStatusUsecase.java | 3 +- .../attend/presentation/AttendController.java | 8 +++-- 5 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/ChangeAttendStatusResponse.java create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/ChangeAttendStatusConverter.java diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/ChangeAttendStatusResponse.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/ChangeAttendStatusResponse.java new file mode 100644 index 00000000..f687d5d9 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/ChangeAttendStatusResponse.java @@ -0,0 +1,16 @@ +package com.blackcompany.eeos.attend.application.dto; + +import com.blackcompany.eeos.common.support.dto.AbstractResponseDto; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder(toBuilder = true) +public class ChangeAttendStatusResponse implements AbstractResponseDto { + private String name; + private String attendStatus; +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/ChangeAttendStatusConverter.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/ChangeAttendStatusConverter.java new file mode 100644 index 00000000..9327340c --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/ChangeAttendStatusConverter.java @@ -0,0 +1,11 @@ +package com.blackcompany.eeos.attend.application.dto.converter; + +import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusResponse; +import org.springframework.stereotype.Component; + +@Component +public class ChangeAttendStatusConverter { + public ChangeAttendStatusResponse from(String name, String attendStatus) { + return ChangeAttendStatusResponse.builder().name(name).attendStatus(attendStatus).build(); + } +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java index 2a80cb77..e9fe6545 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java @@ -2,7 +2,9 @@ import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; +import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusResponse; import com.blackcompany.eeos.attend.application.dto.converter.AttendInfoConverter; +import com.blackcompany.eeos.attend.application.dto.converter.ChangeAttendStatusConverter; import com.blackcompany.eeos.attend.application.exception.NotFoundAttendException; import com.blackcompany.eeos.attend.application.model.AttendModel; import com.blackcompany.eeos.attend.application.model.AttendStatus; @@ -11,6 +13,7 @@ import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; import com.blackcompany.eeos.attend.persistence.AttendEntity; import com.blackcompany.eeos.attend.persistence.AttendRepository; +import com.blackcompany.eeos.member.application.service.QueryMemberService; import com.blackcompany.eeos.member.persistence.MemberRepository; import com.blackcompany.eeos.program.application.service.ProgramValidService; import java.util.List; @@ -30,6 +33,8 @@ public class AttendService implements GetAttendantInfoUsecase, ChangeAttendStatu private final ProgramValidService programValidService; private final AttendInfoConverter infoConverter; private final AttendEntityConverter attendEntityConverter; + private final QueryMemberService queryMemberService; + private final ChangeAttendStatusConverter changeAttendStatusConverter; @Override public List findAttendInfo(final Long programId) { @@ -40,13 +45,6 @@ public List findAttendInfo(final Long programId) { .collect(Collectors.toList()); } - private AttendStatus getAttendStatus(final Long memberId, final Long programId) { - return attendRepository - .findByProgramIdAndMemberId(programId, memberId) - .map(AttendEntity::getStatus) - .orElseThrow(() -> new NotFoundAttendException(programId)); - } - @Override public List findAttendInfo(final Long programId, final String status) { programValidService.validate(programId); @@ -66,16 +64,24 @@ public List findAttendInfo(final Long programId, final Strin @Transactional @Override - public void changeStatus( + public ChangeAttendStatusResponse changeStatus( final Long memberId, final ChangeAttendStatusRequest request, final Long programId) { - AttendModel model = - attendRepository - .findByProgramIdAndMemberId(programId, memberId) - .map(attendEntityConverter::from) - .orElseThrow(() -> new NotFoundAttendException(programId)); + AttendModel model = attendEntityConverter.from(getAttend(memberId, programId)); model.changeStatus(request.getBeforeAttendStatus(), request.getAfterAttendStatus()); + AttendEntity updated = attendRepository.save(attendEntityConverter.toEntity(model)); + + String name = queryMemberService.getName(memberId); + return changeAttendStatusConverter.from(name, updated.getStatus().getStatus()); + } - attendRepository.save(attendEntityConverter.toEntity(model)); + private AttendEntity getAttend(final Long memberId, final Long programId) { + return attendRepository + .findByProgramIdAndMemberId(programId, memberId) + .orElseThrow(() -> new NotFoundAttendException(programId)); + } + + private AttendStatus getAttendStatus(final Long memberId, final Long programId) { + return getAttend(memberId, programId).getStatus(); } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/ChangeAttendStatusUsecase.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/ChangeAttendStatusUsecase.java index 1d0bf47e..d7c018c1 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/ChangeAttendStatusUsecase.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/ChangeAttendStatusUsecase.java @@ -1,8 +1,9 @@ package com.blackcompany.eeos.attend.application.usecase; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; +import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusResponse; public interface ChangeAttendStatusUsecase { - void changeStatus( + ChangeAttendStatusResponse changeStatus( final Long memberId, final ChangeAttendStatusRequest request, final Long programId); } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java index e4956161..b6dad09b 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java @@ -2,6 +2,7 @@ import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; +import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusResponse; import com.blackcompany.eeos.attend.application.usecase.ChangeAttendStatusUsecase; import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; import com.blackcompany.eeos.auth.presentation.support.Member; @@ -36,12 +37,13 @@ public ApiResponse>> findAttendMemberInfo( } @PutMapping("/programs/{programId}") - public ApiResponse> changeAttendStatus( + public ApiResponse> changeAttendStatus( @Member Long memberId, @PathVariable("programId") Long programId, @RequestBody ChangeAttendStatusRequest request) { - changeAttendStatusUsecase.changeStatus(memberId, request, programId); - return ApiResponseGenerator.success(HttpStatus.OK, MessageCode.UPDATE); + ChangeAttendStatusResponse response = + changeAttendStatusUsecase.changeStatus(memberId, request, programId); + return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.UPDATE); } @GetMapping("/programs/{programId}/members") From 16c59306c59582822ca21fdc3d0df805a5071a2e Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:54:06 +0900 Subject: [PATCH 08/14] =?UTF-8?q?feat=20:=20=EC=9C=A0=EC=A0=80=EC=9D=98=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=A0=95=EB=B3=B4=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EA=B8=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/application/service/QueryMemberService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/member/application/service/QueryMemberService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/member/application/service/QueryMemberService.java index a53e090c..865c2deb 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/member/application/service/QueryMemberService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/member/application/service/QueryMemberService.java @@ -50,4 +50,11 @@ public QueryMemberResponse execute(Long memberId) { MemberModel model = entityConverter.from(member); return responseConverter.from(model); } + + public String getName(final Long memberId) { + return memberRepository + .findById(memberId) + .map(MemberEntity::getName) + .orElseThrow(NotFoundMemberException::new); + } } From 232c2acd5d2193cce5310bb52f6baa388635101f Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 16:54:25 +0900 Subject: [PATCH 09/14] =?UTF-8?q?feat=20:=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=A8=EC=97=90=20=EB=8C=80=ED=95=9C=20=EB=B3=B8=EC=9D=B8?= =?UTF-8?q?=EC=9D=98=20=EC=B0=B8=EC=84=9D=20=EC=83=81=ED=83=9C=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=ED=95=98=EA=B8=B0=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attend/application/service/AttendService.java | 12 +++++++++++- .../application/usecase/GetAttendStatusUsecase.java | 7 +++++++ .../eeos/attend/presentation/AttendController.java | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/GetAttendStatusUsecase.java diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java index e9fe6545..ac06c36c 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java @@ -10,6 +10,7 @@ import com.blackcompany.eeos.attend.application.model.AttendStatus; import com.blackcompany.eeos.attend.application.model.converter.AttendEntityConverter; import com.blackcompany.eeos.attend.application.usecase.ChangeAttendStatusUsecase; +import com.blackcompany.eeos.attend.application.usecase.GetAttendStatusUsecase; import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; import com.blackcompany.eeos.attend.persistence.AttendEntity; import com.blackcompany.eeos.attend.persistence.AttendRepository; @@ -25,7 +26,8 @@ @Service @RequiredArgsConstructor @Transactional(readOnly = true) -public class AttendService implements GetAttendantInfoUsecase, ChangeAttendStatusUsecase { +public class AttendService + implements GetAttendantInfoUsecase, ChangeAttendStatusUsecase, GetAttendStatusUsecase { private final AttendRepository attendRepository; @@ -84,4 +86,12 @@ private AttendEntity getAttend(final Long memberId, final Long programId) { private AttendStatus getAttendStatus(final Long memberId, final Long programId) { return getAttend(memberId, programId).getStatus(); } + + @Override + public ChangeAttendStatusResponse getStatus(Long memberId, Long programId) { + AttendModel model = attendEntityConverter.from(getAttend(memberId, programId)); + String name = queryMemberService.getName(memberId); + + return changeAttendStatusConverter.from(name, model.getStatus().getStatus()); + } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/GetAttendStatusUsecase.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/GetAttendStatusUsecase.java new file mode 100644 index 00000000..62081015 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/GetAttendStatusUsecase.java @@ -0,0 +1,7 @@ +package com.blackcompany.eeos.attend.application.usecase; + +import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusResponse; + +public interface GetAttendStatusUsecase { + ChangeAttendStatusResponse getStatus(final Long memberId, final Long programId); +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java index b6dad09b..852f4492 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java @@ -4,6 +4,7 @@ import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusResponse; import com.blackcompany.eeos.attend.application.usecase.ChangeAttendStatusUsecase; +import com.blackcompany.eeos.attend.application.usecase.GetAttendStatusUsecase; import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; import com.blackcompany.eeos.auth.presentation.support.Member; import com.blackcompany.eeos.common.presentation.respnose.ApiResponse; @@ -28,6 +29,7 @@ public class AttendController { private final GetAttendantInfoUsecase getAttendantInfoUsecase; private final ChangeAttendStatusUsecase changeAttendStatusUsecase; + private final GetAttendStatusUsecase getAttendStatusUsecase; @GetMapping("/candidate/programs/{programId}") public ApiResponse>> findAttendMemberInfo( @@ -46,6 +48,13 @@ public ApiResponse> changeAttendStatus( return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.UPDATE); } + @GetMapping("/programs/{programId}") + public ApiResponse> getAttendStatus( + @Member Long memberId, @PathVariable("programId") Long programId) { + ChangeAttendStatusResponse response = getAttendStatusUsecase.getStatus(memberId, programId); + return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.UPDATE); + } + @GetMapping("/programs/{programId}/members") public ApiResponse>> getAttendInfoByProgram( @PathVariable("programId") Long programId, @RequestParam("attendStatus") String status) { From e935b404e27d93dae9f82fce0a8dfc416e36eea9 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 17:38:56 +0900 Subject: [PATCH 10/14] =?UTF-8?q?fix=20:=20delete=EB=90=9C=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=A0=9C=EC=99=B8=ED=95=98=EA=B3=A0=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=BF=BC=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eeos/attend/persistence/AttendRepository.java | 10 ++++++++-- .../eeos/auth/persistence/AuthInfoRepository.java | 10 ++++++++-- .../eeos/auth/persistence/OauthInfoRepository.java | 5 ++++- .../eeos/member/persistence/MemberRepository.java | 7 ++++--- .../eeos/program/persistence/ProgramRepository.java | 4 ++-- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/persistence/AttendRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/persistence/AttendRepository.java index 78b31030..0e4b1a03 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/persistence/AttendRepository.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/persistence/AttendRepository.java @@ -8,9 +8,15 @@ import org.springframework.data.repository.query.Param; public interface AttendRepository extends JpaRepository { - List findAllByProgramIdAndStatus(Long programId, AttendStatus status); + @Query( + "SELECT a FROM AttendEntity a WHERE a.programId =:programId AND a.status=:status AND a.isDeleted=false") + List findAllByProgramIdAndStatus( + @Param("programId") Long programId, @Param("status") AttendStatus status); - Optional findByProgramIdAndMemberId(Long programId, Long memberId); + @Query( + "SELECT a FROM AttendEntity a WHERE a.programId =:programId AND a.status=:status AND a.isDeleted=false") + Optional findByProgramIdAndMemberId( + @Param("programId") Long programId, @Param("memberId") Long memberId); void deleteAllByProgramId(Long programId); diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoRepository.java index bbea04c6..e8170460 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoRepository.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/AuthInfoRepository.java @@ -2,9 +2,15 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface AuthInfoRepository extends JpaRepository { - Optional findByMemberIdAndToken(Long memberId, String token); + @Query( + "SELECT a FROM AuthInfoEntity a WHERE a.isDeleted=false AND a.memberId=:memberId AND a.token =:token") + Optional findByMemberIdAndToken( + @Param("memberId") Long memberId, @Param("token") String token); - Optional findByToken(String token); + @Query("SELECT a FROM AuthInfoEntity a WHERE a.isDeleted=false AND a.token =:token") + Optional findByToken(@Param("token") String token); } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoRepository.java index be2fb633..e905e6e9 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoRepository.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/auth/persistence/OauthInfoRepository.java @@ -2,7 +2,10 @@ import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface OauthInfoRepository extends JpaRepository { - Optional findByOauthId(String oauthId); + @Query("SELECT o FROM OauthInfoEntity o WHERE o.isDeleted=false AND o.oauthId=:oauthId") + Optional findByOauthId(@Param("oauthId") String oauthId); } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/member/persistence/MemberRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/member/persistence/MemberRepository.java index c6df7107..1fe5ae12 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/member/persistence/MemberRepository.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/member/persistence/MemberRepository.java @@ -9,12 +9,13 @@ public interface MemberRepository extends JpaRepository { @Query( - "SELECT m FROM MemberEntity m inner join AttendEntity a on m.id = a.memberId where a.programId = :programId ORDER BY m.name") + "SELECT m FROM MemberEntity m inner join AttendEntity a on m.id = a.memberId where a.programId = :programId AND m.isDeleted=false ORDER BY m.name") List findMembersByProgramId(@Param("programId") Long programId); - @Query("SELECT m FROM MemberEntity m where m.activeStatus= :activeStatus ORDER BY m.name") + @Query( + "SELECT m FROM MemberEntity m where m.activeStatus= :activeStatus AND m.isDeleted=false ORDER BY m.name") List findMembersByActiveStatus(@Param("activeStatus") ActiveStatus activeStatus); - @Query("SELECT m FROM MemberEntity m WHERE m.id IN :ids") + @Query("SELECT m FROM MemberEntity m WHERE m.isDeleted=false AND m.id IN :ids") List findUsersByIds(@Param("ids") List ids); } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/program/persistence/ProgramRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/program/persistence/ProgramRepository.java index a6ead19c..eb33e44d 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/program/persistence/ProgramRepository.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/program/persistence/ProgramRepository.java @@ -10,12 +10,12 @@ public interface ProgramRepository extends JpaRepository { @Query( - "SELECT p FROM ProgramEntity p WHERE p.programDate < :now AND p.programCategory =:category ORDER BY p.programDate DESC, p.title ASC") + "SELECT p FROM ProgramEntity p WHERE p.programDate < :now AND p.programCategory =:category AND p.isDeleted=false ORDER BY p.programDate DESC, p.title ASC ") Page findAllByEnd( @Param("category") ProgramCategory category, @Param("now") Timestamp now, Pageable pageable); @Query( - "SELECT p FROM ProgramEntity p WHERE p.programDate >= :now AND p.programCategory =:category ORDER BY p.programDate ASC, p.title ASC") + "SELECT p FROM ProgramEntity p WHERE p.programDate >= :now AND p.programCategory =:category AND p.isDeleted=false ORDER BY p.programDate ASC, p.title ASC") Page findAllByIng( @Param("category") ProgramCategory category, @Param("now") Timestamp now, Pageable pageable); } From b8f438005ce6738a76e7764910acfe0c9d94d3a0 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 20:05:42 +0900 Subject: [PATCH 11/14] =?UTF-8?q?fix=20:=20memberId=EB=A5=BC=20=EA=B8=B0?= =?UTF-8?q?=EC=A4=80=EC=9C=BC=EB=A1=9C=20=EC=A1=B0=ED=9A=8C=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=BF=BC=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blackcompany/eeos/attend/persistence/AttendRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/persistence/AttendRepository.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/persistence/AttendRepository.java index 0e4b1a03..346550ea 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/persistence/AttendRepository.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/persistence/AttendRepository.java @@ -14,7 +14,7 @@ List findAllByProgramIdAndStatus( @Param("programId") Long programId, @Param("status") AttendStatus status); @Query( - "SELECT a FROM AttendEntity a WHERE a.programId =:programId AND a.status=:status AND a.isDeleted=false") + "SELECT a FROM AttendEntity a WHERE a.programId =:programId AND a.memberId=:memberId AND a.isDeleted=false") Optional findByProgramIdAndMemberId( @Param("programId") Long programId, @Param("memberId") Long memberId); From 166be85b29d95fcc27e69c1f4bb78f86cf8bb8d2 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 20:06:45 +0900 Subject: [PATCH 12/14] =?UTF-8?q?feat=20:=20=ED=95=B4=EB=8B=B9=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EB=9E=A8=EC=9D=98=20=EC=B0=B8=EC=97=AC=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20response?= =?UTF-8?q?=20=ED=98=95=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/AttendInfoResponse.java | 1 - .../dto/QueryAttendStatusResponse.java | 16 ++++++++++++++++ .../dto/converter/AttendInfoConverter.java | 9 +++++++++ .../QueryAttendStatusResponseConverter.java | 13 +++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/QueryAttendStatusResponse.java create mode 100644 BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/QueryAttendStatusResponseConverter.java diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/AttendInfoResponse.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/AttendInfoResponse.java index 02d291cb..9fb3b1e2 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/AttendInfoResponse.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/AttendInfoResponse.java @@ -12,7 +12,6 @@ @Builder(toBuilder = true) public class AttendInfoResponse implements AbstractResponseDto { private Long memberId; - private Long generation; private String name; private String attendStatus; } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/QueryAttendStatusResponse.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/QueryAttendStatusResponse.java new file mode 100644 index 00000000..1e827820 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/QueryAttendStatusResponse.java @@ -0,0 +1,16 @@ +package com.blackcompany.eeos.attend.application.dto; + +import com.blackcompany.eeos.common.support.dto.AbstractResponseDto; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@Builder(toBuilder = true) +public class QueryAttendStatusResponse implements AbstractResponseDto { + private List members; +} diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/AttendInfoConverter.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/AttendInfoConverter.java index 55dcd15a..9c44aaa7 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/AttendInfoConverter.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/AttendInfoConverter.java @@ -2,6 +2,7 @@ import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; import com.blackcompany.eeos.attend.application.model.AttendStatus; +import com.blackcompany.eeos.member.application.model.MemberModel; import com.blackcompany.eeos.member.persistence.MemberEntity; import org.springframework.stereotype.Component; @@ -16,6 +17,14 @@ public AttendInfoResponse from(final MemberEntity source, final AttendStatus att .build(); } + public AttendInfoResponse from(final MemberModel source, final AttendStatus attendStatus) { + return AttendInfoResponse.builder() + .memberId(source.getId()) + .name(source.getName()) + .attendStatus(attendStatus.getStatus()) + .build(); + } + public AttendInfoResponse from(final MemberEntity source, final String status) { return AttendInfoResponse.builder() .memberId(source.getId()) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/QueryAttendStatusResponseConverter.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/QueryAttendStatusResponseConverter.java new file mode 100644 index 00000000..b1d70888 --- /dev/null +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/dto/converter/QueryAttendStatusResponseConverter.java @@ -0,0 +1,13 @@ +package com.blackcompany.eeos.attend.application.dto.converter; + +import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; +import com.blackcompany.eeos.attend.application.dto.QueryAttendStatusResponse; +import java.util.List; +import org.springframework.stereotype.Component; + +@Component +public class QueryAttendStatusResponseConverter { + public QueryAttendStatusResponse of(List response) { + return QueryAttendStatusResponse.builder().members(response).build(); + } +} From 863c12d9faec9750740bcc5594404c8b61291dc3 Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 20:06:56 +0900 Subject: [PATCH 13/14] =?UTF-8?q?feat=20:=20=ED=95=B4=EB=8B=B9=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EB=9E=A8=EC=9D=98=20=EC=B0=B8=EC=97=AC=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/AttendService.java | 63 ++++++++++++++----- .../usecase/GetAttendantInfoUsecase.java | 3 +- .../member/application/model/MemberModel.java | 4 ++ 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java index ac06c36c..8f63de76 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/service/AttendService.java @@ -3,8 +3,10 @@ import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusResponse; +import com.blackcompany.eeos.attend.application.dto.QueryAttendStatusResponse; import com.blackcompany.eeos.attend.application.dto.converter.AttendInfoConverter; import com.blackcompany.eeos.attend.application.dto.converter.ChangeAttendStatusConverter; +import com.blackcompany.eeos.attend.application.dto.converter.QueryAttendStatusResponseConverter; import com.blackcompany.eeos.attend.application.exception.NotFoundAttendException; import com.blackcompany.eeos.attend.application.model.AttendModel; import com.blackcompany.eeos.attend.application.model.AttendStatus; @@ -14,7 +16,10 @@ import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; import com.blackcompany.eeos.attend.persistence.AttendEntity; import com.blackcompany.eeos.attend.persistence.AttendRepository; +import com.blackcompany.eeos.member.application.model.MemberModel; +import com.blackcompany.eeos.member.application.model.converter.MemberEntityConverter; import com.blackcompany.eeos.member.application.service.QueryMemberService; +import com.blackcompany.eeos.member.persistence.MemberEntity; import com.blackcompany.eeos.member.persistence.MemberRepository; import com.blackcompany.eeos.program.application.service.ProgramValidService; import java.util.List; @@ -37,6 +42,9 @@ public class AttendService private final AttendEntityConverter attendEntityConverter; private final QueryMemberService queryMemberService; private final ChangeAttendStatusConverter changeAttendStatusConverter; + private final MemberEntityConverter memberEntityConverter; + private final AttendInfoConverter attendInfoConverter; + private final QueryAttendStatusResponseConverter attendStatusResponseConverter; @Override public List findAttendInfo(final Long programId) { @@ -48,20 +56,21 @@ public List findAttendInfo(final Long programId) { } @Override - public List findAttendInfo(final Long programId, final String status) { + public QueryAttendStatusResponse findAttendInfo(final Long programId, final String status) { programValidService.validate(programId); - AttendStatus attendStatus = AttendStatus.findByAttendStatus(status); + List attendsByProgram = findAttend(programId, status); + List members = + findAMembers(programId, status).stream() + .map(memberEntityConverter::from) + .collect(Collectors.toList()); - List statusMember = - attendRepository.findAllByProgramIdAndStatus(programId, attendStatus).stream() - .map(AttendEntity::getMemberId) + List response = + members.stream() + .map(member -> combine(member, attendsByProgram, programId)) .collect(Collectors.toList()); - return memberRepository.findMembersByProgramId(programId).stream() - .filter(member -> statusMember.contains(member.getId())) - .map(member -> infoConverter.from(member, status)) - .collect(Collectors.toList()); + return attendStatusResponseConverter.of(response); } @Transactional @@ -77,6 +86,14 @@ public ChangeAttendStatusResponse changeStatus( return changeAttendStatusConverter.from(name, updated.getStatus().getStatus()); } + @Override + public ChangeAttendStatusResponse getStatus(Long memberId, Long programId) { + AttendModel model = attendEntityConverter.from(getAttend(memberId, programId)); + String name = queryMemberService.getName(memberId); + + return changeAttendStatusConverter.from(name, model.getStatus().getStatus()); + } + private AttendEntity getAttend(final Long memberId, final Long programId) { return attendRepository .findByProgramIdAndMemberId(programId, memberId) @@ -87,11 +104,29 @@ private AttendStatus getAttendStatus(final Long memberId, final Long programId) return getAttend(memberId, programId).getStatus(); } - @Override - public ChangeAttendStatusResponse getStatus(Long memberId, Long programId) { - AttendModel model = attendEntityConverter.from(getAttend(memberId, programId)); - String name = queryMemberService.getName(memberId); + private AttendInfoResponse combine( + MemberModel member, List attends, Long programId) { + AttendEntity attendEntity = + attends.stream() + .filter(attend -> member.validateSame(attend.getMemberId())) + .findAny() + .orElseThrow(() -> new NotFoundAttendException(programId)); - return changeAttendStatusConverter.from(name, model.getStatus().getStatus()); + return attendInfoConverter.from(member, attendEntity.getStatus()); + } + + private List findAMembers(final Long programId, final String status) { + List memberIds = + findAttend(programId, status).stream() + .map(AttendEntity::getMemberId) + .collect(Collectors.toList()); + + return memberRepository.findUsersByIds(memberIds); + } + + private List findAttend(final Long programId, final String status) { + AttendStatus attendStatus = AttendStatus.findByAttendStatus(status); + + return attendRepository.findAllByProgramIdAndStatus(programId, attendStatus); } } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/GetAttendantInfoUsecase.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/GetAttendantInfoUsecase.java index 826374ff..52264b25 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/GetAttendantInfoUsecase.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/application/usecase/GetAttendantInfoUsecase.java @@ -1,10 +1,11 @@ package com.blackcompany.eeos.attend.application.usecase; import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; +import com.blackcompany.eeos.attend.application.dto.QueryAttendStatusResponse; import java.util.List; public interface GetAttendantInfoUsecase { List findAttendInfo(final Long programId); - List findAttendInfo(final Long programId, final String attendStatus); + QueryAttendStatusResponse findAttendInfo(final Long programId, final String attendStatus); } diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/member/application/model/MemberModel.java b/BE/eeos/src/main/java/com/blackcompany/eeos/member/application/model/MemberModel.java index 77362c46..d72d6d99 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/member/application/model/MemberModel.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/member/application/model/MemberModel.java @@ -23,4 +23,8 @@ public MemberModel updateActiveStatus(String status) { this.activeStatus = ActiveStatus.find(status); return this; } + + public boolean validateSame(Long memberId) { + return id.equals(memberId); + } } From 34cd95671b6e9b5f24c94be73211957a363e647b Mon Sep 17 00:00:00 2001 From: kssumin <201566@jnu.ac.kr> Date: Sun, 7 Jan 2024 20:07:03 +0900 Subject: [PATCH 14/14] =?UTF-8?q?feat=20:=20=ED=95=B4=EB=8B=B9=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EB=9E=A8=EC=9D=98=20=EC=B0=B8=EC=97=AC=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eeos/attend/presentation/AttendController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java index 852f4492..e7b4e380 100644 --- a/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java +++ b/BE/eeos/src/main/java/com/blackcompany/eeos/attend/presentation/AttendController.java @@ -3,6 +3,7 @@ import com.blackcompany.eeos.attend.application.dto.AttendInfoResponse; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusRequest; import com.blackcompany.eeos.attend.application.dto.ChangeAttendStatusResponse; +import com.blackcompany.eeos.attend.application.dto.QueryAttendStatusResponse; import com.blackcompany.eeos.attend.application.usecase.ChangeAttendStatusUsecase; import com.blackcompany.eeos.attend.application.usecase.GetAttendStatusUsecase; import com.blackcompany.eeos.attend.application.usecase.GetAttendantInfoUsecase; @@ -56,9 +57,9 @@ public ApiResponse> getAttendStatus( } @GetMapping("/programs/{programId}/members") - public ApiResponse>> getAttendInfoByProgram( + public ApiResponse> getAttendInfoByProgram( @PathVariable("programId") Long programId, @RequestParam("attendStatus") String status) { - List response = getAttendantInfoUsecase.findAttendInfo(programId, status); + QueryAttendStatusResponse response = getAttendantInfoUsecase.findAttendInfo(programId, status); return ApiResponseGenerator.success(response, HttpStatus.OK, MessageCode.GET); } }