|
|
@@ -2,6 +2,7 @@ package com.liangjiang.price_collection.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.liangjiang.price_collection.dto.BackupsInfo;
|
|
|
+import com.liangjiang.price_collection.dto.ExchangeCoinDto;
|
|
|
import com.liangjiang.price_collection.dto.PriceDto;
|
|
|
import com.liangjiang.price_collection.dto.PriceInfoDto;
|
|
|
import com.liangjiang.price_collection.mapper.TableMapper;
|
|
|
@@ -70,21 +71,36 @@ public class TableServiceImpl implements ITableService {
|
|
|
return tableMapper.getTableName();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean initExchange(ExchangeCoinDto dto){
|
|
|
+ if(dto ==null || CollectionUtil.isEmpty(dto.getCoin())){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ Set<String> tableNames = new HashSet<>();
|
|
|
+ dto.getCoin().forEach(coin -> {
|
|
|
+ String tableName = String.format("%s_%s_%s", coin.replaceAll("_", ""), dto.getSource(), dto.getB_type()).toUpperCase();
|
|
|
+ tableNames.add(tableName);
|
|
|
+ });
|
|
|
+ // 建表
|
|
|
+ this.tableMapper.createTables(tableNames);
|
|
|
+ return true;
|
|
|
+ }catch (Exception ex){
|
|
|
+ log.error("建表初始化失败!", ex);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void savePriceBatch(List<PriceInfoDto> dtos){
|
|
|
if(CollectionUtil.isEmpty(dtos)){
|
|
|
return;
|
|
|
}
|
|
|
- Set<String> tableNames = new HashSet<>();
|
|
|
List<BackupsInfo> addDtos = new LinkedList<>();
|
|
|
dtos.forEach(dto -> {
|
|
|
- String tableName = String.format("%s_%s_%s", dto.getCoin().replaceAll("_", ""), dto.getSource(), dto.getB_type()).toUpperCase();
|
|
|
- tableNames.add(tableName);
|
|
|
addDtos.add(dto.convertAdd());
|
|
|
});
|
|
|
try {
|
|
|
- // 建表
|
|
|
- this.tableMapper.createTables(tableNames);
|
|
|
// 写入数据
|
|
|
this.tableMapper.savePrices(addDtos);
|
|
|
} catch (Exception ex){
|