-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # .github/workflows/deploy.yml # Dockerfile
- Loading branch information
Showing
378 changed files
with
20,066 additions
and
428 deletions.
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
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 |
---|---|---|
@@ -1 +1,80 @@ | ||
# WEB1_2_Child-Learn_BE | ||
# ์์ด์ฃผ์ฃผ ![์์ด์ฃผ์ฃผ 3](https://github.com/user-attachments/assets/89cd492b-92fe-46ef-b7f2-319e8df4c400) | ||
|
||
![ํ๋ก์ ํธ์ด๋ฏธ์ง](https://github.com/user-attachments/assets/6e0bdf74-a374-4c70-952d-fc22e0ba3413) | ||
|
||
## ๐ ํ๋ก์ ํธ ์๊ฐ | ||
์์ด์ฃผ์ฃผ๋ ์ด๋ฑํ์๋ค์ด ๋๊ณผ ํฌ์์ ๊ธฐ๋ณธ ๊ฐ๋ ์ ์ฝ๊ณ ์ฌ๋ฏธ์๊ฒ ๋ฐฐ์ธ ์ ์๋๋ก ์ค๊ณ๋ ๋ชจ์ํฌ์ ํ์ต ํ๋ซํผ์ ๋๋ค. | ||
|
||
[๐ ๊ธฐํ์](https://www.notion.so/13f336d06fda80d4a0dfc9e9ac30e96b?pvs=4) | ||
[๐ ๋์์ธ](https://www.figma.com/design/HfCXjOdS1CcDWLJbhci0dI/%EC%95%84%EC%9D%B4%EC%A3%BC%EC%A3%BC-%EC%99%80%EC%9D%B4%EC%96%B4%ED%94%84%EB%A0%88%EC%9E%84?node-id=0-1&t=WB1ZEVppjZTp8DY5-1) | ||
[๐ ํ๋ก ํธ ๊นํ๋ธ](https://github.com/prgrms-web-devcourse-final-project/WEB1_2_Child-Learn_FE) | ||
[๐ ๋ฐฑ์๋ ๊นํ๋ธ](https://github.com/prgrms-web-devcourse-final-project/WEB1_2_Child-Learn_BE) | ||
[๐ ์์ด์ฃผ์ฃผ ๋ฐ๋ก๊ฐ๊ธฐ](http://ijuju.site) | ||
|
||
### ๊ฐ๋ฐ๊ธฐ๊ฐ : 2024/11/18 ~ 2024/12/09 | ||
|
||
<br> | ||
|
||
|
||
## ๐ ์ฃผ์ ๊ธฐ๋ฅ | ||
> **์ฃผ์ ๊ทธ๋ํ** | ||
- **๊ทธ๋ํ ๋ฐ ๋ฐ์ดํฐ ์ ๊ณต:** ์ข ๋ชฉ๋ณ ํฌ์ ๊ทธ๋ํ์ ๋น์ ์ ์ค๋ช ์ด ๋ด๊ธด ๋ด์ค๋ ํฐ ์ ๊ณต | ||
- **AI ๋ง์ถคํ ์ ๋ณด:** API๋ก ์ค์๊ฐ ๋ฐ์ดํฐ ์์ง ๋ฐ ๋ง์ถคํ ๋ด์ค ์ํฐํด ์ ๊ณต | ||
- **๋๋ค์ฑ๊ณผ ํ์ค์ฑ:** ๋๋ค ์๊ณ ๋ฆฌ์ฆ๊ณผ ์ค์ ๊ฒฝ์ ๋ฐ์ดํฐ๋ฅผ ํผํฉํด ์ฌ๋ฏธ์๊ณ ํ์ค๊ฐ ์๋ ๊ทธ๋ํ ๋ณํ ์ ๊ณต | ||
|
||
> **๋ฏธ๋๊ฒ์** | ||
์์ด๋ค์ ํฅ๋ฏธ๋ฅผ ์ ๋ฐํ๊ณ , ํ์ต ํจ๊ณผ๋ฅผ ๊ทน๋ํํ๊ธฐ ์ํ ๋ค์ํ ๋ฏธ๋๊ฒ์ | ||
- **์นด๋ ๋ค์ง๊ธฐ**: ํฌ์ ๊ด๋ จ์ฉ์ด๋ฅผ ๊ฒ์์ผ๋ก ๊ฐ๋ ์ดํด. | ||
- **๊ธ์ต ํด์ฆ:** ๋, ์ ์ถ, ํฌ์ ๊ด๋ จ ํด์ฆ๋ฅผ ํตํด ๊ธฐ๋ณธ ๊ฐ๋ ์ดํด. | ||
- **๋ก๋:** ๊ฐ๋จํ ํ๋ฅ ๊ฒ์์ผ๋ก ํฌ์์ ์ํ์ ๊ฐ๋ ์ดํด. | ||
|
||
> **์์ ** | ||
- ๊ฒ์ ๋ฐ ์ฃผ์ํฌ์๋ฅผ ํตํ์ฌ ํ๋ํ ํฌ์ธํธ๋ก ์์ ๊ธฐ๋ฅ ์ ๊ณต. | ||
- ์์ ์์ ์์ ๋ง์ ์๋ฐํ๋ฅผ ๊พธ๋ฐ ์ ์๋ ์์ดํ ์ ๊ณต. | ||
- ์ฌ๋ฌ๊ฐ์ง ์์ดํ ์ผ๋ก ํฅ๋ฏธ ์ ๊ณต. | ||
|
||
<br> | ||
|
||
## ๐ ๊ฐ๋ฐ ํ๊ฒฝ ๋ฐ ๊ธฐ์ ์คํ | ||
### ํตํฉ ์์คํ ์ํคํ ์ฒ | ||
![ํตํฉ ์์คํ ์ํคํ ์ฒ](https://github.com/user-attachments/assets/f6ddd958-6a68-4305-84c3-3e6f8098633f) | ||
|
||
<br> | ||
|
||
## ๐ ๊ฐ๋ฐ ๋ฌธ์ | ||
<details> | ||
<summary>ERD</summary> | ||
</details> | ||
<details> | ||
<summary>์ํคํ ์ฒ</summary> | ||
|
||
![๋ฐฑ์๋ ์๋ฒ ์ํคํ ์ฒ](https://github.com/user-attachments/assets/f96d2c88-223c-47b4-a673-ac613be39063) | ||
|
||
</details> | ||
<details> | ||
<summary>์๊ตฌ์ฌํญ ๋ช ์ธ์</summary> | ||
|
||
[๐ ์๊ตฌ์ฌํญ ๋ช ์ธ์](https://foggy-move-190.notion.site/67c1e522ca8047d98094580d9bdc8f87?pvs=74) | ||
</details> | ||
<details> | ||
<summary>API ๋ช ์ธ์</summary> | ||
|
||
[๐ API ๋ช ์ธ์](https://foggy-move-190.notion.site/API-b44b55ec93c9478c9a25c9f75150b773?pvs=73) | ||
</details> | ||
|
||
## ๐ ํ ์๊ฐ | ||
|
||
### FRONTEND | ||
| ๐ ์ดํฌ์ฃผ | ๐ ๋ฐ์ฐํ | ๋ฅ๋ฏผ์ฃผ | | ||
|:----------------------------------------------------------:|:----------------------------------------------------------:|:-------------------------------------:| | ||
| FE TeamLeader | PM | Git_Admin | | ||
| [tree0000](https://github.com/tree0000) | [hjlee2778](https://github.com/hjlee2778) | [minij02](https://github.com/minij02) | | ||
| ![](https://avatars.githubusercontent.com/u/141895600?v=4) | ![](https://avatars.githubusercontent.com/u/144092849?v=4) | ![](https://avatars.githubusercontent.com/u/135093109?v=4)| | ||
|
||
### BACKEND | ||
| ๐ ์์ง์ | ์ ์ํ | ์ต์ฌํ | ์ด์๋น | ๋ฐ์ฐฌ์ | | ||
|:---------------------------------:|:-----------------------------------------:|:--------------------------------:|:---------------------------------------:|:---------------------------------------:| | ||
| BE TeamLeader & AWS_Admin | Git_Admin | Developer | Developer | Developer | | ||
| [1mjay](https://github.com/1mjay) | [deveunhwa](https://github.com/deveunhwa) | [Preta3418](https://github.com/Preta3418) | [subbb-in](https://github.com/subbb-in) | [chanspar](https://github.com/chanspar) | | ||
| ![](https://avatars.githubusercontent.com/u/84836677?v=4) | ![](https://avatars.githubusercontent.com/u/180101230?v=4) | ![](https://avatars.githubusercontent.com/u/161911738?v=4) | ![](https://avatars.githubusercontent.com/u/48655473?v=4) | ![](https://avatars.githubusercontent.com/u/87303538?v=4) | |
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
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
101 changes: 101 additions & 0 deletions
101
src/main/java/com/prgrms/ijuju/domain/article/component/AdvTrendAnalyzer.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,101 @@ | ||
package com.prgrms.ijuju.domain.article.component; | ||
|
||
import com.prgrms.ijuju.domain.article.data.DailyTrend; | ||
import com.prgrms.ijuju.domain.article.data.Trend; | ||
import com.prgrms.ijuju.domain.stock.adv.advstock.entity.AdvStock; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.Instant; | ||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Adv ๊ฐ์ ๊ฒฝ์ฐ๋ timeStamp ๋ก ์ด๋ฃจ์ด์ ธ ์์ผ๋ฉฐ, ํ์๊ฐ ๋ด์ผ๋ก ๋ฐ์ดํฐ๊ฐ ์ด๋ฃจ์ด์ ธ ์์ต๋๋ค | ||
* ๋ฐ์ดํฐ ๋ถ์์ ์ํด์ ๋ชจ๋ ๋ฐ์ดํฐ๋ฅผ ์ ๋ถ "ํ๋ฃจ" ๋จ์๋ก ๋ณ๊ฒฝํฉ๋๋ค | ||
*/ | ||
@Component | ||
public class AdvTrendAnalyzer { | ||
|
||
|
||
public List<Trend> analyzeTrends(AdvStock advStock) { | ||
Map<LocalDate, List<Double>> groupedData = groupByDate(advStock.getTimestamps(), advStock.getClosePrices()); | ||
|
||
List<DailyTrend> dailyTrends = calculateDailyTrends(groupedData); | ||
|
||
return calculateCompositeTrends(dailyTrends, advStock.getSymbol()); | ||
} | ||
|
||
// ํ ์๊ฐ ๋จ์ ๋ฐ์ดํฐ๋ฅผ ์ผ ๋จ์๋ก ๋ฌถ์ | ||
// AdvStock ์ timeStamps ๋ก ๊ตฌ๋ถ๋์ด ์๊ธฐ์, LocalData ๋ก ๋ณํํ ๊ณผ์ ์ด ํ์ํ๊ธฐ์ ์์ฑ๋ ๋ฉ์๋ ์ ๋๋ค | ||
private Map<LocalDate, List<Double>> groupByDate(List<Long> timestamps, List<Double> closePrices) { | ||
Map<LocalDate, List<Double>> groupedData = new HashMap<>(); | ||
|
||
for (int i = 0; i < timestamps.size(); i++) { | ||
LocalDate date = Instant.ofEpochMilli(timestamps.get(i)).atZone(ZoneId.systemDefault()).toLocalDate(); | ||
groupedData.computeIfAbsent(date, k -> new ArrayList<>()).add(closePrices.get(i)); | ||
} | ||
|
||
return groupedData; | ||
} | ||
|
||
|
||
private List<DailyTrend> calculateDailyTrends(Map<LocalDate, List<Double>> groupedData) { | ||
List<DailyTrend> dailyTrends = new ArrayList<>(); | ||
|
||
for (Map.Entry<LocalDate, List<Double>> entry : groupedData.entrySet()) { | ||
List<Double> dailyPrices = entry.getValue(); | ||
double startPrice = dailyPrices.get(0); | ||
double endPrice = dailyPrices.get(dailyPrices.size() - 1); | ||
|
||
double percentageChange = ((endPrice - startPrice) / startPrice) * 100; | ||
String trendType = determineTrendType(percentageChange); | ||
|
||
dailyTrends.add(new DailyTrend(entry.getKey(), trendType, percentageChange)); | ||
} | ||
|
||
return dailyTrends; | ||
} | ||
|
||
private String determineTrendType(double percentageChange) { | ||
if (percentageChange > 2.0) return "UP"; | ||
if (percentageChange < -2.0) return "DOWN"; | ||
return "STABLE"; | ||
} | ||
|
||
|
||
private List<Trend> calculateCompositeTrends(List<DailyTrend> dailyTrends, String symbol) { | ||
List<Trend> trends = new ArrayList<>(); | ||
|
||
|
||
if (dailyTrends.size() >= 3) { | ||
trends.add(new Trend("SHORT_TERM", | ||
calculateTrendDescription(dailyTrends.subList(0, Math.min(3, dailyTrends.size()))), symbol)); | ||
} | ||
|
||
|
||
if (dailyTrends.size() >= 7) { | ||
trends.add(new Trend("MID_TERM", | ||
calculateTrendDescription(dailyTrends.subList(0, Math.min(7, dailyTrends.size()))), symbol)); | ||
} | ||
|
||
|
||
trends.add(new Trend("LONG_TERM", calculateTrendDescription(dailyTrends), symbol)); | ||
|
||
return trends; | ||
} | ||
|
||
|
||
private String calculateTrendDescription(List<DailyTrend> dailyTrends) { | ||
|
||
long upCount = dailyTrends.stream().filter(d -> d.getTrendType().equals("UP")).count(); | ||
long downCount = dailyTrends.stream().filter(d -> d.getTrendType().equals("DOWN")).count(); | ||
|
||
if (upCount > downCount) return "UP"; | ||
if (downCount > upCount) return "DOWN"; | ||
return "STABLE"; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/prgrms/ijuju/domain/article/component/MidTrendAnalyzer.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.prgrms.ijuju.domain.article.component; | ||
|
||
import com.prgrms.ijuju.domain.article.data.Trend; | ||
import com.prgrms.ijuju.domain.stock.mid.entity.MidStockPrice; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Component | ||
public class MidTrendAnalyzer { | ||
|
||
public List<Trend> analyzeTrends(List<MidStockPrice> prices, String midName) { | ||
List<Trend> trends = new ArrayList<>(); | ||
|
||
// 3์ผ ๊ธฐ์ค | ||
trends.add(new Trend("SHORT_TERM", calculateTrend(prices, 3), midName)); | ||
|
||
// 1์ฃผ ๊ธฐ์ค | ||
trends.add(new Trend("MID_TERM", calculateTrend(prices, 7), midName)); | ||
|
||
// 2์ฃผ ๊ธฐ์ค | ||
trends.add(new Trend("LONG_TERM", calculateTrend(prices, 14), midName)); | ||
|
||
return trends; | ||
} | ||
|
||
private String calculateTrend(List<MidStockPrice> prices, int days) { | ||
if (prices.size() < days) return "INSUFFICIENT_DATA"; | ||
|
||
double startPrice = prices.get(prices.size() - days).getAvgPrice(); // ์์ ๊ฐ๊ฒฉ | ||
double endPrice = prices.get(prices.size() - 1).getAvgPrice(); // ์ข ๋ฃ ๊ฐ๊ฒฉ | ||
double percentageChange = ((endPrice - startPrice) / startPrice) * 100; | ||
|
||
if (percentageChange > 2.0) return "UP"; | ||
if (percentageChange < -2.0) return "DOWN"; | ||
return "STABLE"; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/prgrms/ijuju/domain/article/contant/DataType.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,5 @@ | ||
package com.prgrms.ijuju.domain.article.contant; | ||
|
||
public enum DataType { | ||
ADVANCED, MID | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/com/prgrms/ijuju/domain/article/controller/ArticleController.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,50 @@ | ||
package com.prgrms.ijuju.domain.article.controller; | ||
|
||
import com.prgrms.ijuju.domain.article.scheduler.ArticleScheduler; | ||
import com.prgrms.ijuju.domain.article.service.ArticleService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import java.util.List; | ||
import com.prgrms.ijuju.domain.article.entity.Article; | ||
import com.prgrms.ijuju.domain.article.contant.DataType; | ||
|
||
|
||
|
||
|
||
@RestController | ||
@RequestMapping("/api/v1/articles") | ||
@RequiredArgsConstructor | ||
public class ArticleController { | ||
|
||
private final ArticleService articleService; | ||
private final ArticleScheduler articleScheduler; | ||
|
||
|
||
@GetMapping("/{type}") | ||
public ResponseEntity<List<Article>> getArticlesByType(@PathVariable DataType type) { | ||
List<Article> articles = articleService.findArticlesByType(type); | ||
return ResponseEntity.ok(articles); | ||
} | ||
|
||
|
||
@GetMapping("/detail/{id}") | ||
public ResponseEntity<Article> getArticleById(@PathVariable Long id) { | ||
Article article = articleService.findArticleById(id); | ||
return ResponseEntity.ok(article); | ||
} | ||
|
||
//๋๋ฒ๊น ์ฉ๋ | ||
@GetMapping | ||
public ResponseEntity<List<Article>> getAllArticles() { | ||
List<Article> articles = articleService.findAllArticles(); | ||
return ResponseEntity.ok(articles); | ||
} | ||
|
||
//๋๋ฒ๊น ์ฉ๋ | ||
@PostMapping("/manage-articles") | ||
public ResponseEntity<String> executeManageArticlesScheduler() { | ||
articleScheduler.manageArticles(); | ||
return ResponseEntity.ok("์ค์ผ์ฅด๋ฌ ๊ธฐ๋ฅ์ด ๊ฐ์ ๋ก ์คํ๋์์ต๋๋ค."); | ||
} | ||
} |
Oops, something went wrong.