Skip to content

Commit

Permalink
Feat: #196 어드민 페이지에서 사용할 '2인 사진생성 요청만 불러오는 API' 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeJae-H committed Nov 18, 2024
1 parent 86a1b07 commit 75e6cd5
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ public Page<PictureGenerateRequest> findByMatchToAdminIs(boolean matchToAdmin, P

}

@Override
public Page<PictureGenerateRequest> findByMatchToAdminIsAndPaidIs(boolean matchToAdmin, boolean paid, Pageable pageable) {
return pictureGenerateRequestRepository.findByMatchToAdminIsAndPaidIs(matchToAdmin, paid, pageable);
}

@Override
public Page<PictureGenerateRequest> findAllByRequester(User foundUser, Pageable pageable) {
return pictureGenerateRequestRepository.findAllByRequester(foundUser, pageable);
}

@Override
public Page<PictureGenerateRequest> findAllByRequesterAndPaidIs(User foundUser, boolean paid, Pageable pageable) {
return pictureGenerateRequestRepository.findAllByRequesterAndPaidIs(foundUser, paid, pageable);
}

@Override
public Optional<PictureGenerateRequest> findTopByRequesterOrderByCreatedAtDesc(User foundUser) {
return pictureGenerateRequestRepository.findTopByRequesterOrderByCreatedAtDesc(foundUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ ResponseEntity<ApiResult<Page<PGREQAdminMatchedDetailFindByAdminResponseDto>>> 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 = "사진생성요청 전체를 매칭대상(어드민,공급자), 응답의 상태를 조건으로 조회하고 페이지네이션 조회합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,23 @@ public ResponseEntity<ApiResult<Page<PGREQAdminMatchedDetailFindByAdminResponseD
@ExampleObject(name = "COMPLETED", description = "작업 완료", value = "COMPLETED"),
@ExampleObject(name = "EXPIRED", description = "만료됨 (기존의 협의된 내용은 아니지만 어드민페이지에 필요하다고 생각했습니다. 추가 부탁드립니다.)", value = "EXPIRED"),
@ExampleObject(name = "ALL", description = "전체", value = "ALL")}) @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) {
@Parameter(description = "유저의 email") @RequestParam(name = "email", required = false) @Email(message = "올바른 email 형식이 아닙니다.") String email,
@Parameter(description = "유료 사진생성요청 여부") @RequestParam(name = "paid", required = false) Boolean paid) {

Sort.Direction sortDirection = Sort.Direction.fromString(direction);
Pageable pageable = PageRequest.of(page, size, Sort.by(sortDirection, sortBy));

if (paid != null && paid){
if(email != null){
return success(pictureGenerateRequestUseCase.getAllPaidAdminMatchedByRequesterEmail(email, pageable));
}
return success(pictureGenerateRequestUseCase.getAllPaidAdminMatched(pageable));
}

if (email != null) {
return success(pictureGenerateRequestUseCase.getAllAdminMatchedByRequesterEmail(email, pageable));
}

if ("ALL".equalsIgnoreCase(status)) {
return success(pictureGenerateRequestUseCase.getAllAdminMatched(pageable));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ Page<PictureGenerateResponse> findByPGRESStatusInAndMatchToAdminIs(List<PictureG

Page<PictureGenerateRequest> findByMatchToAdminIs(boolean matchToAdmin, Pageable pageable);

Page<PictureGenerateRequest> findByMatchToAdminIsAndPaidIs(boolean matchToAdmin, boolean paid, Pageable pageable);

Page<PictureGenerateRequest> findAllByRequester(User foundUser, Pageable pageable);

Page<PictureGenerateRequest> findAllByRequesterAndPaidIs(User foundUser, boolean paid, Pageable pageable);

Optional<PictureGenerateRequest> findTopByRequesterOrderByCreatedAtDesc(User foundUser);
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ public Page<PGREQAdminMatchedDetailFindByAdminResponseDto> getAllAdminMatchedByR
.map(convertPGREQToAdminMatchedResponseDto());
}

@Override
public Page<PGREQAdminMatchedDetailFindByAdminResponseDto> getAllPaidAdminMatched(Pageable pageable) {
return pictureGenerateRequestPort.findByMatchToAdminIsAndPaidIs(true, true, pageable)
.map(convertPGREQToAdminMatchedResponseDto());
}

@Override
public Page<PGREQAdminMatchedDetailFindByAdminResponseDto> 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<PGREQCreatorSubmittedDetailFindByAdminResponseDto> getAllCreatorSubmitted(Pageable pageable) {
return pictureGenerateRequestPort.findByMatchToAdminIs(false, pageable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Page<PGREQAdminMatchedDetailFindByAdminResponseDto> getAllAdminMatchedByPGRESSta
Page<PGREQAdminMatchedDetailFindByAdminResponseDto> getAllAdminMatchedByRequesterEmail(String email,
Pageable pageable);

Page<PGREQAdminMatchedDetailFindByAdminResponseDto> getAllPaidAdminMatched(Pageable pageable);

Page<PGREQAdminMatchedDetailFindByAdminResponseDto> getAllPaidAdminMatchedByRequesterEmail(String email, Pageable pageable);

Page<PGREQCreatorSubmittedDetailFindByAdminResponseDto> getAllCreatorSubmitted(Pageable pageable);

Page<PGREQCreatorSubmittedDetailFindByAdminResponseDto> getAllCreatorSubmittedByPGRESStatus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public interface PictureGenerateRequestRepository

Page<PictureGenerateRequest> findAllByRequester(User requester, Pageable pageable);

Page<PictureGenerateRequest> findAllByRequesterAndPaidIs(User requester, boolean paid, Pageable pageable);

@Query("select pgr from PictureGenerateRequest pgr "
+ "where pgr.pictureGenerateRequestStatus = com.gt.genti.picturegeneraterequest.model.PictureGenerateRequestStatus."
+ "IN_PROGRESS "
Expand Down Expand Up @@ -92,9 +94,10 @@ Page<PictureGenerateResponse> findByPictureGenerateResponseStatusInAndMatchToAdm
boolean matchToAdmin,
Pageable pageable);


Page<PictureGenerateRequest> findByMatchToAdminIs(boolean matchToAdmin, Pageable pageable);

Page<PictureGenerateRequest> findByMatchToAdminIsAndPaidIs(boolean matchToAdmin, boolean paid, Pageable pageable);

Optional<PictureGenerateRequest> findTopByRequesterOrderByCreatedAtDesc(User requester);

List<PictureGenerateRequest> findAllByCreatedAtBeforeAndPictureGenerateRequestStatusIn(LocalDateTime createdAt, List<PictureGenerateRequestStatus> status);
Expand Down

0 comments on commit 75e6cd5

Please sign in to comment.