-
Notifications
You must be signed in to change notification settings - Fork 2
Sisc1 52 be 주식 베팅 게임 구현 #98
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
Merged
The head ref may contain hidden characters: "SISC1-52-BE-\uC8FC\uC2DD-\uBCA0\uD305-\uAC8C\uC784-\uAD6C\uD604"
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0ccb944
[BE] SISC1-52 [FIX] 베팅 게임 버그 수정
otter2023 08c400d
[BE] SISC1-52 [DOCS] Swagger에 API 주석 추가
otter2023 8e01a8f
[BE] SISC1-52 [DOCS] Swagger에 Request 주석 추가
otter2023 cd8d834
Merge branch 'main' into SISC1-52-BE-주식-베팅-게임-구현
otter2023 4feba2c
[BE] SISC1-52 [FIX] 500 에러 수정
otter2023 757fe9c
[BE] SISC1-52 [DOCS] Swagger에 BetRound 주석 추가
otter2023 2c4eca0
[BE] SISC1-52 [FEAT] 테스트를 위한 스케쥴러의 api화
otter2023 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
40 changes: 40 additions & 0 deletions
40
backend/src/main/java/org/sejongisc/backend/betting/controller/BettingAdminController.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package org.sejongisc.backend.betting.controller; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import org.sejongisc.backend.betting.entity.Scope; | ||
| import org.sejongisc.backend.betting.service.BettingService; | ||
| import org.sejongisc.backend.betting.service.BettingScheduler; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/admin/bet-rounds") | ||
| public class BettingAdminController { | ||
|
|
||
| private final BettingService bettingService; | ||
|
|
||
| @PostMapping("/daily/open") | ||
| public ResponseEntity<String> createDailyRound() { | ||
| bettingService.createBetRound(Scope.DAILY); | ||
| return ResponseEntity.ok("DAILY 라운드 생성"); | ||
| } | ||
|
|
||
| @PostMapping("/weekly/open") | ||
| public ResponseEntity<String> createWeeklyRound() { | ||
| bettingService.createBetRound(Scope.WEEKLY); | ||
| return ResponseEntity.ok("WEEKLY 라운드 생성"); | ||
| } | ||
|
|
||
| @PostMapping("/close") | ||
| public ResponseEntity<String> closeRounds() { | ||
| bettingService.closeBetRound(); | ||
| return ResponseEntity.ok("라운드 종료"); | ||
| } | ||
|
|
||
| @PostMapping("/settle") | ||
| public ResponseEntity<String> settleRounds() { | ||
| bettingService.settleUserBets(); | ||
| return ResponseEntity.ok("정산"); | ||
| } | ||
| } |
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
42 changes: 42 additions & 0 deletions
42
backend/src/main/java/org/sejongisc/backend/betting/dto/PriceResponse.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.sejongisc.backend.betting.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.*; | ||
| import org.sejongisc.backend.betting.entity.MarketType; | ||
| import org.sejongisc.backend.stock.entity.PriceData; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Schema(description = "시세 응답 DTO (PriceData 기반)") | ||
| public class PriceResponse { | ||
|
|
||
| @Schema(description = "티커 이름 (예: KOSPI, BTC, AAPL)") | ||
| private String name; | ||
|
|
||
| @Schema(description = "심볼 (거래 대상의 식별자)") | ||
| private String symbol; | ||
|
|
||
| @Schema(description = "시장 구분 (예: KOREA, US, CRYPTO)") | ||
| private MarketType market; | ||
|
|
||
| @Schema(description = "이전 종가 (기준가)") | ||
| private BigDecimal previousClosePrice; | ||
|
|
||
| @Schema(description = "정산 종가 (결과 비교용)") | ||
| private BigDecimal settleClosePrice; | ||
|
|
||
|
|
||
| public static PriceResponse from(PriceData entity, MarketType marketName) { | ||
| return PriceResponse.builder() | ||
| .name(entity.getTicker()) | ||
| .symbol(entity.getTicker()) | ||
| .market(marketName) | ||
| .previousClosePrice(entity.getClosePrice()) | ||
| .settleClosePrice(entity.getAdjustedClose()) | ||
| .build(); | ||
| } | ||
| } |
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
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
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.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
컨트롤러에서 엔티티 객체를 직접 반환하고 있습니다.
현재 모든 엔드포인트에서
BetRound와UserBet엔티티를 직접 반환하고 있습니다. 이는 다음과 같은 문제를 야기합니다:DTO 패턴을 도입하여 각 엔드포인트에 맞는 응답 클래스를 만드는 것을 강력히 권장합니다.
다음 스크립트로 엔티티에 JPA 관계 어노테이션이 있는지 확인하여 순환 참조 위험을 검증합니다:
Also applies to: 74-77, 94-101, 117-125, 138-144
🏁 Script executed:
Length of output: 131
추가 검증이 필요합니다. BetRound와 다른 엔티티의 양방향 관계를 확인하겠습니다.
Length of output: 233
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 1118
Length of output: 3523
🏁 Script executed:
Length of output: 5591
🏁 Script executed:
Length of output: 291
엔티티 객체의 직접 반환에 따른 아키텍처 위험 개선 필요
현재 모든 엔드포인트에서
BetRound와UserBet엔티티를 직접 반환하고 있습니다. 순환 참조 위험은 현재 설정(unidirectional relationship + LAZY fetch)에서 즉각적인 문제는 아니지만, 다음의 아키텍처적 문제가 존재합니다:각 엔드포인트에 맞는 DTO 클래스를 작성하여 응답 데이터를 제어하기를 권장합니다 (50-60, 74-77, 94-101, 138-144 라인).
🤖 Prompt for AI Agents