From 75e6cd5d84c43f4414406a32bb575ea90444a0df Mon Sep 17 00:00:00 2001 From: LeeJaehyung <540900@naver.com> Date: Mon, 18 Nov 2024 10:24:02 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20#196=20=EC=96=B4=EB=93=9C=EB=AF=BC=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=A0=20'2=EC=9D=B8=20=EC=82=AC=EC=A7=84=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=9A=94=EC=B2=AD=EB=A7=8C=20=EB=B6=88=EB=9F=AC?= =?UTF-8?q?=EC=98=A4=EB=8A=94=20API'=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PictureGenerateRequestPersistenceAdapter.java | 10 ++++++++++ .../picturegeneraterequest/api/AdminPGREQApi.java | 3 ++- .../controller/AdminPGREQController.java | 13 ++++++++++++- .../port/PictureGenerateRequestPort.java | 4 ++++ .../service/PictureGenerateRequestService.java | 15 +++++++++++++++ .../usecase/PictureGenerateRequestUseCase.java | 4 ++++ .../PictureGenerateRequestRepository.java | 5 ++++- 7 files changed, 51 insertions(+), 3 deletions(-) diff --git a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/adapter/PictureGenerateRequestPersistenceAdapter.java b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/adapter/PictureGenerateRequestPersistenceAdapter.java index e58f2291..b6c2cb73 100644 --- a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/adapter/PictureGenerateRequestPersistenceAdapter.java +++ b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/adapter/PictureGenerateRequestPersistenceAdapter.java @@ -59,11 +59,21 @@ public Page findByMatchToAdminIs(boolean matchToAdmin, P } + @Override + public Page findByMatchToAdminIsAndPaidIs(boolean matchToAdmin, boolean paid, Pageable pageable) { + return pictureGenerateRequestRepository.findByMatchToAdminIsAndPaidIs(matchToAdmin, paid, pageable); + } + @Override public Page findAllByRequester(User foundUser, Pageable pageable) { return pictureGenerateRequestRepository.findAllByRequester(foundUser, pageable); } + @Override + public Page findAllByRequesterAndPaidIs(User foundUser, boolean paid, Pageable pageable) { + return pictureGenerateRequestRepository.findAllByRequesterAndPaidIs(foundUser, paid, pageable); + } + @Override public Optional findTopByRequesterOrderByCreatedAtDesc(User foundUser) { return pictureGenerateRequestRepository.findTopByRequesterOrderByCreatedAtDesc(foundUser); diff --git a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/api/AdminPGREQApi.java b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/api/AdminPGREQApi.java index 25b32638..4676db50 100644 --- a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/api/AdminPGREQApi.java +++ b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/api/AdminPGREQApi.java @@ -51,7 +51,8 @@ ResponseEntity>> g @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = PictureGenerateResponseStatusForAdmin.class, hasAllOption = true) String status, @Parameter(description = "유저의 email") - @RequestParam(name = "email", required = false) @Email(message = "올바른 email 형식이 아닙니다.") String email + @RequestParam(name = "email", required = false) @Email(message = "올바른 email 형식이 아닙니다.") String email, + @Parameter(description = "유료 사진생성요청 여부") @RequestParam(name = "paid", required = false) Boolean paid ); @Operation(summary = "공급자->어드민(얼굴붙여야하는 요청)", description = "사진생성요청 전체를 매칭대상(어드민,공급자), 응답의 상태를 조건으로 조회하고 페이지네이션 조회합니다.") diff --git a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/controller/AdminPGREQController.java b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/controller/AdminPGREQController.java index 4634d049..35ca60a6 100644 --- a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/controller/AdminPGREQController.java +++ b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/controller/AdminPGREQController.java @@ -54,12 +54,23 @@ public ResponseEntity findByPGRESStatusInAndMatchToAdminIs(List findByMatchToAdminIs(boolean matchToAdmin, Pageable pageable); + Page findByMatchToAdminIsAndPaidIs(boolean matchToAdmin, boolean paid, Pageable pageable); + Page findAllByRequester(User foundUser, Pageable pageable); + Page findAllByRequesterAndPaidIs(User foundUser, boolean paid, Pageable pageable); + Optional findTopByRequesterOrderByCreatedAtDesc(User foundUser); } diff --git a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/service/PictureGenerateRequestService.java b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/service/PictureGenerateRequestService.java index 0858ae76..872a98a0 100644 --- a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/service/PictureGenerateRequestService.java +++ b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/service/PictureGenerateRequestService.java @@ -91,6 +91,21 @@ public Page getAllAdminMatchedByR .map(convertPGREQToAdminMatchedResponseDto()); } + @Override + public Page getAllPaidAdminMatched(Pageable pageable) { + return pictureGenerateRequestPort.findByMatchToAdminIsAndPaidIs(true, true, pageable) + .map(convertPGREQToAdminMatchedResponseDto()); + } + + @Override + public Page getAllPaidAdminMatchedByRequesterEmail(String email, + Pageable pageable) { + User foundUser = userRepository.findByEmail(email) + .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.UserNotFoundByEmail, email)); + return pictureGenerateRequestPort.findAllByRequesterAndPaidIs(foundUser, true, pageable) + .map(convertPGREQToAdminMatchedResponseDto()); + } + @Override public Page getAllCreatorSubmitted(Pageable pageable) { return pictureGenerateRequestPort.findByMatchToAdminIs(false, pageable) diff --git a/genti-api/src/main/java/com/gt/genti/usecase/PictureGenerateRequestUseCase.java b/genti-api/src/main/java/com/gt/genti/usecase/PictureGenerateRequestUseCase.java index 21ebec13..7f335b05 100644 --- a/genti-api/src/main/java/com/gt/genti/usecase/PictureGenerateRequestUseCase.java +++ b/genti-api/src/main/java/com/gt/genti/usecase/PictureGenerateRequestUseCase.java @@ -38,6 +38,10 @@ Page getAllAdminMatchedByPGRESSta Page getAllAdminMatchedByRequesterEmail(String email, Pageable pageable); + Page getAllPaidAdminMatched(Pageable pageable); + + Page getAllPaidAdminMatchedByRequesterEmail(String email, Pageable pageable); + Page getAllCreatorSubmitted(Pageable pageable); Page getAllCreatorSubmittedByPGRESStatus( diff --git a/genti-domain/src/main/java/com/gt/genti/picturegeneraterequest/repository/PictureGenerateRequestRepository.java b/genti-domain/src/main/java/com/gt/genti/picturegeneraterequest/repository/PictureGenerateRequestRepository.java index f3b687a9..16c2bf94 100644 --- a/genti-domain/src/main/java/com/gt/genti/picturegeneraterequest/repository/PictureGenerateRequestRepository.java +++ b/genti-domain/src/main/java/com/gt/genti/picturegeneraterequest/repository/PictureGenerateRequestRepository.java @@ -28,6 +28,8 @@ public interface PictureGenerateRequestRepository Page findAllByRequester(User requester, Pageable pageable); + Page findAllByRequesterAndPaidIs(User requester, boolean paid, Pageable pageable); + @Query("select pgr from PictureGenerateRequest pgr " + "where pgr.pictureGenerateRequestStatus = com.gt.genti.picturegeneraterequest.model.PictureGenerateRequestStatus." + "IN_PROGRESS " @@ -92,9 +94,10 @@ Page findByPictureGenerateResponseStatusInAndMatchToAdm boolean matchToAdmin, Pageable pageable); - Page findByMatchToAdminIs(boolean matchToAdmin, Pageable pageable); + Page findByMatchToAdminIsAndPaidIs(boolean matchToAdmin, boolean paid, Pageable pageable); + Optional findTopByRequesterOrderByCreatedAtDesc(User requester); List findAllByCreatedAtBeforeAndPictureGenerateRequestStatusIn(LocalDateTime createdAt, List status);