feat: 增加月线周线蜡烛图
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user