From e05702fcbc376fa64eb18315bd02f2fd603dba04 Mon Sep 17 00:00:00 2001 From: Geonwoo Lee <82176176+geonwoo0215@users.noreply.github.com> Date: Sun, 12 Mar 2023 21:00:59 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor(Proposal):=20=EC=8B=A0=EC=B2=AD?= =?UTF-8?q?=EC=84=9C=20=EC=9D=91=EB=8B=B5=20=EA=B0=9D=EC=B2=B4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EA=B0=80=EA=B2=8C=20=EC=9D=B4=EB=A6=84,=20?= =?UTF-8?q?=EB=AA=A8=EC=9E=84=EC=9D=B4=EB=A6=84=20=ED=95=84=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/ProposalResponse.java | 4 +- .../proposal/mapper/ProposalMapper.java | 2 +- .../proposal/service/ProposalServiceImpl.java | 46 ++++++++++++++----- .../proposal/api/ProposalControllerTest.java | 6 +++ 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/prgrms/mukvengers/domain/proposal/dto/response/ProposalResponse.java b/src/main/java/com/prgrms/mukvengers/domain/proposal/dto/response/ProposalResponse.java index dfc956b0..b41ea803 100644 --- a/src/main/java/com/prgrms/mukvengers/domain/proposal/dto/response/ProposalResponse.java +++ b/src/main/java/com/prgrms/mukvengers/domain/proposal/dto/response/ProposalResponse.java @@ -9,6 +9,8 @@ public record ProposalResponse( Long leaderId, Long crewId, String content, - ProposalStatus status + ProposalStatus status, + String storeName, + String crewName ) { } diff --git a/src/main/java/com/prgrms/mukvengers/domain/proposal/mapper/ProposalMapper.java b/src/main/java/com/prgrms/mukvengers/domain/proposal/mapper/ProposalMapper.java index 89912148..26e4d362 100644 --- a/src/main/java/com/prgrms/mukvengers/domain/proposal/mapper/ProposalMapper.java +++ b/src/main/java/com/prgrms/mukvengers/domain/proposal/mapper/ProposalMapper.java @@ -12,5 +12,5 @@ public interface ProposalMapper { Proposal toProposal(CreateProposalRequest proposalRequest, User user, Long crewId); - ProposalResponse toProposalResponse(Proposal proposal); + ProposalResponse toProposalResponse(Proposal proposal, String storeName, String crewName); } diff --git a/src/main/java/com/prgrms/mukvengers/domain/proposal/service/ProposalServiceImpl.java b/src/main/java/com/prgrms/mukvengers/domain/proposal/service/ProposalServiceImpl.java index d2f65b6a..07522546 100644 --- a/src/main/java/com/prgrms/mukvengers/domain/proposal/service/ProposalServiceImpl.java +++ b/src/main/java/com/prgrms/mukvengers/domain/proposal/service/ProposalServiceImpl.java @@ -1,5 +1,6 @@ package com.prgrms.mukvengers.domain.proposal.service; +import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -92,33 +93,54 @@ public IdResponse create(CreateProposalRequest proposalRequest, Long userId, Lon @Override public ProposalResponse getById(Long proposalId) { - Proposal proposal = proposalRepository.findById(proposalId) .orElseThrow(() -> new ProposalNotFoundException(proposalId)); - return proposalMapper.toProposalResponse(proposal); + Crew crew = crewRepository.findById(proposal.getCrewId()) + .orElseThrow(() -> new CrewNotFoundException(proposal.getCrewId())); + + String crewName = crew.getName(); + String storePlaceName = crew.getStore().getPlaceName(); + + return proposalMapper.toProposalResponse(proposal, crewName, storePlaceName); } @Override public ProposalResponses getProposalsByLeaderId(Long userId) { + List proposals = proposalRepository.findAllByLeaderIdOrderByCreatedAtDesc(userId); + List proposalResponses = new ArrayList<>(); + + for (Proposal proposal : proposals) { + Crew crew = crewRepository.findById(proposal.getCrewId()) + .orElseThrow(() -> new CrewNotFoundException(proposal.getCrewId())); - List proposals = proposalRepository.findAllByLeaderIdOrderByCreatedAtDesc(userId) - .stream() - .map(proposalMapper::toProposalResponse) - .toList(); + String crewName = crew.getName(); + String storePlaceName = crew.getStore().getPlaceName(); - return new ProposalResponses(proposals); + ProposalResponse proposalResponse = proposalMapper.toProposalResponse(proposal, crewName, storePlaceName); + proposalResponses.add(proposalResponse); + } + + return new ProposalResponses(proposalResponses); } @Override public ProposalResponses getProposalsByMemberId(Long userId) { + List proposals = proposalRepository.findAllByUserIdOrderByCreatedAtDesc(userId); + List proposalResponses = new ArrayList<>(); + + for (Proposal proposal : proposals) { + Crew crew = crewRepository.findById(proposal.getCrewId()) + .orElseThrow(() -> new CrewNotFoundException(proposal.getCrewId())); - List proposals = proposalRepository.findAllByUserIdOrderByCreatedAtDesc(userId) - .stream() - .map(proposalMapper::toProposalResponse) - .toList(); + String crewName = crew.getName(); + String storePlaceName = crew.getStore().getPlaceName(); + + ProposalResponse proposalResponse = proposalMapper.toProposalResponse(proposal, crewName, storePlaceName); + proposalResponses.add(proposalResponse); + } - return new ProposalResponses(proposals); + return new ProposalResponses(proposalResponses); } @Override diff --git a/src/test/java/com/prgrms/mukvengers/domain/proposal/api/ProposalControllerTest.java b/src/test/java/com/prgrms/mukvengers/domain/proposal/api/ProposalControllerTest.java index 99706826..712a22f2 100644 --- a/src/test/java/com/prgrms/mukvengers/domain/proposal/api/ProposalControllerTest.java +++ b/src/test/java/com/prgrms/mukvengers/domain/proposal/api/ProposalControllerTest.java @@ -108,6 +108,8 @@ void getById_success() throws Exception { fieldWithPath("data.status").type(STRING).description("신청서 상태"), fieldWithPath("data.leaderId").type(NUMBER).description("모임의 방장 아이디"), fieldWithPath("data.crewId").type(NUMBER).description("모임 아이디"), + fieldWithPath("data.storeName").type(STRING).description("가게 이름"), + fieldWithPath("data.crewName").type(STRING).description("모임 이름"), fieldWithPath("data.user.id").type(NUMBER).description("유저 ID"), fieldWithPath("data.user.nickname").type(STRING).description("닉네임"), fieldWithPath("data.user.profileImgUrl").type(STRING).description("프로필 이미지"), @@ -153,6 +155,8 @@ void getProposalsByLeaderId_success() throws Exception { fieldWithPath("data.responses.[].content").type(STRING).description("신청서 내용"), fieldWithPath("data.responses.[].status").type(STRING).description("신청서 상태"), fieldWithPath("data.responses.[].leaderId").type(NUMBER).description("모임의 방장 아이디"), + fieldWithPath("data.responses.[].storeName").type(STRING).description("가게 이름"), + fieldWithPath("data.responses.[].crewName").type(STRING).description("모임 이름"), fieldWithPath("data.responses.[].crewId").type(NUMBER).description("모임 아이디") ) .build() @@ -252,6 +256,8 @@ void getProposalsByMemberId_success() throws Exception { fieldWithPath("data.responses.[].content").type(STRING).description("신청서 내용"), fieldWithPath("data.responses.[].status").type(STRING).description("신청서 상태"), fieldWithPath("data.responses.[].leaderId").type(NUMBER).description("모임의 방장 아이디"), + fieldWithPath("data.responses.[].storeName").type(STRING).description("가게 이름"), + fieldWithPath("data.responses.[].crewName").type(STRING).description("모임 이름"), fieldWithPath("data.responses.[].crewId").type(NUMBER).description("모임 아이디") ) .build() From e6ff4f64c8c82e7c6829edde1253af607de83098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B8=B0=EC=84=9C?= <5rne@naver.com> Date: Sun, 12 Mar 2023 23:34:33 +0900 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20Error=20log=20handler=EC=97=90=20H?= =?UTF-8?q?ttpServletRequest=20param=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mukvengers/global/exception/GlobalExceptionHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/prgrms/mukvengers/global/exception/GlobalExceptionHandler.java b/src/main/java/com/prgrms/mukvengers/global/exception/GlobalExceptionHandler.java index e1b5d85d..1de45ec2 100644 --- a/src/main/java/com/prgrms/mukvengers/global/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/prgrms/mukvengers/global/exception/GlobalExceptionHandler.java @@ -89,7 +89,7 @@ public ErrorResponse handleIllegalArgumentException(IllegalArgumentException e) @SlackNotification @ResponseStatus(INTERNAL_SERVER_ERROR) @ExceptionHandler(Exception.class) - public ErrorResponse handleException(Exception e) { + public ErrorResponse handleException(HttpServletRequest request, Exception e) { logError(e); return ErrorResponse.of(ErrorCode.INTERNAL_SERVER_ERROR); } From ff461b220e53aeb8569cd982b680b0153100ea8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B8=B0=EC=84=9C?= <5rne@naver.com> Date: Sun, 12 Mar 2023 23:34:53 +0900 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=EB=B0=B0=ED=8F=AC=20=EB=B2=84?= =?UTF-8?q?=EC=A0=84=201.0.1=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d9e90b72..a53cac2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM openjdk:17-oracle -ARG JAR_FILE=build/libs/Mukvengers-1.0.0-SNAPSHOT.jar +ARG JAR_FILE=build/libs/Mukvengers-1.0.1.jar ENV MY_SERVER=${MY_SERVER} \ AWS_ACCESS_KEY=${AWS_ACCESS_KEY} \ AWS_SECRET_KEY=${AWS_SECRET_KEY} \ diff --git a/build.gradle b/build.gradle index f7e0642c..759390a0 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ plugins { } group = 'com.prgrms' -version = '1.0.0-SNAPSHOT' +version = '1.0.1' sourceCompatibility = '17' configurations { @@ -42,7 +42,7 @@ openapi3 { setServer(env.MY_SERVER.orElse("http://localhost:8080")) // Swagger 서버 설정 title = "KKINI API Document" description = "Spring REST Docs with SwaggerUI." - version = "1.0.0 - SNAPSHOT" + version = "1.0.1" format = "yaml" }