From d61072f997839b4564ce35132d5902a1b6f7d54f Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 03 Aug 2020 17:39:10 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/modules/symbols/controller/SymbolsController.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/symbols/controller/SymbolsController.java b/src/main/java/com/xcong/excoin/modules/symbols/controller/SymbolsController.java
index f5e87f8..64fe133 100644
--- a/src/main/java/com/xcong/excoin/modules/symbols/controller/SymbolsController.java
+++ b/src/main/java/com/xcong/excoin/modules/symbols/controller/SymbolsController.java
@@ -1,22 +1,25 @@
package com.xcong.excoin.modules.symbols.controller;
+import com.huobi.client.model.Candlestick;
import com.xcong.excoin.common.response.Result;
+import com.xcong.excoin.modules.symbols.parameter.dto.KlineDetailDto;
+import com.xcong.excoin.modules.symbols.parameter.vo.HomeSymbolsVo;
+import com.xcong.excoin.modules.symbols.parameter.vo.KlineDataVo;
import com.xcong.excoin.modules.symbols.service.SymbolsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiModelProperty;
-import io.swagger.annotations.ApiOperation;
+import com.xcong.excoin.utils.RedisUtils;
+import com.xcong.excoin.utils.TypeJudgeUtils;
+import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import javax.validation.Valid;
/**
* @author wzy
* @date 2020-05-28
**/
-@Api(value = "币种相关轮询接口类", tags = "币种相关轮询接口类")
+@Api(value = "K线以及币种相关轮询接口类", tags = "K线以及币种相关轮询接口类")
@Slf4j
@RestController
@RequestMapping(value = "/api/symbols")
@@ -25,9 +28,44 @@
@Resource
private SymbolsService symbolsService;
+ @Resource
+ private RedisUtils redisUtils;
+
@ApiOperation(value = "轮询获取app首页币种交易信息", notes = "轮询获取app首页币种交易信息")
+ @ApiResponses({
+ @ApiResponse(code = 0, message = "success", response = HomeSymbolsVo.class)
+ })
@GetMapping(value = "/homeSymbols")
- public Result homeSymbols(Integer type) {
+ public Result homeSymbols(@ApiParam(name = "type", value = "类型1-币币2-合约3-自选", required = true, example = "1") @RequestParam(value = "type") Integer type) {
return symbolsService.homeSymbols(type);
}
+
+ @ApiOperation(value = "根据币种查询币种当前各种数据", notes = "根据币种查询币种当前各种数据")
+ @ApiResponses({
+ @ApiResponse(code = 0, message = "success", response = HomeSymbolsVo.class)
+ })
+ @GetMapping(value = "/findSymbolData")
+ public Result findSymbolData(@ApiParam(name = "symbol", value = "币种", required = true, example = "BTC/USDT") @RequestParam(value = "symbol") String symbol) {
+ return symbolsService.findSymbolData(symbol);
+ }
+
+ @ApiOperation(value = "查询历史K线数据", notes = "查询历史K线数据")
+ @ApiResponses({
+ @ApiResponse(code = 0, message = "success", response = KlineDataVo.class)
+ })
+ @PostMapping(value = "/klineDetail")
+ public Result klineDetail(@RequestBody @Valid KlineDetailDto klineDetailDto) {
+ if (!TypeJudgeUtils.klinePeriod(klineDetailDto.getPeriod())) {
+ return Result.fail("非法参数");
+ }
+ return symbolsService.findKlineDetails(klineDetailDto);
+ }
+
+ @ApiOperation(value = "查询当日最高最低价")
+ @GetMapping(value = "/getDayHighAndLow")
+ public Result getDayHighAndLow(@ApiParam(name = "symbol", value = "币种", required = true, example = "BTC/USDT") @RequestParam(value = "symbol") String symbol) {
+ Candlestick object = (Candlestick) redisUtils.get(symbol);
+ return Result.ok(object);
+ }
+
}
--
Gitblit v1.9.1