Conversation
* feat: 회원가입 기능 구현 * refactor: DTO 파일명 변경, @transactional 추가
* feat: 로그인 기능 구현 * feat: 로그인 테스트 초기 유저 데이터 추가 * feat: 리프레시 토큰 발급 추가 * Users 엔터티에 리프레시 토큰 필드 추가 * feat: 로그인 시 UUID 리프레시 토큰 생성 후 DB 저장 * chore: JWT 토큰 만료 시간 설정 (액세스 15분, 리프레시 7일) * refactor: 불필요한 코드 삭제 및 주석 추가
* feat: UsersRepository에 findByRefreshToken() 추가 * feat: UserService에 reissueToken() 추가 (Rotation) * feat: 토큰 재발급 엔드포인트 구현
* feat: apikey파일 .gitignore에 저장 * feat: kis 실시간 시세 반환 필드 상수 처리, websocket 키 발급 * feat: websocket 연결 및 데이터 파싱 * feat: 실시간 시세 인메모리 저장 후 sse 반환 * feat: 종목 별 구독자 관리, 마지막 구독자일 때 종목 구독 취소 * feat: stockCode가 유효한 종목인지 확인
- UserAccount/UserStock 엔티티에 매수 처리용 메서드 추가 - UserAccountRepository, UserStockRepository 쿼리 메서드 추가 - BuyReq, BuyRes DTO 추가 - TradeBuyProcessor: 현재가 조회 → 잔고 검증 → 잔고 차감 → 보유 주식 업데이트 → 거래 내역 저장 - TradeController: POST /api/trades/buy 엔드포인트 구현
- IdempotencyKey 엔티티 추가 (DB UNIQUE 제약으로 중복 체결 방지) - IdempotencyService: 키 등록(REQUIRES_NEW), 반납, 만료 키 자정 정리 스케줄러 - TradeService: 매수 전 멱등성 키 검증, 실패 시 키 반납하여 재시도 허용 - @EnableScheduling 활성화
- RealtimeStockPrice, RealTimeStockPriceStore 임시 구현 - 팀장 WebSocket 코드 머지 후 해당 파일 교체 예정 - StockController: WebSocket 없이 현재가 수동 주입하는 DEV 전용 엔드포인트 추가
- TradeServiceTest: 1000명 동시 매수, 중복 키 차단, 실패 시 키 반납 검증 - TradeControllerTest: 매수 엔드포인트 요청 검증 (정상/필드 누락/헤더 누락) - TradeBuyProcessorTest: 신규/추가 매수 비즈니스 로직, 잔고 부족 예외 검증 - build.gradle.kts: spring-boot-starter-test 추가
- application.yaml: sql.init.mode, defer-datasource-initialization 추가 - data.sql: Postman 테스트용 초기 데이터 추가 (유저, 삼성전자, 계좌 5천만원)
자정 스케줄러에서 5분 기준은 실질적으로 무의미하여 의도에 맞게 1일로 변경
- BaseInitData.work1()에 테스트용 시드 데이터 추가 (유저, 삼성전자, 계좌 5천만원) - data.sql 삭제 - application.yaml에서 sql.init.mode, defer-datasource-initialization 제거
- stock.enitity.Stock → stock.entity.Stock import 경로 수정 (TradeBuyProcessor, BaseInitData, TradeBuyProcessorTest) - stock.service.RealtimeStockPrice → stock.dto.RealtimeStockPrice import 경로 수정 (팀장 코드 반영) - stock/service/RealtimeStockPrice.java 임시 파일 삭제 (TODO 완료) - users.enitity.Users → users.entity.Users import 경로 수정 (TradeBuyProcessorTest)
Feature/st 01
feature/tr-01 매수
Open
zioJioh
reviewed
Apr 22, 2026
| @@ -0,0 +1,25 @@ | |||
| package com.back.together02be.global.util; | |||
| private String changeRate; // 전일 대비율 | ||
| private String tradeTime; // 체결시간 | ||
|
|
||
| // 10초 이상 지연시 예외처리 |
Collaborator
There was a problem hiding this comment.
TradeSellProcessor파일로 옮기는게 좋겠습니다. 결합도가 높아질 것 같습니다.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📌 과제 설명 TR-04(매도)
👩💻 요구 사항과 구현 내용
매도 API 구현 (/api/trades/sell):
사용자 ID, 종목 코드, 매도 수량, 현재가를 받아 매도 처리.
@transactional을 통한 데이터 무결성 보장 (보유 수량 차감 및 예수금 증가).
보유 자산 검증 로직:
매도 요청 시 해당 사용자가 실제로 주식을 보유하고 있는지 확인.
보유 수량보다 많은 수량을 매도하려 할 경우 RuntimeException 발생 처리.
비관적 락 사용으로 동시성 처리
✅ PR 포인트 & 궁금한 점