-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 내정보 조회 api에 provider field를 추가한다. * feat: 특정 기간의 장부를 반환하는 메소드를 추가한다. * feat: LedgerReader의 공통 코드를 메소드 분리한다. * feat: LedgerControllerV2, RequestV2를 추가한다.
- Loading branch information
Showing
7 changed files
with
265 additions
and
25 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/main/java/com/moneymong/domain/ledger/api/LedgerControllerV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.moneymong.domain.ledger.api; | ||
|
||
import com.moneymong.domain.ledger.api.request.*; | ||
import com.moneymong.domain.ledger.api.response.ledger.LedgerInfoView; | ||
import com.moneymong.domain.ledger.service.reader.LedgerReader; | ||
import com.moneymong.global.security.token.dto.jwt.JwtAuthentication; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springdoc.core.annotations.ParameterObject; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@Tag(name = "5. [장부 V2]") | ||
@RequestMapping("/api/v2/ledger") | ||
@RestController | ||
@RequiredArgsConstructor | ||
public class LedgerControllerV2 { | ||
private final LedgerReader ledgerReader; | ||
|
||
@Operation(summary = " 장부 내역 조회 API") | ||
@GetMapping("/{id}") | ||
public LedgerInfoView search( | ||
@AuthenticationPrincipal JwtAuthentication user, | ||
@PathVariable("id") final Long ledgerId, | ||
@ParameterObject @Valid final SearchLedgerRequestV2 searchLedgerRequest | ||
) { | ||
return ledgerReader.searchLedgersByPeriod( | ||
user.getId(), | ||
ledgerId, | ||
searchLedgerRequest.getStartYear(), | ||
searchLedgerRequest.getStartMonth(), | ||
searchLedgerRequest.getEndYear(), | ||
searchLedgerRequest.getEndMonth(), | ||
searchLedgerRequest.getPage(), | ||
searchLedgerRequest.getLimit() | ||
); | ||
} | ||
|
||
@Operation(summary = "장부 내역 필터별 조회 API") | ||
@GetMapping("/{id}/filter") | ||
public LedgerInfoView searchByFilter( | ||
@AuthenticationPrincipal JwtAuthentication user, | ||
@PathVariable("id") final Long ledgerId, | ||
@ParameterObject @Valid final SearchLedgerFilterRequestV2 searchLedgerFilterRequest | ||
) { | ||
return ledgerReader.searchLedgersByPeriodAndFundType( | ||
user.getId(), | ||
ledgerId, | ||
searchLedgerFilterRequest.getStartYear(), | ||
searchLedgerFilterRequest.getStartMonth(), | ||
searchLedgerFilterRequest.getEndYear(), | ||
searchLedgerFilterRequest.getEndMonth(), | ||
searchLedgerFilterRequest.getPage(), | ||
searchLedgerFilterRequest.getLimit(), | ||
searchLedgerFilterRequest.getFundType() | ||
); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/moneymong/domain/ledger/api/request/SearchLedgerFilterRequestV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.moneymong.domain.ledger.api.request; | ||
|
||
import com.moneymong.domain.ledger.entity.enums.FundType; | ||
import jakarta.validation.constraints.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SearchLedgerFilterRequestV2 { | ||
@Positive(message = "startYear를 입력해주세요.") | ||
private int startYear; | ||
|
||
@Positive(message = "endYear를 입력해주세요.") | ||
private int endYear; | ||
|
||
@Min(value = 1, message = "month 1 이상 입력해주세요.") | ||
@Max(value = 12, message = "month 12 이하 입력해주세요.") | ||
private int startMonth; | ||
|
||
@Min(value = 1, message = "month 1 이상 입력해주세요.") | ||
@Max(value = 12, message = "month 12 이하 입력해주세요.") | ||
private int endMonth; | ||
|
||
@PositiveOrZero(message = "page 0이상 입력해주세요.") | ||
private int page; | ||
|
||
@Max(value= 300, message = "limit를 입력해주세요.") | ||
private int limit; | ||
|
||
@NotNull(message = "fundType(INCOME, EXPENSE)를 입력해주세요.") | ||
private FundType fundType; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/moneymong/domain/ledger/api/request/SearchLedgerRequestV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.moneymong.domain.ledger.api.request; | ||
|
||
import jakarta.validation.constraints.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SearchLedgerRequestV2 { | ||
|
||
@Positive(message = "startYear를 입력해주세요.") | ||
private int startYear; | ||
|
||
@Positive(message = "endYear를 입력해주세요.") | ||
private int endYear; | ||
|
||
@Min(value = 1, message = "month 1 이상 입력해주세요.") | ||
@Max(value = 12, message = "month 12 이하 입력해주세요.") | ||
private int startMonth; | ||
|
||
@Min(value = 1, message = "month 1 이상 입력해주세요.") | ||
@Max(value = 12, message = "month 12 이하 입력해주세요.") | ||
private int endMonth; | ||
|
||
@PositiveOrZero(message = "page 0이상 입력해주세요.") | ||
private int page; | ||
|
||
@Max(value= 300, message = "limit를 입력해주세요.") | ||
private int limit; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters