diff --git a/genti-api/src/main/java/com/gt/genti/withdraw/api/AdminWithdrawRequestApi.java b/genti-api/src/main/java/com/gt/genti/cashout/api/AdminCashoutApi.java similarity index 80% rename from genti-api/src/main/java/com/gt/genti/withdraw/api/AdminWithdrawRequestApi.java rename to genti-api/src/main/java/com/gt/genti/cashout/api/AdminCashoutApi.java index efbbb29e..38782cdd 100644 --- a/genti-api/src/main/java/com/gt/genti/withdraw/api/AdminWithdrawRequestApi.java +++ b/genti-api/src/main/java/com/gt/genti/cashout/api/AdminCashoutApi.java @@ -1,10 +1,13 @@ -package com.gt.genti.withdraw.api; +package com.gt.genti.cashout.api; import org.springframework.data.domain.Page; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; +import com.gt.genti.cashout.dto.response.CashoutCompletionResponseDto; +import com.gt.genti.cashout.dto.response.CashoutFindByAdminResponseDto; +import com.gt.genti.cashout.model.CashoutStatus; import com.gt.genti.error.ResponseCode; import com.gt.genti.response.GentiResponse.ApiResult; import com.gt.genti.swagger.AuthorizedAdmin; @@ -12,9 +15,6 @@ import com.gt.genti.swagger.EnumResponses; import com.gt.genti.user.model.AuthUser; import com.gt.genti.validator.ValidEnum; -import com.gt.genti.withdraw.dto.response.WithdrawCompletionResponseDto; -import com.gt.genti.withdraw.dto.response.WithdrawFindByAdminResponseDto; -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -24,13 +24,13 @@ import jakarta.validation.constraints.NotNull; @AuthorizedAdmin -@Tag(name = "[AdminWithdrawRequestController] 어드민 출금요청 컨트롤러", description = "공급자의 출금 요청을 조회,수정합니다.") -public interface AdminWithdrawRequestApi { +@Tag(name = "[AdminCashoutController] 어드민 출금요청 컨트롤러", description = "공급자의 출금 요청을 조회,수정합니다.") +public interface AdminCashoutApi { @Operation(summary = "출금요청 전체조회", description = "출금요청 페이지네이션 조회") @EnumResponses(value = { @EnumResponse(ResponseCode.OK) }) - ResponseEntity>> getAllWithdrawList( + ResponseEntity>> getAllCashoutList( @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, @Parameter(description = "페이지 당 요소 개수 >=1", example = "10", required = true) @@ -43,7 +43,7 @@ ResponseEntity>> getAllWithdrawLi @RequestParam(name = "direction", defaultValue = "desc") String direction, @Parameter(description = "출금요청 상태, ALL : 모든 상태", example = "IN_PROGRESS", schema = @Schema( allowableValues = {"IN_PROGRESS", "COMPLETED", "REJECTED", "ALL"})) - @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = WithdrawRequestStatus.class, hasAllOption = true) String status + @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = CashoutStatus.class, hasAllOption = true) String status ); @Operation(summary = "특정 공급자의 출금요청 조회", description = "공급자의 email을 전달 받아 해당 공급자의 전체 출금요청을 페이지네이션 조회") @@ -51,7 +51,7 @@ ResponseEntity>> getAllWithdrawLi @EnumResponse(ResponseCode.OK), @EnumResponse(ResponseCode.UserNotFoundByEmail) }) - ResponseEntity>> getWithdrawListByCreatorEmail( + ResponseEntity>> getCashoutListByCreatorEmail( @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, @Parameter(description = "페이지 당 요소 개수 >=1", example = "10", required = true) @@ -64,7 +64,7 @@ ResponseEntity>> getWithdrawListB @RequestParam(name = "direction", defaultValue = "desc") String direction, @Parameter(description = "출금요청 상태, ALL : 모든 상태", example = "IN_PROGRESS", schema = @Schema( allowableValues = {"IN_PROGRESS", "COMPLETED", "REJECTED", "ALL"})) - @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = WithdrawRequestStatus.class, hasAllOption = true) String status, + @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = CashoutStatus.class, hasAllOption = true) String status, @Parameter(description = "사용자 이메일", example = "example@naver.com", required = true) @PathVariable("email") @NotNull String email ); @@ -75,9 +75,9 @@ ResponseEntity>> getWithdrawListB @EnumResponse(ResponseCode.UserNotFound), @EnumResponse(ResponseCode.DepositNotFound) }) - ResponseEntity> complete( + ResponseEntity> complete( @Parameter(description = "출금요청 Id", example = "1") - @PathVariable(value = "withdrawRequestId") Long withdrawRequestId, + @PathVariable(value = "cashoutId") Long cashoutId, @AuthUser Long userId ); } diff --git a/genti-api/src/main/java/com/gt/genti/withdraw/api/CreatorWithdrawApi.java b/genti-api/src/main/java/com/gt/genti/cashout/api/CreatorCashoutApi.java similarity index 78% rename from genti-api/src/main/java/com/gt/genti/withdraw/api/CreatorWithdrawApi.java rename to genti-api/src/main/java/com/gt/genti/cashout/api/CreatorCashoutApi.java index 44662535..5d9011b8 100644 --- a/genti-api/src/main/java/com/gt/genti/withdraw/api/CreatorWithdrawApi.java +++ b/genti-api/src/main/java/com/gt/genti/cashout/api/CreatorCashoutApi.java @@ -1,16 +1,16 @@ -package com.gt.genti.withdraw.api; +package com.gt.genti.cashout.api; import org.springframework.data.domain.Page; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestParam; +import com.gt.genti.cashout.dto.response.CashoutFindByCreatorResponseDto; import com.gt.genti.error.ResponseCode; import com.gt.genti.response.GentiResponse.ApiResult; import com.gt.genti.swagger.AuthorizedCreator; import com.gt.genti.swagger.EnumResponse; import com.gt.genti.swagger.EnumResponses; import com.gt.genti.user.model.AuthUser; -import com.gt.genti.withdraw.dto.response.WithdrawFindByCreatorResponseDto; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -20,16 +20,16 @@ import jakarta.validation.constraints.NotNull; @AuthorizedCreator -@Tag(name = "[CreatorWithdrawController] 공급자 출금요청 컨트롤러", description = "공급자가 출금요청을 수행합니다.") -public interface CreatorWithdrawApi { +@Tag(name = "[CreatorCashoutController] 공급자 출금요청 컨트롤러", description = "공급자가 출금요청을 수행합니다.") +public interface CreatorCashoutApi { @Operation(summary = "출금요청", description = "공급자가 작업한 정산결과를 바탕으로 출금요청을 생성합니다.") @EnumResponses(value = { @EnumResponse(ResponseCode.OK), @EnumResponse(ResponseCode.CreatorNotFound), - @EnumResponse(ResponseCode.CannotCreateWithdrawalDueToSettlementsNotAvailable) + @EnumResponse(ResponseCode.CannotRequestCashoutDueToSettlementsNotAvailable) }) - ResponseEntity> createWithdrawRequest( + ResponseEntity> createCashout( @AuthUser Long userId ); @@ -37,7 +37,7 @@ ResponseEntity> createWithdrawReques @EnumResponses(value = { @EnumResponse(ResponseCode.OK) }) - ResponseEntity>> getWithdrawRequest( + ResponseEntity>> getCashout( @AuthUser Long userId, @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, diff --git a/genti-api/src/main/java/com/gt/genti/withdraw/controller/AdminWithdrawRequestController.java b/genti-api/src/main/java/com/gt/genti/cashout/controller/AdminCashoutController.java similarity index 51% rename from genti-api/src/main/java/com/gt/genti/withdraw/controller/AdminWithdrawRequestController.java rename to genti-api/src/main/java/com/gt/genti/cashout/controller/AdminCashoutController.java index d653d286..023bf846 100644 --- a/genti-api/src/main/java/com/gt/genti/withdraw/controller/AdminWithdrawRequestController.java +++ b/genti-api/src/main/java/com/gt/genti/cashout/controller/AdminCashoutController.java @@ -1,4 +1,4 @@ -package com.gt.genti.withdraw.controller; +package com.gt.genti.cashout.controller; import static com.gt.genti.response.GentiResponse.*; @@ -14,16 +14,17 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.gt.genti.cashout.api.AdminCashoutApi; +import com.gt.genti.cashout.dto.response.CashoutCompletionResponseDto; +import com.gt.genti.cashout.dto.response.CashoutFindByAdminResponseDto; +import com.gt.genti.cashout.model.CashoutStatus; +import com.gt.genti.cashout.service.CashoutService; import com.gt.genti.model.LogAction; import com.gt.genti.model.LogItem; import com.gt.genti.model.LogRequester; import com.gt.genti.model.Logging; import com.gt.genti.user.model.AuthUser; import com.gt.genti.validator.ValidEnum; -import com.gt.genti.withdraw.dto.response.WithdrawCompletionResponseDto; -import com.gt.genti.withdraw.dto.response.WithdrawFindByAdminResponseDto; -import com.gt.genti.withdraw.service.WithdrawService; -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; @@ -32,66 +33,53 @@ import lombok.RequiredArgsConstructor; @RestController -@RequestMapping("/api/v1/admin/withdraw-requests") +@RequestMapping("/api/v1/admin/cashouts") @RequiredArgsConstructor -public class AdminWithdrawRequestController implements com.gt.genti.withdraw.api.AdminWithdrawRequestApi { - private final WithdrawService withDrawService; +public class AdminCashoutController implements AdminCashoutApi { + private final CashoutService cashoutService; @Logging(item = LogItem.CASHOUT, action = LogAction.VIEW, requester = LogRequester.ADMIN) @GetMapping - public ResponseEntity>> getAllWithdrawList( - @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) - @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, - @Parameter(description = "페이지 당 요소 개수 >=1", example = "10", required = true) - @RequestParam(name = "size", defaultValue = "10") @NotNull @Min(0) int size, + public ResponseEntity>> getAllCashoutList( + @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, + @Parameter(description = "페이지 당 요소 개수 >=1", example = "10", required = true) @RequestParam(name = "size", defaultValue = "10") @NotNull @Min(0) int size, @Parameter(description = "정렬 조건 - 기본값 생성일시", example = "createdAt", schema = @Schema(allowableValues = {"id", - "createdAt"})) - @RequestParam(name = "sortBy", defaultValue = "createdAt") String sortBy, + "createdAt"})) @RequestParam(name = "sortBy", defaultValue = "createdAt") String sortBy, @Parameter(description = "정렬 방향 - 기본값 내림차순", example = "desc", schema = @Schema(allowableValues = {"acs", - "desc"})) - @RequestParam(name = "direction", defaultValue = "desc") String direction, - @Parameter(description = "출금요청 상태, ALL : 모든 상태", example = "IN_PROGRESS", schema = @Schema( - allowableValues = {"IN_PROGRESS", "COMPLETED", "REJECTED", "ALL"})) - @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = WithdrawRequestStatus.class, hasAllOption = true) String status - ) { + "desc"})) @RequestParam(name = "direction", defaultValue = "desc") String direction, + @Parameter(description = "출금요청 상태, ALL : 모든 상태", example = "IN_PROGRESS", schema = @Schema(allowableValues = { + "IN_PROGRESS", "COMPLETED", "REJECTED", + "ALL"})) @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = CashoutStatus.class, hasAllOption = true) String status) { Sort.Direction sortDirection = Sort.Direction.fromString(direction); Pageable pageable = PageRequest.of(page, size, Sort.by(sortDirection, sortBy)); - return success(withDrawService.getAllWithdrawRequests(pageable, status)); + return success(cashoutService.getAllCashout(pageable, status)); } @Logging(item = LogItem.CASHOUT, action = LogAction.VIEW, requester = LogRequester.ADMIN) @GetMapping("/{email}") - public ResponseEntity>> getWithdrawListByCreatorEmail( - @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) - @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, - @Parameter(description = "페이지 당 요소 개수 >=1", example = "10", required = true) - @RequestParam(name = "size", defaultValue = "10") @NotNull @Min(0) int size, + public ResponseEntity>> getCashoutListByCreatorEmail( + @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, + @Parameter(description = "페이지 당 요소 개수 >=1", example = "10", required = true) @RequestParam(name = "size", defaultValue = "10") @NotNull @Min(0) int size, @Parameter(description = "정렬 조건 - 기본값 생성일시", example = "createdAt", schema = @Schema(allowableValues = { - "createdAt"})) - @RequestParam(name = "sortBy", defaultValue = "createdAt") String sortBy, + "createdAt"})) @RequestParam(name = "sortBy", defaultValue = "createdAt") String sortBy, @Parameter(description = "정렬 방향 - 기본값 내림차순", example = "desc", schema = @Schema(allowableValues = {"acs", - "desc"})) - @RequestParam(name = "direction", defaultValue = "desc") String direction, - @Parameter(description = "출금요청 상태, ALL : 모든 상태", example = "IN_PROGRESS", schema = @Schema( - allowableValues = {"IN_PROGRESS", "COMPLETED", "REJECTED", "ALL"})) - @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = WithdrawRequestStatus.class, hasAllOption = true) String status, - @Parameter(description = "사용자 이메일", example = "example@naver.com", required = true) - @PathVariable("email") @NotNull String email - ) { + "desc"})) @RequestParam(name = "direction", defaultValue = "desc") String direction, + @Parameter(description = "출금요청 상태, ALL : 모든 상태", example = "IN_PROGRESS", schema = @Schema(allowableValues = { + "IN_PROGRESS", "COMPLETED", "REJECTED", + "ALL"})) @RequestParam(name = "status", defaultValue = "ALL") @ValidEnum(value = CashoutStatus.class, hasAllOption = true) String status, + @Parameter(description = "사용자 이메일", example = "example@naver.com", required = true) @PathVariable("email") @NotNull String email) { Sort.Direction sortDirection = Sort.Direction.fromString(direction); Pageable pageable = PageRequest.of(page, size, Sort.by(sortDirection, sortBy)); - return success(withDrawService.getWithdrawListByCreatorEmail(email, pageable, status)); + return success(cashoutService.getCashoutByCreatorEmail(email, pageable, status)); } @Logging(item = LogItem.CASHOUT, action = LogAction.COMPLETE, requester = LogRequester.ADMIN) - @PostMapping("/{withdrawRequestId}") - public ResponseEntity> complete( - @Parameter(description = "출금요청 Id", example = "1") - @PathVariable(value = "withdrawRequestId") Long withdrawRequestId, - @AuthUser Long userId - ) { - return success(withDrawService.complete(withdrawRequestId, userId)); + @PostMapping("/{cashoutId}") + public ResponseEntity> complete( + @Parameter(description = "출금요청 Id", example = "1") @PathVariable(value = "cashoutId") Long cashoutId, + @AuthUser Long userId) { + return success(cashoutService.complete(cashoutId, userId)); } } diff --git a/genti-api/src/main/java/com/gt/genti/withdraw/controller/CreatorWithdrawController.java b/genti-api/src/main/java/com/gt/genti/cashout/controller/CreatorCashoutController.java similarity index 62% rename from genti-api/src/main/java/com/gt/genti/withdraw/controller/CreatorWithdrawController.java rename to genti-api/src/main/java/com/gt/genti/cashout/controller/CreatorCashoutController.java index bc2e0aa0..f49561df 100644 --- a/genti-api/src/main/java/com/gt/genti/withdraw/controller/CreatorWithdrawController.java +++ b/genti-api/src/main/java/com/gt/genti/cashout/controller/CreatorCashoutController.java @@ -1,4 +1,4 @@ -package com.gt.genti.withdraw.controller; +package com.gt.genti.cashout.controller; import static com.gt.genti.response.GentiResponse.*; @@ -13,13 +13,14 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import com.gt.genti.cashout.api.CreatorCashoutApi; +import com.gt.genti.cashout.dto.response.CashoutFindByCreatorResponseDto; +import com.gt.genti.cashout.service.CashoutService; import com.gt.genti.model.LogAction; import com.gt.genti.model.LogItem; import com.gt.genti.model.LogRequester; import com.gt.genti.model.Logging; import com.gt.genti.user.model.AuthUser; -import com.gt.genti.withdraw.dto.response.WithdrawFindByCreatorResponseDto; -import com.gt.genti.withdraw.service.WithdrawService; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; @@ -28,37 +29,29 @@ import lombok.RequiredArgsConstructor; @RestController -@RequestMapping("/api/v1/creators/withdraw") +@RequestMapping("/api/v1/creators/cashouts") @RequiredArgsConstructor -public class CreatorWithdrawController implements com.gt.genti.withdraw.api.CreatorWithdrawApi { - private final WithdrawService withDrawService; +public class CreatorCashoutController implements CreatorCashoutApi { + private final CashoutService cashoutService; @Logging(item = LogItem.CASHOUT, action = LogAction.CREATE, requester = LogRequester.CREATOR) @PostMapping - public ResponseEntity> createWithdrawRequest( - @AuthUser Long userId - ) { + public ResponseEntity> createCashout(@AuthUser Long userId) { - return success(withDrawService.create(userId)); + return success(cashoutService.create(userId)); } @Logging(item = LogItem.CASHOUT, action = LogAction.VIEW, requester = LogRequester.CREATOR) @GetMapping - public ResponseEntity>> getWithdrawRequest( - @AuthUser Long userId, - @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) - @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, - @Parameter(description = "페이지 당 요소 개수 >=1", example = "10", required = true) - @RequestParam(name = "size", defaultValue = "10") @NotNull @Min(1) int size, + public ResponseEntity>> getCashout(@AuthUser Long userId, + @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, + @Parameter(description = "페이지 당 요소 개수 >=1", example = "10", required = true) @RequestParam(name = "size", defaultValue = "10") @NotNull @Min(1) int size, @Parameter(description = "정렬 조건 - 기본값 생성일시", example = "createdAt", schema = @Schema(allowableValues = {"id", - "createdAt"})) - @RequestParam(name = "sortBy", defaultValue = "createdAt") String sortBy, + "createdAt"})) @RequestParam(name = "sortBy", defaultValue = "createdAt") String sortBy, @Parameter(description = "정렬 방향 - 기본값 내림차순", example = "desc", schema = @Schema(allowableValues = {"acs", - "desc"})) - @RequestParam(name = "direction", defaultValue = "desc") String direction - ) { + "desc"})) @RequestParam(name = "direction", defaultValue = "desc") String direction) { Sort.Direction sortDirection = Sort.Direction.fromString(direction); Pageable pageable = PageRequest.of(page, size, Sort.by(sortDirection, sortBy)); - return success(withDrawService.findWithdrawList(userId, pageable)); + return success(cashoutService.findCashoutList(userId, pageable)); } } diff --git a/genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawCompletionResponseDto.java b/genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutCompletionResponseDto.java similarity index 50% rename from genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawCompletionResponseDto.java rename to genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutCompletionResponseDto.java index 78d63f69..0130295a 100644 --- a/genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawCompletionResponseDto.java +++ b/genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutCompletionResponseDto.java @@ -1,26 +1,26 @@ -package com.gt.genti.withdraw.dto.response; +package com.gt.genti.cashout.dto.response; -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; +import com.gt.genti.cashout.model.CashoutStatus; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -@Schema(name = "[Withdraw][Admin] 출금 요청 해결(송금) 완료시 응답 dto") +@Schema(name = "[Cashout][Admin] 출금 요청 해결(송금) 완료시 응답 dto") @Getter @NoArgsConstructor -public class WithdrawCompletionResponseDto { +public class CashoutCompletionResponseDto { @Schema(description = "출금요청 DB Id", example = "1") - Long withdrawRequestId; + Long cashoutId; @Schema(description = "출금요청의 상태", example = "출금 진행중") - WithdrawRequestStatus status; + CashoutStatus status; @Schema(description = "작업한 어드민 이름", example = "로빈") String modifiedBy; @Builder - public WithdrawCompletionResponseDto(Long withdrawRequestId, WithdrawRequestStatus status, String modifiedBy) { - this.withdrawRequestId = withdrawRequestId; + public CashoutCompletionResponseDto(Long cashoutId, CashoutStatus status, String modifiedBy) { + this.cashoutId = cashoutId; this.status = status; this.modifiedBy = modifiedBy; } diff --git a/genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutFindByAdminResponseDto.java b/genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutFindByAdminResponseDto.java new file mode 100644 index 00000000..cdfd3385 --- /dev/null +++ b/genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutFindByAdminResponseDto.java @@ -0,0 +1,45 @@ +package com.gt.genti.cashout.dto.response; + +import com.gt.genti.cashout.model.Cashout; +import com.gt.genti.cashout.model.CashoutStatus; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Schema(name = "[Cashout][Admin] 출금요청 조회 by 어드민 응답 dto") +@Getter +@NoArgsConstructor +public class CashoutFindByAdminResponseDto { + @Schema(description = "출금요청 DB Id", example = "1") + Long cashoutId; + @Schema(description = "출금요청한 유저의 이메일", example = "example@gmail.com") + String requesterEmail; + @Schema(description = "출금 금액", example = "15000") + long amount; + @Schema(description = "출금 요청에 포함된 작업 수", example = "3") + int taskCount; + @Schema(description = "출금 요청 상태", example = "출금 완료") + CashoutStatus status; + + public static CashoutFindByAdminResponseDto of(Cashout cashout) { + return CashoutFindByAdminResponseDto.builder() + .cashoutId(cashout.getId()) + .requesterEmail(cashout.getCreator().getUser().getEmail()) + .amount(cashout.getAmount()) + .status(cashout.getStatus()) + .taskCount(cashout.getTaskCount()) + .build(); + } + + @Builder + public CashoutFindByAdminResponseDto(Long cashoutId, String requesterEmail, long amount, int taskCount, + CashoutStatus status) { + this.cashoutId = cashoutId; + this.requesterEmail = requesterEmail; + this.amount = amount; + this.taskCount = taskCount; + this.status = status; + } +} diff --git a/genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutFindByCreatorResponseDto.java b/genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutFindByCreatorResponseDto.java new file mode 100644 index 00000000..56b4e405 --- /dev/null +++ b/genti-api/src/main/java/com/gt/genti/cashout/dto/response/CashoutFindByCreatorResponseDto.java @@ -0,0 +1,31 @@ +package com.gt.genti.cashout.dto.response; + +import com.gt.genti.cashout.model.CashoutStatus; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Schema(name = "[Cashout][Creator] 출금요청 조회 by 공급자 응답 dto") +@Getter +@NoArgsConstructor +public class CashoutFindByCreatorResponseDto { + @Schema(description = "출금요청 DB Id", example = "1") + Long cashoutId; + @Schema(description = "출금 신청액", example = "15000") + Long amount; + @Schema(description = "출금된 작업 개수", example = "3") + int taskCount; + @Schema(description = "출금요청 상태") + CashoutStatus cashoutStatus; + + @Builder + public CashoutFindByCreatorResponseDto(Long cashoutId, Long amount, int taskCount, + CashoutStatus cashoutStatus) { + this.cashoutId = cashoutId; + this.amount = amount; + this.taskCount = taskCount; + this.cashoutStatus = cashoutStatus; + } +} diff --git a/genti-api/src/main/java/com/gt/genti/cashout/service/CashoutService.java b/genti-api/src/main/java/com/gt/genti/cashout/service/CashoutService.java new file mode 100644 index 00000000..788d0417 --- /dev/null +++ b/genti-api/src/main/java/com/gt/genti/cashout/service/CashoutService.java @@ -0,0 +1,119 @@ +package com.gt.genti.cashout.service; + +import java.util.List; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.gt.genti.cashout.dto.response.CashoutCompletionResponseDto; +import com.gt.genti.cashout.dto.response.CashoutFindByAdminResponseDto; +import com.gt.genti.cashout.dto.response.CashoutFindByCreatorResponseDto; +import com.gt.genti.cashout.model.Cashout; +import com.gt.genti.cashout.model.CashoutStatus; +import com.gt.genti.cashout.repository.CashoutRepository; +import com.gt.genti.creator.model.Creator; +import com.gt.genti.creator.repository.CreatorRepository; +import com.gt.genti.deposit.model.Deposit; +import com.gt.genti.deposit.repository.DepositRepository; +import com.gt.genti.error.ExpectedException; +import com.gt.genti.error.ResponseCode; +import com.gt.genti.settlement.model.Settlement; +import com.gt.genti.settlement.repository.SettlementRepository; +import com.gt.genti.user.model.User; +import com.gt.genti.user.repository.UserRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@Transactional +@RequiredArgsConstructor +public class CashoutService { + private final SettlementRepository settlementRepository; + private final CashoutRepository cashoutRepository; + private final CreatorRepository creatorRepository; + private final UserRepository userRepository; + private final DepositRepository depositRepository; + + public CashoutFindByCreatorResponseDto create(Long user) { + Creator foundCreator = findCreatorByUserId(user); + List foundSettlementList = settlementRepository.findAllValidSettlementByCreatorOrderByCreatedAtDesc( + foundCreator); + + if (foundSettlementList.isEmpty()) { + throw ExpectedException.withoutLogging(ResponseCode.CannotRequestCashoutDueToSettlementsNotAvailable); + } + + Cashout cashout = new Cashout(foundCreator); + foundSettlementList.forEach(settlement -> { + settlement.setCashout(cashout); + cashout.addSettlement(settlement.getReward()); + }); + + Cashout savedCashout = cashoutRepository.save(cashout); + return mapToFindByCreatorResponseDto(savedCashout); + } + + private static CashoutFindByCreatorResponseDto mapToFindByCreatorResponseDto(Cashout savedCashout) { + return CashoutFindByCreatorResponseDto.builder() + .cashoutId(savedCashout.getId()) + .amount(savedCashout.getAmount()) + .taskCount(savedCashout.getTaskCount()) + .cashoutStatus(savedCashout.getStatus()) + .build(); + } + + private Creator findCreatorByUserId(Long userId) { + return creatorRepository.findByUserId(userId) + .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.CreatorNotFound, userId)); + } + + public Page findCashoutList(Long userId, Pageable pageable) { + Creator foundCreator = findCreatorByUserId(userId); + return cashoutRepository.findAllByCreator(foundCreator, pageable) + .map(CashoutService::mapToFindByCreatorResponseDto); + } + + public Page getAllCashout(Pageable pageable, String statusString) { + if (statusString.equals("ALL")) { + return cashoutRepository.findAll(pageable).map(CashoutFindByAdminResponseDto::of); + } else { + return cashoutRepository.findAllByStatus(pageable, CashoutStatus.valueOf(statusString)) + .map(CashoutFindByAdminResponseDto::of); + } + } + + public Page getCashoutByCreatorEmail(String email, Pageable pageable, + String statusString) { + User foundUser = userRepository.findByEmail(email) + .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.UserNotFoundByEmail, email)); + if (statusString.equals("ALL")) { + return cashoutRepository.findAllByCreatedBy(foundUser, pageable).map(CashoutFindByAdminResponseDto::of); + } else { + return cashoutRepository.findAllByCreatedByAndStatus(foundUser, pageable, + CashoutStatus.valueOf(statusString)).map(CashoutFindByAdminResponseDto::of); + } + } + + public CashoutCompletionResponseDto complete(Long cashoutId, Long userId) { + Cashout foundCashout = getCashout(cashoutId); + User foundAdminUser = userRepository.findById(userId) + .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.UserNotFound, userId)); + foundCashout.complete(foundAdminUser); + Deposit foundDeposit = depositRepository.findByCreator(foundCashout.getCreator()) + .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.DepositNotFound)); + + foundDeposit.completeCashout(foundCashout.getAmount()); + return CashoutCompletionResponseDto.builder() + .cashoutId(foundCashout.getId()) + .modifiedBy(foundCashout.getModifiedBy().getUsername()) + .status(foundCashout.getStatus()) + .build(); + } + + private Cashout getCashout(Long cashoutId) { + return cashoutRepository.findById(cashoutId) + .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.CashoutNotFound)); + } +} diff --git a/genti-api/src/main/java/com/gt/genti/settlement/api/SettlementApi.java b/genti-api/src/main/java/com/gt/genti/settlement/api/SettlementApi.java index 2a83bcad..71407f04 100644 --- a/genti-api/src/main/java/com/gt/genti/settlement/api/SettlementApi.java +++ b/genti-api/src/main/java/com/gt/genti/settlement/api/SettlementApi.java @@ -5,7 +5,7 @@ import com.gt.genti.error.ResponseCode; import com.gt.genti.response.GentiResponse.ApiResult; -import com.gt.genti.settlementandwithdraw.dto.response.SettlementAndWithdrawPageResponseDto; +import com.gt.genti.settlementandcashout.dto.response.SettlementAndCashoutPageResponseDto; import com.gt.genti.swagger.AuthorizedCreator; import com.gt.genti.swagger.EnumResponse; import com.gt.genti.swagger.EnumResponses; @@ -28,7 +28,7 @@ public interface SettlementApi { @EnumResponse(ResponseCode.CreatorNotFound), @EnumResponse(ResponseCode.DepositNotFound) }) - ResponseEntity> getMySettlements( + ResponseEntity> getMySettlements( @AuthUser Long userId, @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, diff --git a/genti-api/src/main/java/com/gt/genti/settlement/controller/SettlementController.java b/genti-api/src/main/java/com/gt/genti/settlement/controller/SettlementController.java index 31fc2c34..68064782 100644 --- a/genti-api/src/main/java/com/gt/genti/settlement/controller/SettlementController.java +++ b/genti-api/src/main/java/com/gt/genti/settlement/controller/SettlementController.java @@ -17,7 +17,7 @@ import com.gt.genti.model.Logging; import com.gt.genti.settlement.api.SettlementApi; import com.gt.genti.settlement.service.SettlementService; -import com.gt.genti.settlementandwithdraw.dto.response.SettlementAndWithdrawPageResponseDto; +import com.gt.genti.settlementandcashout.dto.response.SettlementAndCashoutPageResponseDto; import com.gt.genti.user.model.AuthUser; import io.swagger.v3.oas.annotations.Parameter; @@ -34,7 +34,7 @@ public class SettlementController implements SettlementApi { @Logging(item = LogItem.SETTLEMENT, action = LogAction.VIEW, requester = LogRequester.CREATOR) @GetMapping - public ResponseEntity> getMySettlements( + public ResponseEntity> getMySettlements( @AuthUser Long userId, @Parameter(description = "페이지 번호 (0-based)", example = "0", required = true) @RequestParam(name = "page", defaultValue = "0") @NotNull @Min(0) int page, diff --git a/genti-api/src/main/java/com/gt/genti/settlement/service/SettlementService.java b/genti-api/src/main/java/com/gt/genti/settlement/service/SettlementService.java index e1059166..c112d5ef 100644 --- a/genti-api/src/main/java/com/gt/genti/settlement/service/SettlementService.java +++ b/genti-api/src/main/java/com/gt/genti/settlement/service/SettlementService.java @@ -10,9 +10,9 @@ import com.gt.genti.deposit.repository.DepositRepository; import com.gt.genti.error.ExpectedException; import com.gt.genti.error.ResponseCode; -import com.gt.genti.settlementandwithdraw.dto.response.SettlementAndWithdrawPageResponseDto; -import com.gt.genti.settlementanwithdraw.model.SettlementAndWithdraw; -import com.gt.genti.settlementanwithdraw.repository.SettlementAndWithdrawalRepositoryCustom; +import com.gt.genti.settlementandcashout.dto.response.SettlementAndCashoutPageResponseDto; +import com.gt.genti.settlementandcashout.model.SettlementAndCashout; +import com.gt.genti.settlementandcashout.repository.SettlementAndCashoutRepositoryCustom; import lombok.RequiredArgsConstructor; @@ -22,16 +22,16 @@ public class SettlementService { private final CreatorRepository creatorRepository; private final DepositRepository depositRepository; - private final SettlementAndWithdrawalRepositoryCustom settlementAndWithdrawalRepositoryCustom; + private final SettlementAndCashoutRepositoryCustom settlementAndCashoutRepositoryCustom; - public SettlementAndWithdrawPageResponseDto getAllSettlements(Long userId, Pageable pageable) { + public SettlementAndCashoutPageResponseDto getAllSettlements(Long userId, Pageable pageable) { Creator foundCreator = findCreatorByUserId(userId); Deposit foundDeposit = findDepositByCreator(foundCreator); - return new SettlementAndWithdrawPageResponseDto(foundDeposit, - settlementAndWithdrawalRepositoryCustom.findSettlementAndWithdrawByCreatorPagination(foundCreator.getId(), + return new SettlementAndCashoutPageResponseDto(foundDeposit, + settlementAndCashoutRepositoryCustom.findSettlementAndCashoutByCreatorPagination(foundCreator.getId(), pageable) - .map(SettlementAndWithdraw::new)); + .map(SettlementAndCashout::new)); } private Deposit findDepositByCreator(Creator foundCreator) { diff --git a/genti-api/src/main/java/com/gt/genti/settlementandcashout/dto/response/SettlementAndCashoutPageResponseDto.java b/genti-api/src/main/java/com/gt/genti/settlementandcashout/dto/response/SettlementAndCashoutPageResponseDto.java new file mode 100644 index 00000000..5028ccf7 --- /dev/null +++ b/genti-api/src/main/java/com/gt/genti/settlementandcashout/dto/response/SettlementAndCashoutPageResponseDto.java @@ -0,0 +1,28 @@ +package com.gt.genti.settlementandcashout.dto.response; + +import org.springframework.data.domain.Page; + +import com.gt.genti.deposit.dto.response.DepositFindByCreatorResponseDto; +import com.gt.genti.deposit.model.Deposit; +import com.gt.genti.settlementandcashout.model.SettlementAndCashout; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Schema(name = "[SettlementAndCashout][Creator] 정산&출금내역 조회 페이지네이션 응답 dto", description = "정산&출금내역 리스트와 함께 잔액을 조회한다.") +@Getter +@NoArgsConstructor +public class SettlementAndCashoutPageResponseDto { + + @Schema(description = "잔액조회 dto") + DepositFindByCreatorResponseDto deposit; + @Schema(description = "정산&출금내역 페이지 응답") + Page settlementAndCashoutPage; + + public SettlementAndCashoutPageResponseDto(Deposit deposit, + Page settlementAndCashoutPage) { + this.deposit = new DepositFindByCreatorResponseDto(deposit); + this.settlementAndCashoutPage = settlementAndCashoutPage; + } +} diff --git a/genti-api/src/main/java/com/gt/genti/settlementandwithdraw/dto/response/SettlementAndWithdrawPageResponseDto.java b/genti-api/src/main/java/com/gt/genti/settlementandwithdraw/dto/response/SettlementAndWithdrawPageResponseDto.java deleted file mode 100644 index 6cc04d57..00000000 --- a/genti-api/src/main/java/com/gt/genti/settlementandwithdraw/dto/response/SettlementAndWithdrawPageResponseDto.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.gt.genti.settlementandwithdraw.dto.response; - -import org.springframework.data.domain.Page; - -import com.gt.genti.deposit.dto.response.DepositFindByCreatorResponseDto; -import com.gt.genti.deposit.model.Deposit; -import com.gt.genti.settlementanwithdraw.model.SettlementAndWithdraw; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Schema(name = "[Settlement][Creator] 정산&출금내역 조회 페이지네이션 응답 dto", description = "정산&출금내역 리스트와 함께 잔액을 조회한다.") -@Getter -@NoArgsConstructor -public class SettlementAndWithdrawPageResponseDto { - - @Schema(description = "잔액조회 dto") - DepositFindByCreatorResponseDto deposit; - @Schema(description = "정산&출금내역 페이지 응답") - Page settlementAndWithdrawPage; - - public SettlementAndWithdrawPageResponseDto(Deposit deposit, - Page settlementAndWithdrawPage) { - this.deposit = new DepositFindByCreatorResponseDto(deposit); - this.settlementAndWithdrawPage = settlementAndWithdrawPage; - } -} diff --git a/genti-api/src/main/java/com/gt/genti/swagger/EnumResponseGroup.java b/genti-api/src/main/java/com/gt/genti/swagger/EnumResponseGroup.java index 1936d153..86644b97 100644 --- a/genti-api/src/main/java/com/gt/genti/swagger/EnumResponseGroup.java +++ b/genti-api/src/main/java/com/gt/genti/swagger/EnumResponseGroup.java @@ -25,7 +25,7 @@ public enum EnumResponseGroup { @EnumResponse(PictureCompletedNotFound), @EnumResponse(PictureCreatedByCreatorNotFound), @EnumResponse(PictureProfileNotFound), - @EnumResponse(WithdrawRequestNotFound) + @EnumResponse(CashoutNotFound) }) NOT_FOUND, diff --git a/genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawFindByAdminResponseDto.java b/genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawFindByAdminResponseDto.java deleted file mode 100644 index a8e355ae..00000000 --- a/genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawFindByAdminResponseDto.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.gt.genti.withdraw.dto.response; - -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; -import com.gt.genti.withdrawrequest.model.WithdrawRequest; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Schema(name = "[Withdraw][Admin] 출금요청 조회 by 어드민 응답 dto") -@Getter -@NoArgsConstructor -public class WithdrawFindByAdminResponseDto { - @Schema(description = "출금요청 DB Id", example = "1") - Long withdrawRequestId; - @Schema(description = "출금요청한 유저의 이메일", example = "example@gmail.com") - String requesterEmail; - @Schema(description = "출금 금액", example = "15000") - long amount; - @Schema(description = "출금 요청에 포함된 작업 수", example = "3") - int taskCount; - @Schema(description = "출금 요청 상태", example = "출금 완료") - WithdrawRequestStatus status; - - public static WithdrawFindByAdminResponseDto of(WithdrawRequest withdrawRequest) { - return WithdrawFindByAdminResponseDto.builder() - .withdrawRequestId(withdrawRequest.getId()) - .requesterEmail(withdrawRequest.getCreator().getUser().getEmail()) - .amount(withdrawRequest.getAmount()) - .status(withdrawRequest.getStatus()) - .taskCount(withdrawRequest.getTaskCount()) - .build(); - } - - @Builder - public WithdrawFindByAdminResponseDto(Long withdrawRequestId, String requesterEmail, long amount, int taskCount, - WithdrawRequestStatus status) { - this.withdrawRequestId = withdrawRequestId; - this.requesterEmail = requesterEmail; - this.amount = amount; - this.taskCount = taskCount; - this.status = status; - } -} diff --git a/genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawFindByCreatorResponseDto.java b/genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawFindByCreatorResponseDto.java deleted file mode 100644 index 8ed3ad33..00000000 --- a/genti-api/src/main/java/com/gt/genti/withdraw/dto/response/WithdrawFindByCreatorResponseDto.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.gt.genti.withdraw.dto.response; - -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Schema(name = "[Withdraw][Creator] 출금요청 조회 by 공급자 응답 dto") -@Getter -@NoArgsConstructor -public class WithdrawFindByCreatorResponseDto { - @Schema(description = "출금요청 DB Id", example = "1") - Long withdrawRequestId; - @Schema(description = "출금 신청액", example = "15000") - Long amount; - @Schema(description = "출금된 작업 개수", example = "3") - int taskCount; - @Schema(description = "출금요청 상태") - WithdrawRequestStatus withdrawRequestStatus; - - @Builder - public WithdrawFindByCreatorResponseDto(Long withdrawRequestId, Long amount, int taskCount, - WithdrawRequestStatus withdrawRequestStatus) { - this.withdrawRequestId = withdrawRequestId; - this.amount = amount; - this.taskCount = taskCount; - this.withdrawRequestStatus = withdrawRequestStatus; - } -} diff --git a/genti-api/src/main/java/com/gt/genti/withdraw/service/WithdrawService.java b/genti-api/src/main/java/com/gt/genti/withdraw/service/WithdrawService.java deleted file mode 100644 index b00e26c1..00000000 --- a/genti-api/src/main/java/com/gt/genti/withdraw/service/WithdrawService.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.gt.genti.withdraw.service; - -import java.util.List; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.gt.genti.creator.model.Creator; -import com.gt.genti.creator.repository.CreatorRepository; -import com.gt.genti.deposit.model.Deposit; -import com.gt.genti.deposit.repository.DepositRepository; -import com.gt.genti.error.ExpectedException; -import com.gt.genti.error.ResponseCode; -import com.gt.genti.settlement.model.Settlement; -import com.gt.genti.settlement.repository.SettlementRepository; -import com.gt.genti.user.model.User; -import com.gt.genti.user.repository.UserRepository; -import com.gt.genti.withdraw.dto.response.WithdrawCompletionResponseDto; -import com.gt.genti.withdraw.dto.response.WithdrawFindByAdminResponseDto; -import com.gt.genti.withdraw.dto.response.WithdrawFindByCreatorResponseDto; -import com.gt.genti.withdrawrequest.model.WithdrawRequest; -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; -import com.gt.genti.withdrawrequest.repository.WithdrawRequestRepository; - -import lombok.RequiredArgsConstructor; - -@Service -@Transactional -@RequiredArgsConstructor -public class WithdrawService { - private final SettlementRepository settlementRepository; - private final WithdrawRequestRepository withdrawRequestRepository; - private final CreatorRepository creatorRepository; - private final UserRepository userRepository; - private final DepositRepository depositRepository; - - public WithdrawFindByCreatorResponseDto create(Long user) { - Creator foundCreator = findCreatorByUserId(user); - List foundSettlementList = settlementRepository.findAllWithdrawableByCreatorOrderByCreatedAtDesc( - foundCreator); - - if (foundSettlementList.isEmpty()) { - throw ExpectedException.withoutLogging(ResponseCode.CannotCreateWithdrawalDueToSettlementsNotAvailable); - } - - WithdrawRequest withdrawRequest = new WithdrawRequest(foundCreator); - foundSettlementList.forEach(settlement -> { - settlement.setWithdrawRequest(withdrawRequest); - withdrawRequest.addSettlement(settlement.getReward()); - }); - - WithdrawRequest savedWithdrawRequest = withdrawRequestRepository.save(withdrawRequest); - return mapToFindByCreatorResponseDto(savedWithdrawRequest); - } - - private static WithdrawFindByCreatorResponseDto mapToFindByCreatorResponseDto( - WithdrawRequest savedWithdrawRequest) { - return WithdrawFindByCreatorResponseDto.builder() - .withdrawRequestId(savedWithdrawRequest.getId()) - .amount(savedWithdrawRequest.getAmount()) - .taskCount(savedWithdrawRequest.getTaskCount()) - .withdrawRequestStatus(savedWithdrawRequest.getStatus()) - .build(); - } - - private Creator findCreatorByUserId(Long userId) { - return creatorRepository.findByUserId(userId) - .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.CreatorNotFound, userId)); - } - - public Page findWithdrawList(Long userId, Pageable pageable) { - Creator foundCreator = findCreatorByUserId(userId); - return withdrawRequestRepository.findAllByCreator(foundCreator, pageable) - .map(WithdrawService::mapToFindByCreatorResponseDto); - } - - public Page getAllWithdrawRequests(Pageable pageable, - String statusString) { - if (statusString.equals("ALL")) { - return withdrawRequestRepository.findAll(pageable).map( - WithdrawFindByAdminResponseDto::of); - } else { - return withdrawRequestRepository.findAllByStatus(pageable, WithdrawRequestStatus.valueOf(statusString)) - .map(WithdrawFindByAdminResponseDto::of); - } - } - - public Page getWithdrawListByCreatorEmail(String email, Pageable pageable, String statusString) { - User foundUser = userRepository.findByEmail(email).orElseThrow(()->ExpectedException.withLogging(ResponseCode.UserNotFoundByEmail, email)); - if (statusString.equals("ALL")) { - return withdrawRequestRepository.findAllByCreatedBy(foundUser, pageable).map( - WithdrawFindByAdminResponseDto::of); - } else { - return withdrawRequestRepository.findAllByCreatedByAndStatus(foundUser, pageable, WithdrawRequestStatus.valueOf(statusString)) - .map(WithdrawFindByAdminResponseDto::of); - } - } - - public WithdrawCompletionResponseDto complete(Long withdrawRequestId, Long userId) { - WithdrawRequest foundWR = findWithdrawRequest(withdrawRequestId); - User foundAdminUser = userRepository.findById(userId) - .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.UserNotFound, userId)); - foundWR.complete(foundAdminUser); - Deposit foundDeposit = depositRepository.findByCreator(foundWR.getCreator()) - .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.DepositNotFound)); - - foundDeposit.completeWithdraw(foundWR.getAmount()); - return WithdrawCompletionResponseDto.builder() - .withdrawRequestId(foundWR.getId()) - .modifiedBy(foundWR.getModifiedBy().getUsername()) - .status(foundWR.getStatus()) - .build(); - } - - private WithdrawRequest findWithdrawRequest(Long withdrawRequestId) { - return withdrawRequestRepository.findById(withdrawRequestId) - .orElseThrow(() -> ExpectedException.withLogging(ResponseCode.WithdrawRequestNotFound)); - } -} diff --git a/genti-common/src/main/java/com/gt/genti/constants/ErrorConstants.java b/genti-common/src/main/java/com/gt/genti/constants/ErrorConstants.java index c7bcb92a..45c55a74 100644 --- a/genti-common/src/main/java/com/gt/genti/constants/ErrorConstants.java +++ b/genti-common/src/main/java/com/gt/genti/constants/ErrorConstants.java @@ -10,7 +10,7 @@ public class ErrorConstants { private static final String PICTURE = "PICTURE"; private static final String DEPOSIT = "DEPOSIT"; - private static final String WITHDRAW = "WITHDRAW"; + private static final String CASHOUT = "CASHOUT"; private static final String UPLOAD = "UPLOAD"; private static final String DISCORD = "DISCORD"; @@ -92,9 +92,9 @@ private static String CODE(String type, int seq) { public static final String HandlerMethodValidation = CODE(VALIDATION, 1); public static final String HttpMessageNotReadable = CODE(VALIDATION, 2); - public static final String CannotCreateWithdrawalDueToSettlementsNotAvailable = CODE(WITHDRAW, 1); - public static final String WithdrawRequestNotFound = CODE(WITHDRAW, 2); - public static final String NotEnoughBalance = CODE(WITHDRAW, 3); + public static final String CannotRequestCashoutDueToSettlementsNotAvailable = CODE(CASHOUT, 1); + public static final String CashoutNotFound = CODE(CASHOUT, 2); + public static final String NotEnoughBalance = CODE(CASHOUT, 3); public static final String OauthProviderNotAllowed = CODE(OAUTH, 1); public static final String AppleOauthIdTokenIncorrect = CODE(OAUTH, 2); diff --git a/genti-common/src/main/java/com/gt/genti/error/ResponseCode.java b/genti-common/src/main/java/com/gt/genti/error/ResponseCode.java index f7897724..8b44cbb3 100644 --- a/genti-common/src/main/java/com/gt/genti/error/ResponseCode.java +++ b/genti-common/src/main/java/com/gt/genti/error/ResponseCode.java @@ -182,12 +182,12 @@ public enum ResponseCode { NotEnoughBalance(ErrorConstants.NotEnoughBalance, NOT_ACCEPTABLE, false, "해당 공급자의 출금가능 잔액이 부족하여 요청을 완료할 수 없습니다."), /** - * WithdrawRequest && Settlement + * Cashout && Settlement */ - CannotCreateWithdrawalDueToSettlementsNotAvailable( - ErrorConstants.CannotCreateWithdrawalDueToSettlementsNotAvailable, BAD_REQUEST, false, + CannotRequestCashoutDueToSettlementsNotAvailable( + ErrorConstants.CannotRequestCashoutDueToSettlementsNotAvailable, BAD_REQUEST, false, "출금 가능한 정산 내역이 없습니다."), - WithdrawRequestNotFound(ErrorConstants.WithdrawRequestNotFound, NOT_FOUND, false, + CashoutNotFound(ErrorConstants.CashoutNotFound, NOT_FOUND, false, "해당 출금 요청을 찾을 수 없습니다."), HttpMessageNotReadable(ErrorConstants.HttpMessageNotReadable, BAD_REQUEST, false, "잘못된 입력 : %s"), FileTypeNotProvided(ErrorConstants.FileTypeNotProvided, BAD_REQUEST, false, "파일 형식이 주어지지 않았습니다."), diff --git a/genti-domain/src/main/java/com/gt/genti/withdrawrequest/model/WithdrawRequest.java b/genti-domain/src/main/java/com/gt/genti/cashout/model/Cashout.java similarity index 68% rename from genti-domain/src/main/java/com/gt/genti/withdrawrequest/model/WithdrawRequest.java rename to genti-domain/src/main/java/com/gt/genti/cashout/model/Cashout.java index 8be6085e..2b6f2bf3 100644 --- a/genti-domain/src/main/java/com/gt/genti/withdrawrequest/model/WithdrawRequest.java +++ b/genti-domain/src/main/java/com/gt/genti/cashout/model/Cashout.java @@ -1,8 +1,8 @@ -package com.gt.genti.withdrawrequest.model; +package com.gt.genti.cashout.model; import com.gt.genti.common.baseentity.model.BaseEntity; +import com.gt.genti.common.converter.CashoutStatusConverter; import com.gt.genti.creator.model.Creator; -import com.gt.genti.common.converter.WithdrawRequestStatusConverter; import com.gt.genti.user.model.User; import jakarta.persistence.Column; @@ -19,11 +19,11 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@Table(name = "withdraw_request") +@Table(name = "cashout") @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class WithdrawRequest extends BaseEntity { +public class Cashout extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id; @@ -38,27 +38,26 @@ public class WithdrawRequest extends BaseEntity { @Column(name = "task_count", nullable = false) Integer taskCount; - @Convert(converter = WithdrawRequestStatusConverter.class) + @Convert(converter = CashoutStatusConverter.class) @Column(name = "status", nullable = false) - WithdrawRequestStatus status; - + CashoutStatus status; @PrePersist - public void prePersist(){ - if(this.amount == null){ + public void prePersist() { + if (this.amount == null) { this.amount = 0L; } - if(this.taskCount == null){ + if (this.taskCount == null) { this.taskCount = 0; } - if(this.status == null){ - this.status = WithdrawRequestStatus.IN_PROGRESS; + if (this.status == null) { + this.status = CashoutStatus.IN_PROGRESS; } } - public WithdrawRequest(Creator creator) { + public Cashout(Creator creator) { this.creator = creator; - this.status = WithdrawRequestStatus.IN_PROGRESS; + this.status = CashoutStatus.IN_PROGRESS; } public void addSettlement(long amount) { @@ -68,6 +67,6 @@ public void addSettlement(long amount) { public void complete(User modifiedBy) { this.setModifiedBy(modifiedBy); - this.status = WithdrawRequestStatus.COMPLETED; + this.status = CashoutStatus.COMPLETED; } } diff --git a/genti-domain/src/main/java/com/gt/genti/withdrawrequest/model/WithdrawRequestStatus.java b/genti-domain/src/main/java/com/gt/genti/cashout/model/CashoutStatus.java similarity index 70% rename from genti-domain/src/main/java/com/gt/genti/withdrawrequest/model/WithdrawRequestStatus.java rename to genti-domain/src/main/java/com/gt/genti/cashout/model/CashoutStatus.java index 4b4dba5c..35ab7c56 100644 --- a/genti-domain/src/main/java/com/gt/genti/withdrawrequest/model/WithdrawRequestStatus.java +++ b/genti-domain/src/main/java/com/gt/genti/cashout/model/CashoutStatus.java @@ -1,4 +1,4 @@ -package com.gt.genti.withdrawrequest.model; +package com.gt.genti.cashout.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.gt.genti.common.ConvertableEnum; @@ -9,7 +9,7 @@ @Getter @RequiredArgsConstructor -public enum WithdrawRequestStatus implements ConvertableEnum { +public enum CashoutStatus implements ConvertableEnum { AVAILABLE("AVAILABLE", "출금 가능"), IN_PROGRESS("IN_PROGRESS", "출금 진행중"), COMPLETED("COMPLETED", "출금 완료"), @@ -19,8 +19,8 @@ public enum WithdrawRequestStatus implements ConvertableEnum { private final String response; @JsonCreator - public static WithdrawRequestStatus fromString(String value) { - return EnumUtil.stringToEnum(WithdrawRequestStatus.class, value); + public static CashoutStatus fromString(String value) { + return EnumUtil.stringToEnum(CashoutStatus.class, value); } @Override diff --git a/genti-domain/src/main/java/com/gt/genti/cashout/repository/CashoutRepository.java b/genti-domain/src/main/java/com/gt/genti/cashout/repository/CashoutRepository.java new file mode 100644 index 00000000..a569146a --- /dev/null +++ b/genti-domain/src/main/java/com/gt/genti/cashout/repository/CashoutRepository.java @@ -0,0 +1,23 @@ +package com.gt.genti.cashout.repository; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.gt.genti.cashout.model.Cashout; +import com.gt.genti.cashout.model.CashoutStatus; +import com.gt.genti.creator.model.Creator; +import com.gt.genti.user.model.User; + +@Repository +public interface CashoutRepository extends JpaRepository { + Page findAllByCreator(Creator creator, Pageable pageable); + + Page findAllByStatus(Pageable pageable, CashoutStatus status); + + Page findAllByCreatedBy(User user, Pageable pageable); + + Page findAllByCreatedByAndStatus(User user, Pageable pageable, CashoutStatus status); + +} diff --git a/genti-domain/src/main/java/com/gt/genti/common/converter/CashoutStatusConverter.java b/genti-domain/src/main/java/com/gt/genti/common/converter/CashoutStatusConverter.java new file mode 100644 index 00000000..2a9a2f09 --- /dev/null +++ b/genti-domain/src/main/java/com/gt/genti/common/converter/CashoutStatusConverter.java @@ -0,0 +1,14 @@ +package com.gt.genti.common.converter; + +import com.gt.genti.cashout.model.CashoutStatus; + +import jakarta.persistence.Converter; + +@Converter +public class CashoutStatusConverter extends DefaultEnumDBConverter { + + public CashoutStatusConverter() { + super(CashoutStatus.class); + } + +} \ No newline at end of file diff --git a/genti-domain/src/main/java/com/gt/genti/common/converter/WithdrawRequestStatusConverter.java b/genti-domain/src/main/java/com/gt/genti/common/converter/WithdrawRequestStatusConverter.java deleted file mode 100644 index 8bf06aee..00000000 --- a/genti-domain/src/main/java/com/gt/genti/common/converter/WithdrawRequestStatusConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.gt.genti.common.converter; - -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; - -import jakarta.persistence.Converter; - -@Converter -public class WithdrawRequestStatusConverter extends DefaultEnumDBConverter { - - public WithdrawRequestStatusConverter() { - super(WithdrawRequestStatus.class); - } - -} \ No newline at end of file diff --git a/genti-domain/src/main/java/com/gt/genti/deposit/model/Deposit.java b/genti-domain/src/main/java/com/gt/genti/deposit/model/Deposit.java index 54b9789e..cea74394 100644 --- a/genti-domain/src/main/java/com/gt/genti/deposit/model/Deposit.java +++ b/genti-domain/src/main/java/com/gt/genti/deposit/model/Deposit.java @@ -1,9 +1,9 @@ package com.gt.genti.deposit.model; import com.gt.genti.common.basetimeentity.model.BaseTimeEntity; -import com.gt.genti.user.model.User; import com.gt.genti.error.ExpectedException; import com.gt.genti.error.ResponseCode; +import com.gt.genti.user.model.User; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -59,7 +59,7 @@ private void addInternal(Long amount) { this.totalAmount += amount; } - public void completeWithdraw(Long amount) { + public void completeCashout(Long amount) { if (this.nowAmount < amount) { throw ExpectedException.withLogging(ResponseCode.NotEnoughBalance); } diff --git a/genti-domain/src/main/java/com/gt/genti/settlement/model/Settlement.java b/genti-domain/src/main/java/com/gt/genti/settlement/model/Settlement.java index 69bbabcc..36423e2b 100644 --- a/genti-domain/src/main/java/com/gt/genti/settlement/model/Settlement.java +++ b/genti-domain/src/main/java/com/gt/genti/settlement/model/Settlement.java @@ -1,6 +1,6 @@ package com.gt.genti.settlement.model; -import com.gt.genti.withdrawrequest.model.WithdrawRequest; +import com.gt.genti.cashout.model.Cashout; import com.gt.genti.common.basetimeentity.model.BaseTimeEntity; import com.gt.genti.picturegenerateresponse.model.PictureGenerateResponse; @@ -40,8 +40,8 @@ public class Settlement extends BaseTimeEntity { @Setter @ManyToOne - @JoinColumn(name = "withdraw_request_id") - WithdrawRequest withdrawRequest; + @JoinColumn(name = "cashout_id") + Cashout cashout; @Builder public Settlement(PictureGenerateResponse pictureGenerateResponse, Long elapsedMinutes, Long reward) { diff --git a/genti-domain/src/main/java/com/gt/genti/settlement/model/SettlementStatus.java b/genti-domain/src/main/java/com/gt/genti/settlement/model/SettlementStatus.java index c42b2f60..108ffacb 100644 --- a/genti-domain/src/main/java/com/gt/genti/settlement/model/SettlementStatus.java +++ b/genti-domain/src/main/java/com/gt/genti/settlement/model/SettlementStatus.java @@ -10,9 +10,9 @@ @Getter @RequiredArgsConstructor public enum SettlementStatus implements ConvertableEnum { - WITHDRAWN_COMPLETED("WITHDRAWN_COMPLETED", "출금 완료"), + CASHOUT_COMPLETED("CASHOUT_COMPLETED", "출금 완료"), CREATED("CREATED", "출금 가능"), - WITHDRAWN_IN_PROGRESS("WITHDRAWN_IN_PROGRESS", "출금 진행 중"), + CASHOUT_IN_PROGRESS("CASHOUT_IN_PROGRESS", "출금 진행 중"), CANCELLED("CANCELLED", "취소됨"); private final String stringValue; diff --git a/genti-domain/src/main/java/com/gt/genti/settlement/repository/SettlementRepository.java b/genti-domain/src/main/java/com/gt/genti/settlement/repository/SettlementRepository.java index 3fdce2fe..69e7f052 100644 --- a/genti-domain/src/main/java/com/gt/genti/settlement/repository/SettlementRepository.java +++ b/genti-domain/src/main/java/com/gt/genti/settlement/repository/SettlementRepository.java @@ -16,10 +16,10 @@ public interface SettlementRepository extends JpaRepository { @Query("select s " + "from Settlement s " + "where s.pictureGenerateResponse.creator = :creator " - + "and s.withdrawRequest is null " + + "and s.cashout is null " + "and s.pictureGenerateResponse.status = com.gt.genti.picturegenerateresponse.model.PictureGenerateResponseStatus.COMPLETED " + "order by s.createdAt desc ") - List findAllWithdrawableByCreatorOrderByCreatedAtDesc( + List findAllValidSettlementByCreatorOrderByCreatedAtDesc( @Param(value = "creator") Creator creator); diff --git a/genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/model/SettlementAndWithdraw.java b/genti-domain/src/main/java/com/gt/genti/settlementandcashout/model/SettlementAndCashout.java similarity index 73% rename from genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/model/SettlementAndWithdraw.java rename to genti-domain/src/main/java/com/gt/genti/settlementandcashout/model/SettlementAndCashout.java index 21dbff86..cd3c453f 100644 --- a/genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/model/SettlementAndWithdraw.java +++ b/genti-domain/src/main/java/com/gt/genti/settlementandcashout/model/SettlementAndCashout.java @@ -1,19 +1,19 @@ -package com.gt.genti.settlementanwithdraw.model; +package com.gt.genti.settlementandcashout.model; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.Map; -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; +import com.gt.genti.cashout.model.CashoutStatus; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.NoArgsConstructor; -@Schema(name = "[Settlement&Withdraw][Creator] 정산&출금내역 응답 dto") +@Schema(name = "[SettlementAndCashout][Creator] 정산&출금내역 응답 dto") @Getter @NoArgsConstructor -public class SettlementAndWithdraw { +public class SettlementAndCashout { @Schema(description = "정산 혹은 출금내역 DB Id", example = "1") Long id; @Schema(description = "정산 or 출금내역 구분, true : 정산내역, false : 출금내역") @@ -29,17 +29,17 @@ public class SettlementAndWithdraw { "[정산내역&출금내역]출금 완료된 경우 : COMPLETED " + "
" + "[출금내역] 출금 거절된 경우(현재 사용X) : REJECTED " ) - WithdrawRequestStatus status; + CashoutStatus status; - public SettlementAndWithdraw(Map attributes) { + public SettlementAndCashout(Map attributes) { this.id = (Long)attributes.get("id"); this.isSettlement = (Boolean)attributes.get("isSettlement"); this.amount = (Long)attributes.get("amount"); this.createdAt = (LocalDateTime)attributes.get("createdAt"); - this.status = WithdrawRequestStatus.valueOf((String)attributes.get("status")); + this.status = CashoutStatus.valueOf((String)attributes.get("status")); } - public SettlementAndWithdraw(Object[] o) { + public SettlementAndCashout(Object[] o) { this.id = (Long)o[0]; if ((Long)o[1] == 1L) { this.isSettlement = true; @@ -48,6 +48,6 @@ public SettlementAndWithdraw(Object[] o) { } this.amount = (Long)o[2]; this.createdAt = ((Timestamp)o[3]).toLocalDateTime(); - this.status = WithdrawRequestStatus.valueOf((String)o[4]); + this.status = CashoutStatus.valueOf((String)o[4]); } } diff --git a/genti-domain/src/main/java/com/gt/genti/settlementandcashout/repository/SettlementAndCashoutRepositoryCustom.java b/genti-domain/src/main/java/com/gt/genti/settlementandcashout/repository/SettlementAndCashoutRepositoryCustom.java new file mode 100644 index 00000000..60b7f9aa --- /dev/null +++ b/genti-domain/src/main/java/com/gt/genti/settlementandcashout/repository/SettlementAndCashoutRepositoryCustom.java @@ -0,0 +1,8 @@ +package com.gt.genti.settlementandcashout.repository; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface SettlementAndCashoutRepositoryCustom { + Page findSettlementAndCashoutByCreatorPagination(Long creatorId, Pageable pageable); +} diff --git a/genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/repository/SettlementAndWithdrawalRepositoryCustomImpl.java b/genti-domain/src/main/java/com/gt/genti/settlementandcashout/repository/SettlementAndCashoutRepositoryCustomImpl.java similarity index 70% rename from genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/repository/SettlementAndWithdrawalRepositoryCustomImpl.java rename to genti-domain/src/main/java/com/gt/genti/settlementandcashout/repository/SettlementAndCashoutRepositoryCustomImpl.java index f7986c35..e46e89e1 100644 --- a/genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/repository/SettlementAndWithdrawalRepositoryCustomImpl.java +++ b/genti-domain/src/main/java/com/gt/genti/settlementandcashout/repository/SettlementAndCashoutRepositoryCustomImpl.java @@ -1,4 +1,4 @@ -package com.gt.genti.settlementanwithdraw.repository; +package com.gt.genti.settlementandcashout.repository; import java.util.List; @@ -12,23 +12,23 @@ import jakarta.persistence.Query; @Repository -public class SettlementAndWithdrawalRepositoryCustomImpl implements SettlementAndWithdrawalRepositoryCustom { +public class SettlementAndCashoutRepositoryCustomImpl implements SettlementAndCashoutRepositoryCustom { @PersistenceContext private EntityManager entityManager; @Override - public Page findSettlementAndWithdrawByCreatorPagination(Long creatorId, Pageable pageable) { + public Page findSettlementAndCashoutByCreatorPagination(Long creatorId, Pageable pageable) { String queryStr = "(SELECT s.id as id , true as isSettlement, s.reward as amount, s.created_at as createdAt, " + - "CASE WHEN wr.id IS NULL THEN 'AVAILABLE' ELSE wr.status END as status " + + "CASE WHEN c.id IS NULL THEN 'AVAILABLE' ELSE c.status END as status " + "FROM settlement s " + - "LEFT OUTER JOIN withdraw_request wr ON wr.creator_id = :creatorId " + "LEFT OUTER JOIN cashout c ON c.creator_id = :creatorId " + "LEFT JOIN picture_generate_response ON s.picture_generate_response_id = picture_generate_response.id " + "UNION ALL " + "SELECT w.id as id , false as isSettlement, w.amount as amount, w.created_at as createdAt, w.status " + - "FROM withdraw_request w " + - "WHERE w.creator_id = :creatorId) " + + "FROM cashout c " + + "WHERE c.creator_id = :creatorId) " + "ORDER BY createdAt DESC"; Query query = entityManager.createNativeQuery(queryStr); diff --git a/genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/repository/SettlementAndWithdrawalRepositoryCustom.java b/genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/repository/SettlementAndWithdrawalRepositoryCustom.java deleted file mode 100644 index ace92c31..00000000 --- a/genti-domain/src/main/java/com/gt/genti/settlementanwithdraw/repository/SettlementAndWithdrawalRepositoryCustom.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.gt.genti.settlementanwithdraw.repository; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; - -public interface SettlementAndWithdrawalRepositoryCustom { - Page findSettlementAndWithdrawByCreatorPagination(Long creatorId, Pageable pageable); -} diff --git a/genti-domain/src/main/java/com/gt/genti/withdrawrequest/repository/WithdrawRequestRepository.java b/genti-domain/src/main/java/com/gt/genti/withdrawrequest/repository/WithdrawRequestRepository.java deleted file mode 100644 index 2559ca27..00000000 --- a/genti-domain/src/main/java/com/gt/genti/withdrawrequest/repository/WithdrawRequestRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gt.genti.withdrawrequest.repository; - -import com.gt.genti.user.model.User; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.gt.genti.creator.model.Creator; -import com.gt.genti.withdrawrequest.model.WithdrawRequest; -import com.gt.genti.withdrawrequest.model.WithdrawRequestStatus; - -@Repository -public interface WithdrawRequestRepository extends JpaRepository { - Page findAllByCreator(Creator creator, Pageable pageable); - - Page findAllByStatus(Pageable pageable, WithdrawRequestStatus status); - - Page findAllByCreatedBy(User user, Pageable pageable); - - Page findAllByCreatedByAndStatus(User user, Pageable pageable, WithdrawRequestStatus status); - -}