| | |
| | | package com.nq.controller.backend; |
| | | |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.pojo.Stock; |
| | | import com.nq.pojo.StockAI; |
| | | import com.nq.pojo.StockAIOrderPosition; |
| | | import com.nq.service.IStockAiService; |
| | | import com.nq.service.IStockService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | 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 org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 后台AI产品api |
| | |
| | | |
| | | @Autowired |
| | | IStockAiService stockAiService; |
| | | @Autowired |
| | | IStockService stockService; |
| | | /** |
| | | * 获取ai交易产品列表 |
| | | * @return |
| | |
| | | @ResponseBody |
| | | public ServerResponse getStockAiList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, |
| | | @RequestParam(value = "pageSize", defaultValue = "5") int pageSize, |
| | | @RequestParam(value = "stockType") String stockType, |
| | | @RequestParam(value = "status") String status, |
| | | @RequestParam(value = "name") String name) { |
| | | @RequestParam(value = "stockType", required = false) String stockType, |
| | | @RequestParam(value = "status", required = false) String status, |
| | | @RequestParam(value = "name", required = false) String name) { |
| | | return stockAiService.getAdminStockAiList(pageNum, pageSize, stockType, status, name); |
| | | } |
| | | |
| | | //修改票信息 |
| | | @RequestMapping({"editStockAi.do"}) |
| | | //编辑ai交易产品 |
| | | @PostMapping({"editStockAi.do"}) |
| | | @ResponseBody |
| | | public ServerResponse editStockAi(StockAI model) { |
| | | |
| | | return stockAiService.editStockAi(model); |
| | | } |
| | | |
| | | /** |
| | | * 获取ai交易产品订单列表 |
| | | * @return |
| | | */ |
| | | @RequestMapping("getStockAiOrderList.do") |
| | | @ResponseBody |
| | | public ServerResponse getStockAiOrderList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, |
| | | @RequestParam(value = "pageSize", defaultValue = "5") int pageSize, |
| | | @RequestParam(value = "stockType", required = false) String stockType, |
| | | @RequestParam(value = "status", required = false) String status, |
| | | @RequestParam(value = "userId", required = false) Integer userId, |
| | | @RequestParam(value = "phone", required = false) String phone) { |
| | | return stockAiService.getAdminStockAiOrderList(pageNum, pageSize, stockType, status, userId, phone); |
| | | } |
| | | |
| | | /** |
| | | * ai订单建仓 |
| | | * @param model |
| | | * @return |
| | | */ |
| | | @PostMapping({"openPosition.do"}) |
| | | @ResponseBody |
| | | public ServerResponse openPosition(StockAIOrderPosition model) { |
| | | if (model == null) { |
| | | return ServerResponse.createByErrorMsg("model is null"); |
| | | } |
| | | if (model.getStockAiOrderId() == null) { |
| | | return ServerResponse.createByErrorMsg("stockAiOrderId is null"); |
| | | } |
| | | if (model.getStockId() == null || model.getStockNum() == null || model.getStockPrice() == null || |
| | | model.getCoverDate() == null || model.getCoverPrice() == null) { |
| | | return ServerResponse.createByErrorMsg("请输入必填参数"); |
| | | } |
| | | if (model.getStockNum() <= 0) { |
| | | return ServerResponse.createByErrorMsg("建仓股票数量必须大于0"); |
| | | } |
| | | return stockAiService.openPosition(model); |
| | | } |
| | | |
| | | /** |
| | | * ai订单操作 |
| | | * @param id 订单id |
| | | * @param status 通过 拒绝 结算(已完成) |
| | | * @return |
| | | */ |
| | | @GetMapping({"orderOperation.do"}) |
| | | @ResponseBody |
| | | public ServerResponse orderOperation(@RequestParam(value = "id") Long id, |
| | | @RequestParam(value = "status") String status) { |
| | | if (id == null) { |
| | | return ServerResponse.createByErrorMsg("id is null"); |
| | | } |
| | | if (status.isEmpty()) { |
| | | return ServerResponse.createByErrorMsg("status is null"); |
| | | } |
| | | return stockAiService.orderOperation(id, status); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据条件查询股票 |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @param keyWords code 名称 或 spell |
| | | * @return |
| | | */ |
| | | @PostMapping({"getStocksByKeyWords.do"}) |
| | | @ResponseBody |
| | | public ServerResponse getStocksByKeyWords(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, |
| | | @RequestParam(value = "pageSize", defaultValue = "5") int pageSize, |
| | | @RequestParam(value = "keyWords", required = false) String keyWords) { |
| | | return stockService.getStocksByKeyWords(pageNum, pageSize, keyWords); |
| | | } |
| | | |
| | | //建仓列表页 |
| | | @PostMapping({"getPositionList.do"}) |
| | | @ResponseBody |
| | | public ServerResponse getPositionList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, |
| | | @RequestParam(value = "pageSize", defaultValue = "5") int pageSize, |
| | | @RequestParam(value = "id", required = false) Integer stockAiOrderId) { |
| | | if (stockAiOrderId == null) { |
| | | return ServerResponse.createByErrorMsg("id is null"); |
| | | } |
| | | return stockAiService.getPositionList(pageNum, pageSize, stockAiOrderId); |
| | | } |
| | | } |