| | |
| | | import org.example.pojo.bo.CurrencyMexcBo; |
| | | import org.example.server.impl.CurrencySerivceImpl; |
| | | import org.example.util.ConverterUtil; |
| | | import org.example.util.RedisUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | Gson gson = new Gson(); |
| | | List<CurrencyMexcBo> getList = gson.fromJson(symbolsJson, new TypeToken<List<CurrencyMexcBo>>() { |
| | | }.getType()); |
| | | List<Currency> dbList = currencyService.list(new LambdaQueryWrapper<Currency>().eq(Currency::getSource, "mexc")); |
| | | Set<String> symbolSet = dbList.stream().map(Currency::getSymbol).collect(Collectors.toSet()); |
| | | List<Currency> removeList = dbList.stream() |
| | | .filter(currency -> !symbolSet.contains(currency.getSymbol())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | if(CollectionUtils.isNotEmpty(removeList)){ |
| | | removeList.forEach(f->{ |
| | | RedisUtil.delete("mexc"+f.getSymbol()); |
| | | }); |
| | | } |
| | | currencyService.remove(new LambdaQueryWrapper<Currency>().eq(Currency::getSource,"mexc")); |
| | | List<Currency> currencies = ConverterUtil.convertToList(getList, Currency.class); |
| | | // 批量保存新增数据到数据库 |