1
0

feat: 增加月线周线蜡烛图

This commit is contained in:
2025-10-15 15:14:38 +08:00
parent 42b402d4ef
commit 452d1c681d
2 changed files with 179 additions and 132 deletions

View File

@@ -135,6 +135,36 @@ public class StockController extends SimpleControllerSupport<Stock, Void, StockD
));
}
@SuppressWarnings("DuplicatedCode")
@GetMapping("weekly/{id}")
public GlobalResponse<Map<String, Object>> weeklyCharts(@PathVariable("id") Long id) {
var data = stockService.findWeeklyRecent(id, 50);
var xList = new ArrayList<String>();
var yList = new ArrayList<List<Double>>();
for (var weekly : data) {
xList.add(weekly.tradeDate().toString());
yList.add(List.of(weekly.open(), weekly.close(), weekly.low(), weekly.high()));
}
return GlobalResponse.responseMapData(Map.of(
"xList", xList, "yList", yList
));
}
@SuppressWarnings("DuplicatedCode")
@GetMapping("monthly/{id}")
public GlobalResponse<Map<String, Object>> monthlyCharts(@PathVariable("id") Long id) {
var data = stockService.findMonthlyRecent(id, 24);
var xList = new ArrayList<String>();
var yList = new ArrayList<List<Double>>();
for (var monthly : data) {
xList.add(monthly.tradeDate().toString());
yList.add(List.of(monthly.open(), monthly.close(), monthly.low(), monthly.high()));
}
return GlobalResponse.responseMapData(Map.of(
"xList", xList, "yList", yList
));
}
@Override
protected Function<Void, Stock> saveItemMapper() {
throw new UnsupportedOperationException();