STK10-04 외국인 보유 수집·영속화
작업 내용
외국인 보유주식수·보유율·한도소진율 수직 슬라이스를 구현한다. STK10-03과 동일 패턴, 새 파일만 추가.
- domain:
ForeignHoldingEntity,ForeignHoldingRepository·ForeignHoldingGatewayinterface - infrastructure/krx:
KrxForeignHoldingGatewayImpl— 해당 bld 호출·파싱 - infrastructure/mysql:
ForeignHoldingRepositoryImpl— 전종목 1회 JDBC 벌크 upsert(INSERT … ON DUPLICATE KEY UPDATE), 행 단위 save 금지
다이어그램
처리 흐름
sequenceDiagram participant DS as MarketFlowDomainService participant Gw as KrxForeignHoldingGatewayImpl participant Client as KrxMdcClient participant Repo as ForeignHoldingRepositoryImpl DS->>Gw: fetch(baseDate) Gw->>Client: getJsonData(bld, baseDate) Client-->>Gw: rows Gw-->>DS: List<ForeignHolding> DS->>Repo: upsertAll(list)
클래스 의존
flowchart LR Impl[KrxForeignHoldingGatewayImpl] -.implements.-> Gw[ForeignHoldingGateway] Impl --> Client[KrxMdcClient] RepoImpl[ForeignHoldingRepositoryImpl] -.implements.-> Repo[ForeignHoldingRepository]
테스트 케이스
- KRX JSON을 ForeignHolding Entity로 파싱한다 (보유율·한도소진율 매핑)
- 동일
(symbol, base_date)재적재 시 멱등 upsert된다 - 보유율 소수 정밀도가 보존된다
- 전종목을 1회 벌크 upsert로 적재한다 (행 단위 save 미사용)
- 빈 응답 시 graceful 처리한다