| | |
| | | private static JedisPool jedisPool; |
| | | |
| | | static { |
| | | jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 6379); |
| | | jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 63790,0, "123456"); |
| | | } |
| | | |
| | | // 私有构造方法,防止实例化 |
| | |
| | | private static JedisPool jedisPool; |
| | | |
| | | static { |
| | | jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 6379); |
| | | jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 63790,0, "123456"); |
| | | } |
| | | |
| | | // 私有构造方法,防止实例化 |
| | |
| | | private static JedisPool jedisPool; |
| | | |
| | | static { |
| | | jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 6379); |
| | | jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 63790,0, "123456"); |
| | | } |
| | | |
| | | // 私有构造方法,防止实例化 |
| | |
| | | private static JedisPool jedisPool; |
| | | |
| | | static { |
| | | jedisPool = new JedisPool(new JedisPoolConfig(), "localhost", 6379); |
| | | JedisPoolConfig poolConfig = new JedisPoolConfig(); |
| | | jedisPool = new JedisPool(poolConfig, "107.148.40.10", 6379, 0, "123456"); |
| | | } |
| | | |
| | | // 私有构造方法,防止实例化 |
| | |
| | | .orderByDesc(Log::getLoginTime)); |
| | | return ServerResponse.createBySuccess(pageList); |
| | | } |
| | | |
| | | @GetMapping("/addMark") |
| | | public ServerResponse addMark(@RequestParam(value = "favorites") String favorites, |
| | | HttpServletRequest request) { |
| | | String token = request.getHeader("token"); |
| | | User user = JwtUtil.verify(token); |
| | | |
| | | if (user == null) { |
| | | // 处理用户验证失败的情况,例如返回未授权错误 |
| | | return ServerResponse.createByErrorMsg("标记失败"); |
| | | } |
| | | |
| | | String mark = RedisUtil.get(user.getId() + "_mark"); |
| | | |
| | | if (StringUtils.isNotEmpty(mark)) { |
| | | // 使用 StringJoiner 或者 StringBuilder 来拼接字符串 |
| | | mark += "," + favorites; |
| | | } else { |
| | | mark = favorites; |
| | | } |
| | | |
| | | // 更新 Redis 中的标记 |
| | | RedisUtil.set(user.getId() + "_mark", mark); |
| | | |
| | | // 返回操作成功的响应 |
| | | return ServerResponse.createBySuccess("标记成功"); |
| | | } |
| | | |
| | | @GetMapping("/deleteMark") |
| | | public ServerResponse deleteMark(@RequestParam(value = "favorites") String favorites, |
| | | HttpServletRequest request) { |
| | | String token = request.getHeader("token"); |
| | | User user = JwtUtil.verify(token); |
| | | |
| | | String mark = RedisUtil.get(user.getId() + "_mark"); |
| | | |
| | | if (StringUtils.isNotEmpty(mark)) { |
| | | // 使用逗号分隔符将标记分割成数组 |
| | | String[] marks = mark.split(","); |
| | | |
| | | // 创建一个新的标记列表,用于存储没有要删除的标记 |
| | | List<String> updatedMarks = new ArrayList<>(); |
| | | |
| | | // 遍历现有的标记,将不等于要删除的标记加入新列表 |
| | | for (String m : marks) { |
| | | if (!m.equals(favorites)) { |
| | | updatedMarks.add(m); |
| | | } |
| | | } |
| | | |
| | | // 将新的标记列表转换为逗号分隔的字符串 |
| | | mark = String.join(",", updatedMarks); |
| | | |
| | | // 更新 Redis 中的标记 |
| | | RedisUtil.set(user.getId() + "_mark", mark); |
| | | |
| | | |
| | | } |
| | | // 返回操作成功的响应 |
| | | return ServerResponse.createBySuccess("取消标记成功"); |
| | | } |
| | | |
| | | } |
| | |
| | | private static void assembleMarketDataOut(String coinName, MarketBo markets1, MarketBo markets2, BigDecimal profitPercentage, BigDecimal buyPrice, BigDecimal sellPrice, List<MarketDataOut> marketDataOuts, String formattedDateTime) { |
| | | MarketDataOut marketDataOut = new MarketDataOut(); |
| | | marketDataOut.setBaseAsset(coinName.replaceAll("USDT","").toLowerCase().toUpperCase()); // 设置基础资产 |
| | | marketDataOut.setBuyingPlatform(markets1.getExchange().toUpperCase()); // 设置买入平台 |
| | | marketDataOut.setSellPlatform(markets2.getExchange().toUpperCase()); // 设置卖出平台 |
| | | marketDataOut.setBuyingPlatform(capitalizeFirstLetter(markets1.getExchange())); // 设置买入平台,首字母大写 |
| | | marketDataOut.setSellPlatform(capitalizeFirstLetter(markets2.getExchange())); // 设置卖出平台,首字母大写 |
| | | marketDataOut.setSpread(profitPercentage.setScale(4, RoundingMode.DOWN).toPlainString()); // 设置利润百分比 |
| | | marketDataOut.setBuyPrice(buyPrice.toPlainString()); // 设置买入价格 |
| | | marketDataOut.setSellPrice(sellPrice.toPlainString()); // 设置卖出价格 |
| | |
| | | marketDataOuts.add(marketDataOut); // 添加到输出列表 |
| | | } |
| | | |
| | | public static String capitalizeFirstLetter(String word) { |
| | | if (word == null || word.isEmpty()) { |
| | | return word; |
| | | } |
| | | return Character.toUpperCase(word.charAt(0)) + word.substring(1); |
| | | } |
| | | |
| | | |
| | | private void pushWs(List<MarketDataOut> marketDataOuts) { |
| | | // String key = "MARKET_Date"; |
| | | // // 创建 Gson 对象 |
| | |
| | | /** |
| | | * 同步mexc交易所交易对 |
| | | */ |
| | | @Scheduled(cron = "0 0/30 * * * ?") |
| | | // @Scheduled(cron = "0 0/30 * * * ?") |
| | | // @Scheduled(cron = "0/10 * * * * ?") |
| | | public void syncCurrency() { |
| | | // 使用Lock来确保同步 |
| | |
| | | .collect(Collectors.toList()); |
| | | } |
| | | //自选标记 |
| | | if(null != wsBo.getIsMarker()){ |
| | | List<String> list = Arrays.asList(wsBo.getIsMarker().split(",")); |
| | | String mark = RedisUtil.get(wsBo.getUserId() + "_mark"); |
| | | if(StringUtils.isNoneEmpty(mark)){ |
| | | List<String> list = Arrays.asList(mark.split(",")); |
| | | redisValueMap.stream() |
| | | .filter(data -> list.contains(data.getBuyAndSell())) |
| | | .forEach(data -> data.setMarker(true)); |
| | |
| | | |
| | | XDB_PATH=/www/wwwroot/csdn-ip2region.xdb |
| | | #XDB_PATH=F:/project/marketData/websocketSerivce/src/main/resources/ip/csdn-ip2region.xdb |
| | | #XDB_PATH=/www/wwwroot/csdn-ip2region.xdb |
| | | XDB_PATH=F:/project/marketData/websocketSerivce/src/main/resources/ip/csdn-ip2region.xdb |
| | | |
| | | redis1.ip=localhost |
| | | redis1.port=6379 |