Skip to content

Commit

Permalink
refactor: refactor sector request code
Browse files Browse the repository at this point in the history
  • Loading branch information
songyi00 committed Mar 1, 2024
1 parent 4959b96 commit 1a56d69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public List<SectorRatioResponse> analyzeSectorRatio(final SectorRatioRequest req
return SectorRatioResponse.fromMap(sectorInfoMap);
}

public UpcomingDividendResponse getUpcomingDividendStocks(final String sector, final int pageNumber, final int pageSize) {
public UpcomingDividendResponse getUpcomingDividendStocks(final Sector sector, final int pageNumber, final int pageSize) {
return UpcomingDividendResponse.of(
stockRepository.findUpcomingDividendStock(Sector.fromValue(sector), pageNumber, pageSize)
stockRepository.findUpcomingDividendStock(sector, pageNumber, pageSize)
.stream()
.map(stockDividend -> SingleUpcomingDividendResponse.of(
stockDividend.stock(),
Expand All @@ -117,9 +117,9 @@ public UpcomingDividendResponse getUpcomingDividendStocks(final String sector, f
);
}

public StockDividendYieldResponse getBiggestDividendStocks(final String sector, final int pageNumber, final int pageSize) {
public StockDividendYieldResponse getBiggestDividendStocks(final Sector sector, final int pageNumber, final int pageSize) {
return StockDividendYieldResponse.of(
stockRepository.findBiggestDividendYieldStock(InstantProvider.getLastYear(), Sector.fromValue(sector), pageNumber, pageSize)
stockRepository.findBiggestDividendYieldStock(InstantProvider.getLastYear(), sector, pageNumber, pageSize)
.stream()
.map(stockDividendYield -> SingleStockDividendYieldResponse.of(
stockDividendYield.stock(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import nexters.payout.apiserver.stock.application.StockQueryService;
import nexters.payout.apiserver.stock.application.dto.request.SectorRatioRequest;
import nexters.payout.apiserver.stock.application.dto.response.*;
import nexters.payout.domain.stock.domain.Sector;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand Down Expand Up @@ -45,7 +46,7 @@ public ResponseEntity<List<SectorRatioResponse>> findSectorRatios(

@GetMapping("/ex-dividend-dates/upcoming")
public ResponseEntity<UpcomingDividendResponse> getUpComingDividendStocks(
@RequestParam @NotEmpty final String sector,
@RequestParam @NotEmpty final Sector sector,
@RequestParam @NotNull final Integer pageNumber,
@RequestParam @NotNull final Integer pageSize
) {
Expand All @@ -54,7 +55,7 @@ public ResponseEntity<UpcomingDividendResponse> getUpComingDividendStocks(

@GetMapping("/dividend-yields/highest")
public ResponseEntity<StockDividendYieldResponse> getBiggestDividendYieldStocks(
@RequestParam @NotEmpty final String sector,
@RequestParam @NotEmpty final Sector sector,
@RequestParam @NotNull final Integer pageNumber,
@RequestParam @NotNull final Integer pageSize
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import nexters.payout.apiserver.stock.application.dto.request.SectorRatioRequest;
import nexters.payout.apiserver.stock.application.dto.response.*;
import nexters.payout.core.exception.ErrorResponse;
import nexters.payout.domain.stock.domain.Sector;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -85,7 +86,7 @@ ResponseEntity<List<SectorRatioResponse>> findSectorRatios(
@Operation(summary = "배당락일이 다가오는 주식 리스트")
ResponseEntity<UpcomingDividendResponse> getUpComingDividendStocks(
@Parameter(description = "sector value", example = "TECHNOLOGY", required = true)
@RequestParam @NotEmpty final String sector,
@RequestParam @NotEmpty final Sector sector,
@Parameter(description = "page number(start with 1) for pagination", example = "1", required = true)
@RequestParam @NotNull final Integer pageNumber,
@Parameter(description = "page size for pagination", example = "20", required = true)
Expand All @@ -102,7 +103,7 @@ ResponseEntity<UpcomingDividendResponse> getUpComingDividendStocks(
@Operation(summary = "배당수익률이 큰 주식 리스트")
ResponseEntity<StockDividendYieldResponse> getBiggestDividendYieldStocks(
@Parameter(description = "sector value", example = "TECHNOLOGY", required = true)
@RequestParam @NotEmpty final String sector,
@RequestParam @NotEmpty final Sector sector,
@Parameter(description = "page number(start with 1) for pagination", example = "1", required = true)
@RequestParam @NotNull final Integer pageNumber,
@Parameter(description = "page size for pagination", example = "20", required = true)
Expand Down

0 comments on commit 1a56d69

Please sign in to comment.