ソースを参照

规范注释提交

JiahengHe 1 年間 前
コミット
8b9e2f0999

+ 6 - 1
price_collection/src/main/java/com/liangjiang/price_collection/dto/PriceInfoDto.java

@@ -4,11 +4,16 @@ import lombok.Data;
 
 @Data
 public class PriceInfoDto {
+    // 交易所
     private String source;
-    // swap spot
+    // 合约还是现货 swap spot
     private String type;
+    // 币对
     private String coin;
+    // 时间戳 秒级
     private Integer time;
+    // 买价
     private String bid;
+    // 卖价
     private String ask;
 }

+ 2 - 2
price_collection/src/main/java/com/liangjiang/price_collection/service/impl/TableServiceImpl.java

@@ -24,7 +24,7 @@ public class TableServiceImpl implements ITableService {
 
     @Override
     public boolean createTable(String source, String coin, String type){
-        String tableName = String.format("%s_%s_%s", source, coin, type).toUpperCase();
+        String tableName = String.format("%s_%s_%s", source, coin.replaceAll("_", ""), type).toUpperCase();
         synchronized (interner.intern(tableName)){
             try {
                 tableMapper.createTable(tableName);
@@ -48,7 +48,7 @@ public class TableServiceImpl implements ITableService {
 
     @Override
     public void savePrice(PriceInfoDto dto){
-        String tableName = String.format("%s_%s_%s", dto.getSource(), dto.getCoin(), dto.getType()).toUpperCase();
+        String tableName = String.format("%s_%s_%s", dto.getSource(), dto.getCoin().replaceAll("_", ""), dto.getType()).toUpperCase();
         try {
             // 尝试先写入
             this.tableMapper.savePrice(tableName, dto.getTime(), dto.getAsk(), dto.getBid());

+ 1 - 1
price_collection/src/main/resources/mapper/TableMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.liangjiang.price_collection.mapper.TableMapper">
     <!-- 创建数据表 -->
     <update id="createTable" parameterType="java.lang.String">
-        CREATE TABLE ${tableName} (
+        CREATE TABLE IF NOT EXISTS ${tableName} (
          `id` INT UNSIGNED NOT NULL,
          `bid` VARCHAR(128) NOT NULL,
          `ask` VARCHAR(128) NOT NULL,

BIN
price_collection/target/classes/com/liangjiang/price_collection/service/impl/TableServiceImpl.class


+ 1 - 1
price_collection/target/classes/mapper/TableMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.liangjiang.price_collection.mapper.TableMapper">
     <!-- 创建数据表 -->
     <update id="createTable" parameterType="java.lang.String">
-        CREATE TABLE ${tableName} (
+        CREATE TABLE IF NOT EXISTS ${tableName} (
          `id` INT UNSIGNED NOT NULL,
          `bid` VARCHAR(128) NOT NULL,
          `ask` VARCHAR(128) NOT NULL,