package com.nq.controller;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.nq.common.ServerResponse;
|
import com.nq.pojo.SiteSetting;
|
import com.nq.service.IStockService;
|
import com.nq.service.StockDzService;
|
import com.nq.utils.redis.RedisKeyConstant;
|
import com.nq.utils.redis.RedisShardedPoolUtils;
|
import com.nq.utils.translate.GoogleTranslateUtil;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.HashMap;
|
|
@Controller
|
@RequestMapping({"/api/stock/"})
|
public class StockApiController {
|
private static final Logger log = LoggerFactory.getLogger(StockApiController.class);
|
|
@Autowired
|
IStockService iStockService;
|
@Autowired
|
StockDzService stockDzService;
|
|
//查询 股票指数、大盘指数信息
|
@RequestMapping({"getMarket.do"})
|
@ResponseBody
|
public ServerResponse getMarket() {
|
return this.iStockService.getMarket();
|
}
|
|
//查询官网PC端交易 所有股票信息及指定股票信息
|
@RequestMapping({"getStock.do"})
|
@ResponseBody
|
public ServerResponse getStock(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize, @RequestParam(value = "stockPlate", required = false) String stockPlate, @RequestParam(value = "stockType", required = false) String stockType, @RequestParam(value = "keyWords", required = false) String keyWords, HttpServletRequest request) throws Exception {
|
return this.iStockService.getStock(pageNum, pageSize, keyWords, stockPlate, stockType, request);
|
}
|
|
|
|
@RequestMapping("getStockByType.do")
|
@ResponseBody
|
public ServerResponse getStockByType(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
|
@RequestParam(value = "orderBy", required = false) String orderBy,
|
@RequestParam(value = "stockType", required = false) String stockType,
|
@RequestParam(value = "keyWords", required = false) String keyWords,
|
HttpServletRequest request) {
|
return this.iStockService.getStockByType(pageNum, pageSize, orderBy,keyWords , stockType, request);
|
}
|
|
@RequestMapping("getGoldCrudeOil.do")
|
@ResponseBody
|
public ServerResponse getGoldCrudeOil(HttpServletRequest request) {
|
|
String gold = RedisShardedPoolUtils.get(RedisKeyConstant.XAUUSD);
|
String crudeOil = RedisShardedPoolUtils.get(RedisKeyConstant.USOIL);
|
|
HashMap<String,HashMap> hashMap = new HashMap<>();
|
|
HashMap<String,String> goldMap = new HashMap<>();
|
goldMap.put("XAUUSD",gold);
|
goldMap.put("hcrate",RedisShardedPoolUtils.get("XAUUSD"+"_H"));
|
goldMap.put("hcrateP",RedisShardedPoolUtils.get("XAUUSD"+"_H")+"%");
|
hashMap.put("XAUUSD",goldMap);
|
|
HashMap<String,String> crudOilMap = new HashMap<>();
|
crudOilMap.put("USOIL",crudeOil);
|
crudOilMap.put("hcrate",RedisShardedPoolUtils.get("USOIL"+"_H"));
|
crudOilMap.put("hcrateP",RedisShardedPoolUtils.get("USOIL"+"_H")+"%");
|
hashMap.put("USOIL",crudOilMap);
|
|
return ServerResponse.createBySuccess(hashMap);
|
}
|
|
|
|
@RequestMapping("getOptionStock.do")
|
@ResponseBody()
|
public ServerResponse getOptionStock(HttpServletRequest request){
|
return this.iStockService.getOptionStock(request);
|
}
|
|
|
//通过股票代码查询股票信息
|
@RequestMapping({"getSingleStock.do"})
|
@ResponseBody
|
public ServerResponse getSingleStock(@RequestParam("code") String code, HttpServletRequest request) throws JsonProcessingException {
|
return this.iStockService.getSingleStock(code, request);
|
}
|
|
|
/*查询股票日线*/
|
@RequestMapping({"getKData.do"})
|
@ResponseBody
|
public Object getKData(
|
@RequestParam("pid") String pid,
|
@RequestParam("interval") String interval,
|
@RequestParam("stockType") String stockType,
|
HttpServletRequest request
|
) {
|
try {
|
return this.iStockService.getKData(pid,interval,stockType);
|
}catch (Exception e){
|
log.error("获取k线失败",e.getMessage());
|
}
|
return ServerResponse.createByErrorMsg("获取k线失败",request);
|
}
|
|
|
|
|
/**
|
*大宗交易 列表
|
*/
|
@PostMapping({"getDzList.do"})
|
@ResponseBody
|
public ServerResponse getDzList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
@RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
|
@RequestParam(value = "orderBy", required = false) String orderBy,
|
@RequestParam(value = "keyWords", required = false) String keyWords,
|
HttpServletRequest request) {
|
return stockDzService.getDzList(pageNum, pageSize, orderBy,keyWords , request);
|
}
|
|
|
/**
|
* vip 抢筹列表
|
*/
|
@PostMapping({"getVipList.do"})
|
@ResponseBody
|
public ServerResponse getVipList(String password) {
|
return this.iStockService.ztb(password);
|
}
|
|
/**
|
* vip 抢筹根据股票代码查询
|
* @param code
|
* @return
|
*/
|
|
@PostMapping({"getVipByCode.do"})
|
@ResponseBody
|
public ServerResponse getVipByCode(String code) {
|
return this.iStockService.getVipByCode(code);
|
}
|
}
|