-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/tr 04 #32
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
Closed
Closed
Feature/tr 04 #32
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
5c9eeb3
feat: ํ์๊ฐ์
๊ธฐ๋ฅ ๊ตฌํ (#7)
sat7312 5c5c204
feat: ๋ก๊ทธ์ธ ๊ธฐ๋ฅ ๊ตฌํ (#11)
sat7312 6963831
merge: dev ๋ธ๋์น ๋ณํฉ ๋ฐ ์ถฉ๋ ํด๊ฒฐ
hyhdb 9236d60
feat: ํ ํฐ ์ฌ๋ฐ๊ธ ์๋ํฌ์ธํธ ๊ตฌํ (#14)
sat7312 6c66053
feat: ๋ก๊ทธ์์ API ์ถ๊ฐ (#17)
sat7312 683107a
refactor: DTO ๋ค์ด๋ฐ ๋ฐ RestClient ์ ์ฉ, ๋ถํ์ ํ๋ ์ ๊ฑฐ
hyhdb 20cb10b
Merge branch 'dev' into feature/st-01
hyhdb 08a3b58
feat: ์ข
๋ชฉ ์ด๊ธฐ ๋ฐ์ดํฐ ๋ก๋ฉ ๊ธฐ๋ฅ ์ถ๊ฐ (StockInitData)
hyhdb 290e3da
Feature/st 03 (#18)
zioJioh 6fcfaad
feature:๋งค์ api ๊ตฌํ
gmltmdu 9baa7a5
feature:๋งค์ api ๊ตฌํ
gmltmdu 060da6f
feat: TR-01 ๋งค์ ํต์ฌ ๋ก์ง ๊ตฌํ
davin11992 ef70cf1
feat: ๋ฉฑ๋ฑ์ฑ ํค๋ก ์ค๋ณต ์์ฒญ ๋ฐฉ์ด
davin11992 71f229d
chore: ์์ RealTimeStockPriceStore ์ถ๊ฐ (ํ์ฅ ์ฝ๋ ๋๊ธฐ ์ค)
davin11992 9986aef
test: TR-01 ๋งค์ ํ
์คํธ ์ฝ๋ ์์ฑ
davin11992 ab042eb
chore: H2 ๊ฐ๋ฐ ํ๊ฒฝ seed ๋ฐ์ดํฐ ์ค์
davin11992 fdab242
fix: ๋ฉฑ๋ฑ์ฑ ํค ๋ง๋ฃ ๊ธฐ์ค 5๋ถ โ 1์ผ๋ก ์์
davin11992 ab525a6
refactor: ์๋ ๋ฐ์ดํฐ๋ฅผ data.sql์์ BaseInitData๋ก ์ด๋
davin11992 ef18951
style: TradeBuyProcessor ๋ณ์ ํ์
๋ช
์ (var โ RealtimeStockPrice)
davin11992 24c2c13
refactor: dev ๋ธ๋์น rebase ํ ํจํค์ง ๊ฒฝ๋ก ๋ฐ ์์ ํ์ผ ์ ๋ฆฌ
davin11992 51be62f
chore: dev ๋ธ๋์น ์ถฉ๋ ํด๊ฒฐ
hyhdb 62fd0dd
chore: application-local.yaml gitignore ์ถ๊ฐ
davin11992 e7a0830
Merge pull request #13 from prgrms-be-devcourse/feature/st-01
hyhdb f08ab14
Merge branch 'dev' into feature/tr-01
davin11992 1868cc6
Merge pull request #16 from prgrms-be-devcourse/feature/tr-01
davin11992 a5b4e68
feature: ์ค์๊ฐ ๊ฐ๊ฒฉ ๋ฐ์ดํฐ ์ ์ฉ
gmltmdu 1e80b72
feature: ์ค์๊ฐ ๊ฐ๊ฒฉ ๋ฐ์ดํฐ ์ ์ฉ
gmltmdu c718cba
refactor: TradeSellReq๋ฅผ ๋ณ๋ ํ์ผ๋ก ๋ถ๋ฆฌ
gmltmdu e2f33bf
refactor: TradeSellReq๋ฅผ ๋ณ๋ ํ์ผ๋ก ๋ถ๋ฆฌ
gmltmdu fb5d919
fix: transactional์ค์ ์์ ๋ฐ entity ์คํ ์์
gmltmdu cbda084
fix: transactional์ค์ ์์ ๋ฐ entity ์คํ ์์
gmltmdu 7d18398
merge: dev๋ธ๋์น merge
gmltmdu d00275e
merge: dev๋ธ๋์น merge
gmltmdu 7bdaf15
chore: ํ
์คํธ๋ฅผ ์ํ ์์์ฝ๋ ์์ฑ
gmltmdu 35a33af
chore: ํ
์คํธ๋ฅผ ์ํ ์์์ฝ๋ ์์ฑ
gmltmdu 1590fe6
feature: ๋ฉฑ๋ฑ์ฑ ์ถ๊ฐ
gmltmdu 96cc571
feature: ๋ฉฑ๋ฑ์ฑ ์ถ๊ฐ
gmltmdu 907abe8
fix: ๋น๊ด์ ๋ฝ ๋์ update์ ๋ฝ ๊ฑธ๊ธฐ
gmltmdu a92aed7
fix: ๋น๊ด์ ๋ฝ ๋์ update์ ๋ฝ ๊ฑธ๊ธฐ
gmltmdu d3b6e90
chore: testInitData ์ญ์
gmltmdu 2e071f1
chore: testInitData ์ญ์
gmltmdu 367b35c
feature: ์ฅ ๋ง๊ฐ์ ๊ฑฐ๋ ๋ถ๊ฐ ๊ธฐ๋ฅ ์ถ๊ฐ
gmltmdu 95a8b24
feature: 2%๋ก ๊ฐ๊ฒฉ ๊ฒ์ฆ ๊ธฐ๋ฅ ์ถ๊ฐ
gmltmdu d1e4173
chore: ์ต์ ๋ฒ์ ๋จธ์ง
gmltmdu ca4b474
feature: 10์ด ์ด์ ์ง์ฐ์ ์์ธ์ฒ๋ฆฌ
gmltmdu b8dc38a
test: ํ
์คํธ ์ฝ๋ ์ถ๊ฐ
gmltmdu 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 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
5 changes: 2 additions & 3 deletions
5
src/main/java/com/back/together02be/asset/controller/AssetController.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
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
5 changes: 2 additions & 3 deletions
5
src/main/java/com/back/together02be/asset/repository/UserAccountRepository.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
22 changes: 19 additions & 3 deletions
22
src/main/java/com/back/together02be/asset/repository/UserStockRepository.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 |
|---|---|---|
| @@ -1,11 +1,27 @@ | ||
| package com.back.together02be.asset.repository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| import com.back.together02be.asset.entity.UserStock; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Modifying; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| import com.back.together02be.asset.enitity.UserStock; | ||
| import java.util.Optional; | ||
|
|
||
| public interface UserStockRepository extends JpaRepository<UserStock, Long> { | ||
| Optional<UserStock> findByUsersIdAndStockId(Long usersId, Long stockId); | ||
|
|
||
| // ๋ํฐ ์ฒดํน์ ์ฌ์ฉํ์ง ์์ผ๋ฏ๋ก, ์ฐ์ฐ ํ ์์์ฑ ์ปจํ ์คํธ๋ฅผ ๋น์์ค์ผ ์ต์ ๋ฐ์ดํฐ๊ฐ ๋ฐ์๋ฉ๋๋ค. | ||
| @Modifying(clearAutomatically = true) | ||
| @Query("UPDATE UserStock u SET u.quantity = u.quantity - :sellQuantity " + | ||
| "WHERE u.users.id = :userId AND u.stock.id = :stockId AND u.quantity >= :sellQuantity") | ||
| int updateQuantity(@Param("userId") Long userId, | ||
| @Param("stockId") Long stockId, | ||
| @Param("sellQuantity") Long sellQuantity); | ||
| //delete๋ ๋์์ฑ ์ ์ด๋ฅผ ์ํด ์ฌ์ฉ | ||
| @Modifying(clearAutomatically = true) | ||
| @Query("DELETE FROM UserStock u WHERE u.users.id = :userId AND u.stock.id = :stockId AND u.quantity = 0") | ||
| void deleteByUserAndStock(@Param("userId") Long userId, @Param("stockId") Long stockId); | ||
|
|
||
| //void delete(UserStock userStock); | ||
| } |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/back/together02be/global/util/MarketTimeValidator.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,25 @@ | ||
| package com.back.together02be.global.util; | ||
|
|
||
| import java.time.DayOfWeek; | ||
| import java.time.LocalDateTime; | ||
| import java.time.LocalTime; | ||
| import java.time.ZoneId; | ||
|
|
||
| public class MarketTimeValidator { | ||
|
|
||
| public static void validateMarketOpen() { | ||
| LocalDateTime now = LocalDateTime.now(ZoneId.of("Asia/Seoul")); | ||
| DayOfWeek day = now.getDayOfWeek(); | ||
| LocalTime time = now.toLocalTime(); | ||
|
|
||
| // ์ฃผ๋ง ์ฒดํฌ | ||
| if (day == DayOfWeek.SATURDAY || day == DayOfWeek.SUNDAY) { | ||
| throw new IllegalStateException("์ฃผ๋ง์๋ ๊ฑฐ๋ํ ์ ์์ต๋๋ค."); | ||
| } | ||
|
|
||
| // ์๊ฐ ์ฒดํฌ (09:00 ~ 15:30) | ||
| if (time.isBefore(LocalTime.of(9, 0)) || time.isAfter(LocalTime.of(15, 30))) { | ||
| throw new IllegalStateException("์ฅ ์ด์ ์๊ฐ(09:00 ~ 15:30) ์ธ์๋ ๊ฑฐ๋๊ฐ ๋ถ๊ฐ๋ฅํฉ๋๋ค."); | ||
| } | ||
| } | ||
| } | ||
10 changes: 4 additions & 6 deletions
10
src/main/java/com/back/together02be/infra/kis/ApprovalKeyService.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
12 changes: 5 additions & 7 deletions
12
src/main/java/com/back/together02be/infra/kis/KisWebSocketClient.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
6 changes: 2 additions & 4 deletions
6
src/main/java/com/back/together02be/infra/kis/KisWebSocketHandler.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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,12 @@ | |
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import java.time.LocalTime; | ||
| import java.time.format.DateTimeFormatter; | ||
| import java.time.temporal.ChronoUnit; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| public class RealtimeStockPrice { | ||
|
|
@@ -12,4 +18,18 @@ public class RealtimeStockPrice { | |
| private String change; // ์ ์ผ ๋๋น | ||
| private String changeRate; // ์ ์ผ ๋๋น์จ | ||
| private String tradeTime; // ์ฒด๊ฒฐ์๊ฐ | ||
|
|
||
| // 10์ด ์ด์ ์ง์ฐ์ ์์ธ์ฒ๋ฆฌ | ||
|
Collaborator
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. TradeSellProcessorํ์ผ๋ก ์ฎ๊ธฐ๋๊ฒ ์ข๊ฒ ์ต๋๋ค. ๊ฒฐํฉ๋๊ฐ ๋์์ง ๊ฒ ๊ฐ์ต๋๋ค. |
||
| public boolean isStale(int limitSeconds) { | ||
| if (this.tradeTime == null) return true; // ๋ฐ์ดํฐ๊ฐ ์์ผ๋ฉด ๋ฌด์กฐ๊ฑด ์ง์ฐ ๊ฐ์ฃผ | ||
|
|
||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HHmmss"); | ||
| LocalTime tradeTime = LocalTime.parse(this.tradeTime, formatter); | ||
|
|
||
| LocalDateTime tradeDateTime = LocalDateTime.of(LocalDate.now(), tradeTime); | ||
| LocalDateTime now = LocalDateTime.now(); | ||
|
|
||
| // ํ์ฌ ์๊ฐ๊ณผ ์ฒด๊ฒฐ ์๊ฐ์ ์ฐจ์ด๊ฐ limitSeconds๋ฅผ ๋๋์ง ํ์ธ | ||
| return ChronoUnit.SECONDS.between(tradeDateTime, now) > limitSeconds; | ||
| } | ||
| } | ||
23 changes: 9 additions & 14 deletions
23
src/main/java/com/back/together02be/stock/service/StockService.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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/back/together02be/trade/dto/request/TradeSellReq.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,11 @@ | ||
| package com.back.together02be.trade.dto.request; | ||
|
|
||
| import jakarta.validation.constraints.Min; | ||
|
|
||
| public record TradeSellReq( | ||
| Long userId, | ||
| Long stockId, | ||
| @Min(value = 1, message = "๋งค๋ ์๋์ ์ต์ 1๊ฐ์ฌ์ผ ํฉ๋๋ค.") | ||
| Long quantity, | ||
| Long expectedPrice | ||
| ){ } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/back/together02be/trade/dto/response/TradeSellRes.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,11 @@ | ||
| package com.back.together02be.trade.dto.response; | ||
|
|
||
| public record TradeSellRes( | ||
| Long tradeId, | ||
| String stockName, | ||
| Long quantity, | ||
| Long price, | ||
| Long amount, | ||
| Long remainingDeposit | ||
| ) { | ||
| } |
5 changes: 0 additions & 5 deletions
5
src/main/java/com/back/together02be/trade/enitity/TradeType.java
This file was deleted.
Oops, something went wrong.
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.
trade ํด๋๋ก ์ฎ๊ธฐ๋๊ฒ ์ข์๊ฑฐ ๊ฐ์ต๋๋ค.