feat: 增加股票现价显示,日线改为后复权数据
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.lanyuanxiaoyao.leopard.server.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Daily;
|
||||
import com.lanyuanxiaoyao.leopard.core.entity.Stock;
|
||||
import com.lanyuanxiaoyao.leopard.core.helper.NumberHelper;
|
||||
import com.lanyuanxiaoyao.leopard.core.service.StockService;
|
||||
@@ -108,6 +109,18 @@ public class StockController extends SimpleControllerSupport<Stock, Void, StockD
|
||||
));
|
||||
}
|
||||
|
||||
@GetMapping("daily/current/{id}")
|
||||
public GlobalResponse<Map<String, Object>> dailyCurrent(@PathVariable("id") Long id) {
|
||||
var daily = stockService.findDailyLatest(id);
|
||||
return GlobalResponse.responseMapData(Map.of(
|
||||
"date", daily.map(Daily::getTradeDate).map(LocalDate::toString).orElse("/"),
|
||||
"open", daily.map(Daily::getOpen).map(NumberHelper::formatPriceDouble).orElse(NumberHelper.FINANCE_NULL_DOUBLE),
|
||||
"close", daily.map(Daily::getClose).map(NumberHelper::formatPriceDouble).orElse(NumberHelper.FINANCE_NULL_DOUBLE),
|
||||
"low", daily.map(Daily::getLow).map(NumberHelper::formatPriceDouble).orElse(NumberHelper.FINANCE_NULL_DOUBLE),
|
||||
"high", daily.map(Daily::getHigh).map(NumberHelper::formatPriceDouble).orElse(NumberHelper.FINANCE_NULL_DOUBLE)
|
||||
));
|
||||
}
|
||||
|
||||
@GetMapping("daily/{id}")
|
||||
public GlobalResponse<Map<String, Object>> dailyCharts(@PathVariable("id") Long id) {
|
||||
var data = stockService.findDailyRecent(id, 100);
|
||||
@@ -115,7 +128,7 @@ public class StockController extends SimpleControllerSupport<Stock, Void, StockD
|
||||
var yList = new ArrayList<List<Double>>();
|
||||
for (var daily : data) {
|
||||
xList.add(daily.getTradeDate().toString());
|
||||
yList.add(List.of(daily.getOpen(), daily.getClose(), daily.getLow(), daily.getHigh()));
|
||||
yList.add(List.of(daily.getHfqOpen(), daily.getHfqClose(), daily.getHfqLow(), daily.getHfqHigh()));
|
||||
}
|
||||
return GlobalResponse.responseMapData(Map.of(
|
||||
"xList", xList, "yList", yList
|
||||
|
||||
Reference in New Issue
Block a user