|
@@ -2,6 +2,7 @@ package com.liangjiang.price_collection.controller;
|
|
|
|
|
|
|
|
import com.liangjiang.price_collection.dto.ExchangeCoinPriceArrDto;
|
|
import com.liangjiang.price_collection.dto.ExchangeCoinPriceArrDto;
|
|
|
import com.liangjiang.price_collection.dto.PriceInfoDto;
|
|
import com.liangjiang.price_collection.dto.PriceInfoDto;
|
|
|
|
|
+import com.liangjiang.price_collection.dto.PriceListDto;
|
|
|
import com.liangjiang.price_collection.service.ITableService;
|
|
import com.liangjiang.price_collection.service.ITableService;
|
|
|
import com.liangjiang.price_collection.service.impl.QueryService;
|
|
import com.liangjiang.price_collection.service.impl.QueryService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -37,38 +38,24 @@ public class ApiController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/getPrices")
|
|
@GetMapping("/getPrices")
|
|
|
- public List<ExchangeCoinPriceArrDto> getPriceRest(@RequestParam("exchange") String exchange, @RequestParam("coin")String coin){
|
|
|
|
|
|
|
+ public PriceListDto getPriceRest(@RequestParam("exchange") String exchange, @RequestParam("coin")String coin){
|
|
|
Integer[] times = QueryService.getDaysAgoTime(System.currentTimeMillis(), 3L);
|
|
Integer[] times = QueryService.getDaysAgoTime(System.currentTimeMillis(), 3L);
|
|
|
try {
|
|
try {
|
|
|
return queryService.performQueries(exchange.split(","), coin, times[1], times[0]);
|
|
return queryService.performQueries(exchange.split(","), coin, times[1], times[0]);
|
|
|
} catch (Exception ex){
|
|
} catch (Exception ex){
|
|
|
log.error("查询出错", ex);
|
|
log.error("查询出错", ex);
|
|
|
- return new LinkedList<>();
|
|
|
|
|
|
|
+ return PriceListDto.builder().time(new LinkedList<>()).values(new LinkedList<>()).build();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @GetMapping("/getPricesRest")
|
|
|
|
|
- public List<ExchangeCoinPriceArrDto> getPrices(@RequestParam("exchange") String exchange, @RequestParam("coin")String coin){
|
|
|
|
|
- System.out.println("exchange = " + exchange + ", coin = " + coin);
|
|
|
|
|
- List<ExchangeCoinPriceArrDto> result = new LinkedList<>();
|
|
|
|
|
- ExchangeCoinPriceArrDto dto1 = ExchangeCoinPriceArrDto.builder().exchange("BINANCE_SPOT").symbol("BTCUSDT").ask(new LinkedList<>()).bid(new LinkedList<>()).time(new LinkedList<>()).build();
|
|
|
|
|
- ExchangeCoinPriceArrDto dto2 = ExchangeCoinPriceArrDto.builder().exchange("GATE_SPOT").symbol("BTCUSDT").ask(new LinkedList<>()).bid(new LinkedList<>()).time(new LinkedList<>()).build();
|
|
|
|
|
- int time = 1565613908;
|
|
|
|
|
- for (int i = 1; i < 5; i ++){
|
|
|
|
|
- int x = i * 2 + 1;
|
|
|
|
|
- int y = i * 2 - 2;
|
|
|
|
|
- dto1.getAsk().add(Integer.toString(x));
|
|
|
|
|
- dto1.getBid().add(Integer.toString(y));
|
|
|
|
|
- dto1.getTime().add(time);
|
|
|
|
|
- int x1 = i * 2;
|
|
|
|
|
- int y1 = i * 2 - 1;
|
|
|
|
|
- dto2.getAsk().add(Integer.toString(x1));
|
|
|
|
|
- dto2.getBid().add(Integer.toString(y1));
|
|
|
|
|
- dto2.getTime().add(time);
|
|
|
|
|
- time ++;
|
|
|
|
|
|
|
+ @GetMapping("/getAddPrices")
|
|
|
|
|
+ public PriceListDto getAddPrices(@RequestParam("exchange") String exchange, @RequestParam("coin")String coin,@RequestParam("startTime") Integer startTime){
|
|
|
|
|
+ Integer endTime = Math.toIntExact(System.currentTimeMillis()/1000);
|
|
|
|
|
+ try {
|
|
|
|
|
+ return queryService.performQueries(exchange.split(","), coin, startTime, endTime);
|
|
|
|
|
+ } catch (Exception ex){
|
|
|
|
|
+ log.error("查询出错", ex);
|
|
|
|
|
+ return PriceListDto.builder().time(new LinkedList<>()).values(new LinkedList<>()).build();
|
|
|
}
|
|
}
|
|
|
- result.add(dto1);
|
|
|
|
|
- result.add(dto2);
|
|
|
|
|
- return result;
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|