Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import naughty.tuzamate.domain.stock.service.KrxService;
import naughty.tuzamate.domain.stock.service.NasdaqService;
import naughty.tuzamate.domain.stock.service.compare.async.AsyncKrxService;
import naughty.tuzamate.domain.stock.service.compare.async.AsyncNasdaqService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
Expand All @@ -19,8 +19,8 @@
@ConditionalOnProperty(name = "hantu.stock.schedule.enabled", havingValue = "true")
public class HantuStockApiRefreshScheduler {

private final KrxService krxService;
private final NasdaqService nasdaqService;
private final AsyncKrxService krxService;
private final AsyncNasdaqService asyncNasdaqService;

@Scheduled(cron = "0 39 13 * * *")
public void refreshStockData() {
Expand All @@ -32,7 +32,7 @@ public void refreshStockData() {
log.info("Hantu Krx API 데이터 갱신 완료");

log.info("Hantu Nasdaq API 데이터 갱신 시작");
nasdaqService.saveNasdaqStocksInfo();
asyncNasdaqService.saveNasdaqStocksInfo();
log.info("Hantu Nasdaq API 데이터 갱신 완료");
log.info("Hantu Stock API 데이터 갱신 완료");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import naughty.tuzamate.domain.stock.dto.krx.KrxDto;
import naughty.tuzamate.domain.stock.dto.nasdaq.NasdaqDto;
import naughty.tuzamate.domain.stock.error.StockErrorCode;
import naughty.tuzamate.domain.stock.service.*;
import naughty.tuzamate.domain.stock.service.common.KrxFinancialService;
import naughty.tuzamate.domain.stock.service.common.KrxInquireService;
import naughty.tuzamate.domain.stock.service.common.StockCodeService;
import naughty.tuzamate.domain.stock.service.common.StockInfoService;
import naughty.tuzamate.domain.stock.service.compare.async.AsyncKrxService;
import naughty.tuzamate.domain.stock.service.compare.async.AsyncNasdaqService;
import naughty.tuzamate.domain.stock.service.compare.async.AsyncNasdaqStockFetcher;
import naughty.tuzamate.global.apiPayload.CustomResponse;
import naughty.tuzamate.global.success.GeneralSuccessCode;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -24,8 +30,8 @@
public class StockController {

private final StockCodeService stockCodeService;
private final NasdaqService nasdaqService;
private final KrxService krxService;
private final AsyncNasdaqService asyncNasdaqService;
private final AsyncKrxService krxService;
private final KrxInquireService krxInquireService;
private final KrxFinancialService krxFinancialService;
private final StockInfoService stockInfoService;
Expand Down Expand Up @@ -57,7 +63,7 @@ public NasdaqDto.NasdaqInfoDto getNasdaqStockInfo(@PathVariable("nasdaqStockCode
description = "나스닥 주식 전체 정보를 가져오고 저장합니다. 주식 코드를 입력하지 않아도 됩니다.")
public CustomResponse<?> getAllNasdaqStockInfo() {

nasdaqService.saveNasdaqStocksInfo();
asyncNasdaqService.saveNasdaqStocksInfo();
return CustomResponse.onSuccess(GeneralSuccessCode.CREATED, "나스닥 주식 전체 정보 저장 완료");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package naughty.tuzamate.domain.stock.service;
package naughty.tuzamate.domain.stock.service.common;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package naughty.tuzamate.domain.stock.service;
package naughty.tuzamate.domain.stock.service.common;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package naughty.tuzamate.domain.stock.service;
package naughty.tuzamate.domain.stock.service.common;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package naughty.tuzamate.domain.stock.service;
package naughty.tuzamate.domain.stock.service.common;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
package naughty.tuzamate.domain.stock.service;
package naughty.tuzamate.domain.stock.service.compare.async;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import naughty.tuzamate.domain.stock.dto.StockInfoDto;
import naughty.tuzamate.domain.stock.dto.krx.KrxDto;
import naughty.tuzamate.domain.stock.entity.KrxStockInfo;
import naughty.tuzamate.domain.stock.entity.StockCode;
import naughty.tuzamate.domain.stock.repository.KrxStockInfoRepository;
import naughty.tuzamate.domain.stock.repository.code.StockCodeRepository;
import naughty.tuzamate.domain.stock.strategy.FilterStrategy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
@Slf4j
public class KrxService {
public class AsyncKrxService {

private final StockCodeRepository stockCodeRepository;
private final KrxStockInfoRepository krxStockInfoRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package naughty.tuzamate.domain.stock.service;
package naughty.tuzamate.domain.stock.service.compare.async;

import com.google.common.util.concurrent.RateLimiter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import naughty.tuzamate.domain.stock.dto.StockInfoDto;
import naughty.tuzamate.domain.stock.dto.krx.KrxDto;
import naughty.tuzamate.domain.stock.entity.KrxStockInfo;
import naughty.tuzamate.domain.stock.service.common.KrxFinancialService;
import naughty.tuzamate.domain.stock.service.common.KrxInquireService;
import naughty.tuzamate.domain.stock.service.common.StockInfoService;
import naughty.tuzamate.domain.stock.strategy.FilterStrategy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
package naughty.tuzamate.domain.stock.service;
package naughty.tuzamate.domain.stock.service.compare.async;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import naughty.tuzamate.auth.hantu.service.HantuApiTokenService;
import naughty.tuzamate.domain.stock.dto.StockInfoDto;
import naughty.tuzamate.domain.stock.dto.nasdaq.NasdaqDto;
import naughty.tuzamate.domain.stock.entity.NasdaqStockCode;
import naughty.tuzamate.domain.stock.entity.NasdaqStockInfo;
import naughty.tuzamate.domain.stock.repository.NasdaqStockInfoRepository;
import naughty.tuzamate.domain.stock.repository.code.NasdaqCodeRepository;
import naughty.tuzamate.domain.stock.strategy.FilterStrategy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
@Slf4j
public class NasdaqService {
public class AsyncNasdaqService {

private final NasdaqCodeRepository nasdaqCodeRepository;
private final NasdaqStockInfoRepository nasdaqStockInfoRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package naughty.tuzamate.domain.stock.service;
package naughty.tuzamate.domain.stock.service.compare.async;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -9,6 +9,7 @@
import naughty.tuzamate.domain.stock.dto.StockInfoDto;
import naughty.tuzamate.domain.stock.dto.nasdaq.NasdaqDto;
import naughty.tuzamate.domain.stock.entity.NasdaqStockInfo;
import naughty.tuzamate.domain.stock.service.common.StockInfoService;
import naughty.tuzamate.domain.stock.strategy.FilterStrategy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
Expand Down
Loading