-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
실시간 차트 엔티티 설계 #20
Merged
Merged
실시간 차트 엔티티 설계 #20
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
51 changes: 51 additions & 0 deletions
51
src/main/java/com/flab/mars/api/dto/response/StockPriceResponseDto.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,51 @@ | ||
package com.flab.mars.api.dto.response; | ||
|
||
import com.flab.mars.db.entity.PriceDataType; | ||
import com.flab.mars.domain.vo.response.PriceDataResponseVO; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Getter | ||
public class StockPriceResponseDto { | ||
|
||
private Long id; | ||
|
||
private String stockId; // StockInfoEntity의 ID와 연결되는 값 | ||
|
||
private PriceDataType dataType; | ||
|
||
private BigDecimal currentPrice; // 현재가 | ||
private BigDecimal openPrice; // 시가 | ||
private BigDecimal closePrice; // 종가 | ||
private BigDecimal highPrice; // 최고가 | ||
private BigDecimal lowPrice; // 최저가 | ||
|
||
private BigDecimal acmlVol; // 누적 거래량 (전체 누적 거래량) | ||
private BigDecimal acmlTrPbmn; // 누적 거래 대금 | ||
|
||
private LocalDate stockBusinessDate; // 주식 영업일자 | ||
|
||
// PriceDataResponseVO 객체를 StockPriceResponseDto로 변환하는 메서드 | ||
public static StockPriceResponseDto from(PriceDataResponseVO responseVO) { | ||
return StockPriceResponseDto.builder() | ||
.id(responseVO.getId()) | ||
.dataType(responseVO.getDataType()) | ||
.currentPrice(responseVO.getCurrentPrice()) | ||
.openPrice(responseVO.getOpenPrice()) | ||
.closePrice(responseVO.getClosePrice()) | ||
.highPrice(responseVO.getHighPrice()) | ||
.lowPrice(responseVO.getLowPrice()) | ||
.acmlVol(responseVO.getAcmlVol()) | ||
.acmlTrPbmn(responseVO.getAcmlTrPbmn()) | ||
.stockBusinessDate(responseVO.getStockBusinessDate()) | ||
.build(); | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
src/main/java/com/flab/mars/client/KisPriceResponseVO.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,53 @@ | ||
package com.flab.mars.client; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.flab.mars.domain.vo.response.BaseResponseVO; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class KisPriceResponseVO extends BaseResponseVO { | ||
@JsonProperty("output") | ||
private Output output; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Output { | ||
@JsonProperty("stck_prpr") | ||
private String stckPrpr; // 주식 현재가 | ||
|
||
@JsonProperty("prdy_vrss") | ||
private String prdyVrss; // 전일 대비 | ||
|
||
@JsonProperty("prdy_vrss_sign") | ||
private String prdyVrssSign; // 전일 대비 부호 | ||
|
||
@JsonProperty("prdy_ctrt") | ||
private String prdyCtrt; // 전일 대비율 | ||
|
||
@JsonProperty("acml_tr_pbmn") | ||
private String acmlTrPbmn; // 누적 거래 대금 | ||
|
||
@JsonProperty("acml_vol") | ||
private String acmlVol; // 누적 거래량 | ||
|
||
@JsonProperty("stck_oprc") | ||
private String stckOprc; // 주식 시가 | ||
|
||
@JsonProperty("stck_hgpr") | ||
private String stckHgpr; // 주식 최고가 | ||
|
||
@JsonProperty("stck_lwpr") | ||
private String stckLwpr; // 주식 최저가 | ||
|
||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/flab/mars/db/entity/PriceDataEntity.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,39 @@ | ||
package com.flab.mars.db.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
import java.time.LocalDate; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
@Builder | ||
@Getter | ||
@Entity | ||
@Table(name = "price_data") | ||
public class PriceDataEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "stock_info_id") | ||
private StockInfoEntity stockInfoEntity; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private PriceDataType dataType; // 데이터 유형 (DAY, WEEK, MONTH, YEAR) | ||
|
||
private String currentPrice; // 현재가 (데이터 유형이 실기간인 경우 사용) | ||
private String openPrice; // 시가 | ||
private String closePrice; // 종가 | ||
private String highPrice; // 최고가 | ||
private String lowPrice; // 최저가 | ||
|
||
private String acmlVol; // 누적 거래량 (전체 누적 거래량) | ||
private String acmlTrPbmn; // 누적 거래 대금 | ||
|
||
@Column(name = "stock_business_date") | ||
private LocalDate stockBusinessDate; // 주식 영업일자 | ||
|
||
|
||
} |
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,9 @@ | ||
package com.flab.mars.db.entity; | ||
|
||
public enum PriceDataType { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 우선은 "분" 단위 데이터만 다룬다고 가정하시는건 어때요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 우선은 분단위만 다룬다고 가정하고 작업하겠습니다! |
||
REALTIME, // 실시간 데이터 | ||
DAY, // 일별 데이터 | ||
WEEK, // 주별 데이터 | ||
MONTH, // 월별 데이터 | ||
YEAR // 연별 데이터 | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/flab/mars/db/entity/StockInfoEntity.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,21 @@ | ||
package com.flab.mars.db.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor | ||
@Builder | ||
@Getter | ||
@Entity | ||
@Table(name = "stock_info") | ||
public class StockInfoEntity { | ||
@Id | ||
@GeneratedValue | ||
@Column(name = "stock_info_id") | ||
private Long id; | ||
|
||
private String stockCode; // 주식 코드 | ||
private String stockName; // 주식 이름 | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/flab/mars/db/repository/PriceDataRepository.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,7 @@ | ||
package com.flab.mars.db.repository; | ||
|
||
import com.flab.mars.db.entity.PriceDataEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PriceDataRepository extends JpaRepository<PriceDataEntity, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/flab/mars/db/repository/StockInfoRepository.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,7 @@ | ||
package com.flab.mars.db.repository; | ||
|
||
import com.flab.mars.db.entity.StockInfoEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface StockInfoRepository extends JpaRepository<StockInfoEntity, Long> { | ||
} |
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
52 changes: 52 additions & 0 deletions
52
src/main/java/com/flab/mars/domain/vo/response/PriceDataResponseVO.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,52 @@ | ||
package com.flab.mars.domain.vo.response; | ||
|
||
import com.flab.mars.db.entity.PriceDataEntity; | ||
import com.flab.mars.db.entity.PriceDataType; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Getter | ||
public class PriceDataResponseVO { | ||
|
||
private Long id; | ||
|
||
private String stockInfoId; // StockInfoEntity의 ID와 연결되는 값 | ||
|
||
private PriceDataType dataType; // 데이터 유형 (DAY, WEEK, MONTH, YEAR) | ||
|
||
private BigDecimal currentPrice; // 현재가 | ||
private BigDecimal openPrice; // 시가 | ||
private BigDecimal closePrice; // 종가 | ||
private BigDecimal highPrice; // 최고가 | ||
private BigDecimal lowPrice; // 최저가 | ||
|
||
private BigDecimal acmlVol; // 누적 거래량 (전체 누적 거래량) | ||
private BigDecimal acmlTrPbmn; // 누적 거래 대금 | ||
|
||
private LocalDate stockBusinessDate; // 주식 영업일자 | ||
|
||
|
||
public static PriceDataResponseVO toVO(PriceDataEntity entity) { | ||
return PriceDataResponseVO.builder() | ||
.id(entity.getId()) | ||
//.stockInfoId(entity.getStockInfoEntity().getId().toString()) // TODO : StockPriceInfoEntity의 ID를 문자열로 변환 | ||
.dataType(entity.getDataType()) | ||
.currentPrice(new BigDecimal(entity.getCurrentPrice())) | ||
.openPrice(new BigDecimal(entity.getOpenPrice())) | ||
.closePrice(entity.getClosePrice() != null ? new BigDecimal(entity.getClosePrice()) : BigDecimal.ZERO) // 실시간 가격일 경우 종가 없음 | ||
.highPrice(new BigDecimal(entity.getHighPrice())) | ||
.lowPrice(new BigDecimal(entity.getLowPrice())) | ||
.acmlVol(new BigDecimal(entity.getAcmlVol())) | ||
.acmlTrPbmn(new BigDecimal(entity.getAcmlTrPbmn())) | ||
.stockBusinessDate(entity.getStockBusinessDate()) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우선은 모든 응답 필드를 다 처리하기보단 저희 도메인에 필요한 데이터만 취급하시죠~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네넹~