Merge remote-tracking branch 'origin/master'

pull/1/head
陈沅 2 years ago
commit 602b8a2d0b

@ -12,7 +12,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
@Bean
@Bean(name = "redisTemplate")
public RedisTemplate<String, Object> template(RedisConnectionFactory factory) {
// 创建RedisTemplate<String, Object>对象
RedisTemplate<String, Object> template = new RedisTemplate<>();

@ -1,5 +1,6 @@
package com.sztzjy.forex.trading_trading.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.sztzjy.forex.trading_trading.annotation.AnonymousAccess;
import com.sztzjy.forex.trading_trading.annotation.Permission;
@ -15,11 +16,11 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.util.List;
@Api(tags = "实训任务用户管理")
@ -35,10 +36,20 @@ public class MemberController {
TrainingService trainingService;
@AnonymousAccess
@PostMapping("getMember")
public Member getMember(@RequestBody String memberId) {
@PostMapping("getMemberById")
public ResultEntity getMember(@RequestBody String memberId) {
Member member = memberService.selectByPrimaryKey(memberId);
return member;
return new ResultEntity(HttpStatus.OK, "根据成员ID获取成员对象",member);
}
@AnonymousAccess
@PostMapping("getMember")
public ResultEntity getMemberId(@RequestBody JSONObject jsonObject) {
String name = jsonObject.getString("name");
String trainingId = jsonObject.getString("trainingId");
Integer schoolId = jsonObject.getInteger("schoolId");
Member member = memberService.selectByNameAndSchoolIdAndTrainingID(name, schoolId, trainingId);
return new ResultEntity(HttpStatus.OK, "获取成员ID",member);
}
@Permission(codes = PermissionType.TRAINING_MANAGEMENT_SEARCH)

@ -1,6 +1,7 @@
package com.sztzjy.forex.trading_trading.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONObject;
import com.sztzjy.forex.trading_trading.annotation.AnonymousAccess;
import com.sztzjy.forex.trading_trading.entity.PendingOrder;
@ -80,6 +81,8 @@ public class PendingOrderController {
//保存挂单 挂单保存后 将挂单ID和有效期存入redis
public void insertPendingOrder(PendingOrder pendingOrder){
String uuid = IdUtil.simpleUUID();
pendingOrder.setPendingOrderId(uuid);
pendingOrderService.insert(pendingOrder);
redisUtil.set("pengingOrder_"+pendingOrder.getPendingOrderId(),pendingOrder.getValidityTime());
}

@ -3,17 +3,23 @@ package com.sztzjy.forex.trading_trading.controller;
import com.alibaba.fastjson.JSONObject;
import com.sztzjy.forex.trading_trading.annotation.AnonymousAccess;
import com.sztzjy.forex.trading_trading.dto.TakeStashVO;
import com.sztzjy.forex.trading_trading.entity.TakeStash;
import com.sztzjy.forex.trading_trading.entity.TakeStashExample;
import com.sztzjy.forex.trading_trading.entity.mql5Entity.ForexData;
import com.sztzjy.forex.trading_trading.service.TakeStashService;
import io.swagger.annotations.ApiOperation;
import com.sztzjy.forex.trading_trading.util.RedisUtil;
import com.sztzjy.forex.trading_trading.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("api/takeStash")
@ -22,19 +28,24 @@ public class TakeStashController {
@Autowired
TakeStashService takeStashService;
@Autowired
RedisUtil redisUtil;
@Autowired
TradingController tradingController;
//获取当前持仓表 status 0为获取当前持仓/1为挂单持仓/2为历史持仓
@AnonymousAccess
@PostMapping("getTakeStashList")
public List<TakeStash> getTakeStashList(@RequestBody JSONObject jsonObject) {
String trainingId = String.valueOf(jsonObject.get("trainingId"));
String memberId = String.valueOf(jsonObject.get("memberId"));
Integer status = (Integer) jsonObject.get("status");
TakeStash takeStash = new TakeStash();
takeStash.setTrainingId(trainingId);
takeStash.setMemberId(memberId);
takeStash.setStatus(status);
List<TakeStash> takeStashList = takeStashService.findTakeStashByTrainingIdAndMemberIdAndStatus(trainingId, memberId, status);
return takeStashList;
public ResultEntity getTakeStashList(@RequestBody TakeStash takeStash) {
List<TakeStash> takeStashList = takeStashService.findTakeStashByTrainingIdAndMemberIdAndStatus(takeStash.getTrainingId(),takeStash.getMemberId(), takeStash.getStatus());
List<TakeStashVO> takeStashVOList=new ArrayList<>();
for (int i = 0; i < takeStashList.size(); i++) {
TakeStashVO takeStashVO=new TakeStashVO(takeStashList.get(i));
takeStashVOList.add(takeStashVO);
}
takeStashVOList = flashProfitAndLoss(takeStashVOList).getBody().getData();
return new ResultEntity(HttpStatus.OK, "返回持仓数据",takeStashVOList);
}
//根据持仓ID获取单个持仓数据
@ -45,4 +56,92 @@ public class TakeStashController {
TakeStash takeStash = takeStashService.selectByPrimaryKey(trainingId);
return takeStash;
}
//持仓盈亏和当前价格刷新
@AnonymousAccess
@PostMapping("flashProfitAndLoss")
public ResultEntity<List<TakeStashVO>> flashProfitAndLoss(@RequestBody List<TakeStashVO> takeStashVOList){
List<TakeStashVO> takeStashVOS=new ArrayList<>();
List<ForexData> forexDateList = redisUtil.get("ForexDateList");
Map<String,ForexData> map=new HashMap<>();
if (forexDateList.size() > 0) {
for (int i = 0; i < forexDateList.size(); i++) {
String getCode = forexDateList.get(i).getString("code");
map.put(getCode,forexDateList.get(i));
}
}
for (int i = 0; i < takeStashVOList.size(); i++) {
TakeStashVO takeStashVO = takeStashVOList.get(i);
String buySellType = takeStashVO.getBuySellType(); //买入或卖出
String tradingCode = takeStashVO.getTradingCode(); //交易品种
Double priceTransaction = takeStashVO.getPriceTransaction(); //交易价格
Double volumeTransaction = takeStashVO.getVolumeTransaction(); //交易量
ForexData forexData = map.get(tradingCode);
Double nowBuyPic = Double.valueOf(forexData.getString("buyPic")); //当前买价
Double nowSellPic = Double.valueOf(forexData.getString("sellPic")); //当前卖价
Double profitAndLoss;
if (tradingCode.startsWith("USD")) { //美元在前
if("buy".equals(buySellType)){ //买
profitAndLoss= (nowBuyPic-priceTransaction)*volumeTransaction*100000/nowBuyPic;
takeStashVO.setCurrentPrice(nowBuyPic);
}else { //卖
profitAndLoss= (nowSellPic-priceTransaction)*volumeTransaction*100000/nowSellPic;
takeStashVO.setCurrentPrice(nowSellPic);
}
}else { //美元在后
if("buy".equals(buySellType)){ //买
profitAndLoss= (nowBuyPic-priceTransaction)*volumeTransaction*100000;
takeStashVO.setCurrentPrice(nowBuyPic);
}else { //卖
profitAndLoss= (nowSellPic-priceTransaction)*volumeTransaction*100000;
takeStashVO.setCurrentPrice(nowSellPic);
}
}
takeStashVO.setProfitAndLoss(profitAndLoss);
takeStashVOS.add(takeStashVO);
}
return new ResultEntity(HttpStatus.OK, "持仓盈亏和当前价格刷新",takeStashVOList);
}
//修改当前持仓
@AnonymousAccess
@PostMapping("updateTakeStash")
public ResultEntity updateTakeStash(@RequestBody JSONObject jsonObject) {
String stashId = jsonObject.getString("stashId");
Double stopLoss = jsonObject.getDouble("stopLoss");
Double stopWin = jsonObject.getDouble("stopWin");
String tradingCode = jsonObject.getString("tradingCode");
String buySellType = jsonObject.getString("buySellType");
ForexData forexData = tradingController.getMarketQuotationByCode(tradingCode).getBody().getData();
if (null != stopLoss || null != stopWin) { //判断止损止赢是否合理 如果stopLoss stopWin都为null则跳过
boolean winOrLossStopBoolean = tradingController.getWinOrLossStop(stopLoss, stopWin, buySellType, forexData);
if (winOrLossStopBoolean == false) {
return new ResultEntity(HttpStatus.UNAUTHORIZED, "止损或获利输入错误");
}
}
TakeStash takeStash = new TakeStash();
takeStash.setStashId(stashId);
takeStash.setStopLoss(stopLoss);
takeStashService.updateByPrimaryKey(takeStash);
return new ResultEntity(HttpStatus.OK, "修改持仓成功");
}
//当前持仓平仓 status设置为2
public ResultEntity closeTakeStash(@RequestBody JSONObject jsonObject) {
String stashId = jsonObject.getString("stashId");
TakeStash takeStash = new TakeStash();
takeStash.setStashId(stashId);
takeStash.setStatus(2);
takeStashService.updateByPrimaryKey(takeStash);
return new ResultEntity(HttpStatus.OK, "平仓成功");
}
//持仓止损止盈刷新
}

@ -11,7 +11,9 @@ import com.sztzjy.forex.trading_trading.entity.mql5Entity.ForexData;
import com.sztzjy.forex.trading_trading.service.MemberService;
import com.sztzjy.forex.trading_trading.service.TakeStashService;
import com.sztzjy.forex.trading_trading.util.RedisUtil;
import com.sztzjy.forex.trading_trading.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -41,41 +43,61 @@ public class TradingController {
@AnonymousAccess
@PostMapping("getMarketQuotation")
public List<ForexData> getMarketQuotation() {
boolean bool = redisUtil.hasKey("ForexDateList");
if (bool == true) {
List<ForexData> forexDateList = redisUtil.get("ForexDateList");
return forexDateList;
}
Mql5API mql5API = new Mql5API();
List<ForexData> marketQuotation = mql5API.getMarketQuotation();
redisUtil.set("ForexDateList", marketQuotation);
return marketQuotation;
}
//根据交易类型获取实时数据
@AnonymousAccess
@PostMapping("getMarketQuotationByCode")
public ForexData getMarketQuotationByCode(@RequestBody String code) {
public ResultEntity<ForexData> getMarketQuotationByCode(@RequestBody String code) {
boolean bool = redisUtil.hasKey("ForexDateList");
if (bool == true) {
List<ForexData> forexDateList = redisUtil.get("ForexDateList");
if (forexDateList.size() > 0) {
for (int i = 0; i < forexDateList.size(); i++) {
String getCode = forexDateList.get(i).getString("code");
if (code.equals(getCode)) {
return new ResultEntity(HttpStatus.OK, "获取成功",forexDateList.get(i));
}
}
}
}
Mql5API mql5API = new Mql5API();
ForexData forexData = mql5API.getMarketQuotationByCode(code);
return forexData;
List<ForexData> marketQuotation = mql5API.getMarketQuotation();
redisUtil.set("ForexDateList", marketQuotation);
return new ResultEntity(HttpStatus.OK, "获取成功",forexData);
}
//市场报价交易 交易量为1为1000美元
@AnonymousAccess
@PostMapping("transactionMarketQuotation")
public JSONObject getMarketQuotation(@RequestBody JSONObject jsonObject) {
String tradingCode = String.valueOf(jsonObject.get("tradingCode")); //交易品种
String transactionType = String.valueOf(jsonObject.get("transactionType")); //交易类型
Double transactionVolume = (Double) jsonObject.get("transactionVolume"); //买卖手(量)
String buySellType = String.valueOf(jsonObject.get("buySellType")); //买入卖出类型
Double stopLoss = (Double) jsonObject.get("stopLoss");
Double stopWin = (Double) jsonObject.get("stopWin");
String memberId = String.valueOf(jsonObject.get("memberId"));
String trainingId = jsonObject.get("trainingId").toString();
public ResultEntity getMarketQuotation(@RequestBody JSONObject jsonObject) {
String tradingCode = jsonObject.getString("tradingCode"); //交易品种
String transactionType = jsonObject.getString("transactionType"); //交易类型
Double transactionVolume = jsonObject.getDouble("transactionVolume"); //买卖手(量)
String buySellType = jsonObject.getString("buySellType");//买入卖出类型
Double stopLoss = jsonObject.getDouble("stopLoss");
Double stopWin = jsonObject.getDouble("stopWin");
String memberId = jsonObject.getString("memberId");
String trainingId = jsonObject.getString("trainingId");
Member member = memberService.getMemberByMemberIdAndTrainingId(memberId, trainingId);
Double availableFunds = member.getAvailableFunds(); //获取账户可用资金
ForexData forexData = getMarketQuotationByCode(tradingCode); //获取当前买卖价格
Double buyPic = Double.valueOf(forexData.getBuyPic()); //当前买价
Double sellPic = Double.valueOf(forexData.getSellPic());
ForexData forexData = getMarketQuotationByCode(tradingCode).getBody().getData(); //获取当前买卖价格
Double buyPic = Double.valueOf(forexData.getString("buyPic"));//当前买价
Double sellPic = Double.valueOf(forexData.getString("sellPic"));//当前买价
if (null != stopLoss || null != stopWin) { //判断止损止赢是否合理 如果stopLoss stopWin都为null则跳过
boolean winOrLossStopBoolean = getWinOrLossStop(stopLoss, stopWin, buySellType, forexData);
if (winOrLossStopBoolean == false) {
return JSONObject.parseObject("止损或获利输入错误");
return new ResultEntity(HttpStatus.UNAUTHORIZED, "止损或获利输入错误");
}
}
@ -83,7 +105,7 @@ public class TradingController {
if (transactionType.equals("sjkc")) {//市价开仓
if (tradingCode.startsWith("USD")) { //美元在前
if (availableFunds < transactionVolume * 1000) { //判断可用资金是否足够
return JSONObject.parseObject("可用资金不足");
return new ResultEntity(HttpStatus.UNAUTHORIZED, "可用资金不足");
}
if ("buy".equals(buySellType)) {
TakeStash takeStash = returnTakeStash(memberId, trainingId, tradingCode, buySellType, transactionVolume, buyPic, stopLoss, stopWin);
@ -97,14 +119,14 @@ public class TradingController {
} else { //美元在后 使用可用资金表达式为 买卖手*1000*卖/买价 判断可用资金是否足够 先判断是买还是卖
if ("buy".equals(buySellType)) {
if (availableFunds < transactionVolume * 1000 * buyPic) {
return JSONObject.parseObject("可用资金不足");
return new ResultEntity(HttpStatus.UNAUTHORIZED, "可用资金不足");
}
TakeStash takeStash = returnTakeStash(memberId, trainingId, tradingCode, buySellType, transactionVolume, buyPic, stopLoss, stopWin);
takeStashService.insertTakeStash(takeStash);
availableFunds = availableFunds - transactionVolume * 1000 * buyPic;
} else if ("sell".equals(buySellType)) {
if (availableFunds < transactionVolume * 1000 * sellPic) {
return JSONObject.parseObject("可用资金不足");
return new ResultEntity(HttpStatus.UNAUTHORIZED, "可用资金不足");
}
TakeStash takeStash = returnTakeStash(memberId, trainingId, tradingCode, buySellType, transactionVolume, sellPic, stopLoss, stopWin);
takeStashService.insertTakeStash(takeStash);
@ -113,65 +135,36 @@ public class TradingController {
updateMemberAvailableFundsAndMarginUsed(member, availableFunds);
}
} else if (transactionType.equals("gdkc")) {//挂单开仓 生成的数据为挂单数据 挂单数据生效 判断可用资金是否充足
Double priceCommission = (Double) jsonObject.get("priceCommission"); //获取用户输入的价位
Date validityTime = (Date) jsonObject.get("validityTime"); //获取挂单有效期
Double priceCommission = jsonObject.getDouble("priceCommission");//获取用户输入的价位
Date validityTime = jsonObject.getDate("validityTime"); //获取挂单有效期
if ("buyLimit".equals(buySellType)) { //限价买进(低价买进) 下单时买入价低于当前买价
if (priceCommission >= buyPic) {
return JSONObject.parseObject("限价买进价位不能高于当前买价");
return new ResultEntity(HttpStatus.UNAUTHORIZED, "限价买进价位不能高于当前买价");
}
}
if ("sellLimit".equals(buySellType)) {//限价卖出(高价卖出) 下单时卖出价高于当前卖价
if (priceCommission <= sellPic) {
return JSONObject.parseObject("限价卖出价位不能低于当前卖价");
return new ResultEntity(HttpStatus.UNAUTHORIZED, "限价卖出价位不能低于当前卖价");
}
}
if ("buyStop".equals(buySellType)) {//止损买进(高价买进) 下单时买入价格高于当前买价
if (priceCommission <= buyPic) {
return JSONObject.parseObject("止损买进价位不能低于当前买价");
return new ResultEntity(HttpStatus.UNAUTHORIZED, "止损买进价位不能低于当前买价");
}
}
if ("sellStop".equals(buySellType)) {//止损卖出(低价卖出)下单时卖出价格低于当前卖价
if (priceCommission >= sellPic) {
return JSONObject.parseObject("止损卖出价位不能高于当前卖价");
return new ResultEntity(HttpStatus.UNAUTHORIZED, "止损卖出价位不能高于当前卖价");
}
}
PendingOrder pendingOrder = pendingOrderController.returnPendingOrder(memberId, trainingId, tradingCode, buySellType, transactionVolume, priceCommission, stopLoss, stopWin, validityTime);
pendingOrderController.insertPendingOrder(pendingOrder);//保存挂单
}
JSONObject returnJson = JSONObject.parseObject("error");
return returnJson;
}
//修改当前持仓
@AnonymousAccess
@PostMapping("updateTakeStash")
public JSONObject updateTakeStash(@RequestBody JSONObject jsonObject) {
String stashId = String.valueOf(jsonObject.get("stashId"));
Double stopLoss = (Double) jsonObject.get("stopLoss");
Double stopWin = (Double) jsonObject.get("stopWin");
String tradingCode = String.valueOf(jsonObject.get("tradingCode"));
String buySellType = String.valueOf(jsonObject.get("buySellType"));
ForexData forexData = getMarketQuotationByCode(tradingCode);
if (null != stopLoss || null != stopWin) { //判断止损止赢是否合理 如果stopLoss stopWin都为null则跳过
boolean winOrLossStopBoolean = getWinOrLossStop(stopLoss, stopWin, buySellType, forexData);
if (winOrLossStopBoolean == false) {
return JSONObject.parseObject("止损或获利输入错误");
}
}
TakeStash takeStash = new TakeStash();
takeStash.setStashId(stashId);
takeStash.setStopLoss(stopLoss);
takeStashService.updateByPrimaryKey(takeStash);
return JSONObject.parseObject("修改持仓成功");
return new ResultEntity(HttpStatus.OK, "交易成功");
}
//当前持仓平仓 status设置为2
public JSONObject pingcangTakeStash(@RequestBody JSONObject jsonObject) {
return null;
}
//返回持仓对象
private TakeStash returnTakeStash(String memberId, String trainingId, String tradingCode, String buySellType, Double transactionVolume, Double buyOrSellPic, Double stopLoss, Double stopWin) {
@ -201,7 +194,7 @@ public class TradingController {
}
//判断止损止赢 逻辑:如果方式为买 则止损低于买价 获利高于买价 / 如果方式为卖 则止损高于卖价 获利低于买价 (可以只传一个参数)
private boolean getWinOrLossStop(Double stopLoss, Double stopWin, String buySellType, ForexData forexData) {
public boolean getWinOrLossStop(Double stopLoss, Double stopWin, String buySellType, ForexData forexData) {
if ("buy".equals(buySellType)) {
Double buyPic = Double.valueOf(forexData.getBuyPic());
//判断stopLoss 和stopWin 是否为空

@ -1,7 +1,6 @@
package com.sztzjy.forex.trading_trading.controller;
import com.sun.org.apache.regexp.internal.RE;
import com.sztzjy.forex.trading_trading.annotation.AnonymousAccess;
import com.sztzjy.forex.trading_trading.annotation.OperateLog;
import com.sztzjy.forex.trading_trading.config.security.JwtUser;

@ -0,0 +1,60 @@
package com.sztzjy.forex.trading_trading.dto;
import com.sztzjy.forex.trading_trading.entity.TakeStash;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Data
@Getter
@Setter
public class TakeStashVO {
public TakeStashVO() {
// 无参数的默认构造函数
}
public TakeStashVO(TakeStash takeStash){
this.stashId = takeStash.getStashId();
this.memberId = takeStash.getMemberId();
this.trainingId = takeStash.getTrainingId();
this.tradingCode = takeStash.getTradingCode();
this.orderNumber = takeStash.getOrderNumber();
this.buySellType = takeStash.getBuySellType();
this.volumeTransaction = takeStash.getVolumeTransaction();
this.priceTransaction = takeStash.getPriceTransaction();
this.stopLoss = takeStash.getStopLoss();
this.stopWin = takeStash.getStopWin();
this.timeTransaction = takeStash.getTimeTransaction();
this.status = takeStash.getStatus();
}
private String stashId;
private String memberId;
private String trainingId;
private String tradingCode;
private String orderNumber;
private String buySellType;
private Double volumeTransaction;
private Double priceTransaction;
private Double stopLoss;
private Double stopWin;
private Date timeTransaction;
private Integer status;
private Double currentPrice;
private Double profitAndLoss;
}

@ -1,7 +1,14 @@
package com.sztzjy.forex.trading_trading.entity;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Data
@Getter
@Setter
public class TakeStash {
/**
*

@ -9,6 +9,8 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface TakeStashMapper {
List<TakeStash> selectByTakeStash(TakeStash takeStash);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table sys_take_stash

@ -139,4 +139,12 @@ public class MemberService {
public List<Map<String, Object>> classScoreTrend(Integer schoolId) {
return memberMapper.classScoreTrend(schoolId);
}
public Member selectByNameAndSchoolIdAndTrainingID(String name,Integer schoolId,String trainingId){
MemberExample example=new MemberExample();
MemberExample.Criteria criteria = example.createCriteria();
criteria.andSchoolIdEqualTo(schoolId).andNameEqualTo(name).andTrainingIdEqualTo(trainingId);
List<Member> members = memberMapper.selectByExample(example);
return members.get(0);
}
}

@ -1,5 +1,6 @@
package com.sztzjy.forex.trading_trading.service;
import cn.hutool.core.util.IdUtil;
import com.sztzjy.forex.trading_trading.entity.MemberExample;
import com.sztzjy.forex.trading_trading.entity.TakeStash;
import com.sztzjy.forex.trading_trading.entity.TakeStashExample;
@ -15,9 +16,15 @@ public class TakeStashService {
TakeStashMapper takeStashMapper;
public void insertTakeStash(TakeStash takeStash){
takeStash.setStashId(IdUtil.simpleUUID());
takeStashMapper.insert(takeStash);
}
public List<TakeStash> selectByTakeStash(TakeStash takeStash){
List<TakeStash> takeStashes = takeStashMapper.selectByTakeStash(takeStash);
return takeStashes;
}
public List<TakeStash> findTakeStashByTrainingIdAndMemberIdAndStatus(String trainingId, String memberId, Integer status) {
TakeStashExample example=new TakeStashExample();
TakeStashExample.Criteria criteria = example.createCriteria();

@ -0,0 +1,27 @@
package com.sztzjy.forex.trading_trading.task;
import com.sztzjy.forex.trading_trading.common.mql5API.Mql5API;
import com.sztzjy.forex.trading_trading.entity.mql5Entity.ForexData;
import com.sztzjy.forex.trading_trading.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@EnableScheduling
public class redisTask {
@Autowired
RedisUtil redisUtil;
@Scheduled(fixedDelay = 1278000) // 每隔1278秒执行一次
public void doTask() {
System.out.println("!!!!");
Mql5API mql5API = new Mql5API();
List<ForexData> marketQuotation = mql5API.getMarketQuotation();
redisUtil.set("ForexDateList", marketQuotation);
}
}

@ -1,398 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sztzjy.forex.trading_trading.TrainingMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.forex.trading_trading.Training">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
<id column="training_id" jdbcType="VARCHAR" property="trainingId" />
<result column="people_count" jdbcType="INTEGER" property="peopleCount" />
<result column="start_time" jdbcType="VARCHAR" property="startTime" />
<result column="end_time" jdbcType="VARCHAR" property="endTime" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="creator_id" jdbcType="INTEGER" property="creatorId" />
<result column="create_school" jdbcType="VARCHAR" property="createSchool" />
<result column="training_name" jdbcType="VARCHAR" property="trainingName" />
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="school_id" jdbcType="INTEGER" property="schoolId" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
training_id, people_count, start_time, end_time, status, creator_id, create_school,
training_name, creator_name, create_time, update_time, school_id
</sql>
<select id="selectByExample" parameterType="com.sztzjy.forex.trading_trading.TrainingExample" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from sys_training
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
select
<include refid="Base_Column_List" />
from sys_training
where training_id = #{trainingId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
delete from sys_training
where training_id = #{trainingId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.forex.trading_trading.TrainingExample">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
delete from sys_training
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.forex.trading_trading.Training">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
insert into sys_training (training_id, people_count, start_time,
end_time, status, creator_id,
create_school, training_name, creator_name,
create_time, update_time, school_id
)
values (#{trainingId,jdbcType=VARCHAR}, #{peopleCount,jdbcType=INTEGER}, #{startTime,jdbcType=VARCHAR},
#{endTime,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{creatorId,jdbcType=INTEGER},
#{createSchool,jdbcType=VARCHAR}, #{trainingName,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{schoolId,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.forex.trading_trading.Training">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
insert into sys_training
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="trainingId != null">
training_id,
</if>
<if test="peopleCount != null">
people_count,
</if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="status != null">
status,
</if>
<if test="creatorId != null">
creator_id,
</if>
<if test="createSchool != null">
create_school,
</if>
<if test="trainingName != null">
training_name,
</if>
<if test="creatorName != null">
creator_name,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="schoolId != null">
school_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="trainingId != null">
#{trainingId,jdbcType=VARCHAR},
</if>
<if test="peopleCount != null">
#{peopleCount,jdbcType=INTEGER},
</if>
<if test="startTime != null">
#{startTime,jdbcType=VARCHAR},
</if>
<if test="endTime != null">
#{endTime,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="creatorId != null">
#{creatorId,jdbcType=INTEGER},
</if>
<if test="createSchool != null">
#{createSchool,jdbcType=VARCHAR},
</if>
<if test="trainingName != null">
#{trainingName,jdbcType=VARCHAR},
</if>
<if test="creatorName != null">
#{creatorName,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="schoolId != null">
#{schoolId,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.forex.trading_trading.TrainingExample" resultType="java.lang.Long">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
select count(*) from sys_training
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
update sys_training
<set>
<if test="record.trainingId != null">
training_id = #{record.trainingId,jdbcType=VARCHAR},
</if>
<if test="record.peopleCount != null">
people_count = #{record.peopleCount,jdbcType=INTEGER},
</if>
<if test="record.startTime != null">
start_time = #{record.startTime,jdbcType=VARCHAR},
</if>
<if test="record.endTime != null">
end_time = #{record.endTime,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.creatorId != null">
creator_id = #{record.creatorId,jdbcType=INTEGER},
</if>
<if test="record.createSchool != null">
create_school = #{record.createSchool,jdbcType=VARCHAR},
</if>
<if test="record.trainingName != null">
training_name = #{record.trainingName,jdbcType=VARCHAR},
</if>
<if test="record.creatorName != null">
creator_name = #{record.creatorName,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.schoolId != null">
school_id = #{record.schoolId,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
update sys_training
set training_id = #{record.trainingId,jdbcType=VARCHAR},
people_count = #{record.peopleCount,jdbcType=INTEGER},
start_time = #{record.startTime,jdbcType=VARCHAR},
end_time = #{record.endTime,jdbcType=VARCHAR},
status = #{record.status,jdbcType=VARCHAR},
creator_id = #{record.creatorId,jdbcType=INTEGER},
create_school = #{record.createSchool,jdbcType=VARCHAR},
training_name = #{record.trainingName,jdbcType=VARCHAR},
creator_name = #{record.creatorName,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
school_id = #{record.schoolId,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.forex.trading_trading.Training">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
update sys_training
<set>
<if test="peopleCount != null">
people_count = #{peopleCount,jdbcType=INTEGER},
</if>
<if test="startTime != null">
start_time = #{startTime,jdbcType=VARCHAR},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=VARCHAR},
</if>
<if test="creatorId != null">
creator_id = #{creatorId,jdbcType=INTEGER},
</if>
<if test="createSchool != null">
create_school = #{createSchool,jdbcType=VARCHAR},
</if>
<if test="trainingName != null">
training_name = #{trainingName,jdbcType=VARCHAR},
</if>
<if test="creatorName != null">
creator_name = #{creatorName,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="schoolId != null">
school_id = #{schoolId,jdbcType=INTEGER},
</if>
</set>
where training_id = #{trainingId,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.forex.trading_trading.Training">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Fri Jun 30 14:37:06 CST 2023.
-->
update sys_training
set people_count = #{peopleCount,jdbcType=INTEGER},
start_time = #{startTime,jdbcType=VARCHAR},
end_time = #{endTime,jdbcType=VARCHAR},
status = #{status,jdbcType=VARCHAR},
creator_id = #{creatorId,jdbcType=INTEGER},
create_school = #{createSchool,jdbcType=VARCHAR},
training_name = #{trainingName,jdbcType=VARCHAR},
creator_name = #{creatorName,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
school_id = #{schoolId,jdbcType=INTEGER}
where training_id = #{trainingId,jdbcType=VARCHAR}
</update>
</mapper>

@ -116,6 +116,7 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated

Loading…
Cancel
Save