Browse Source

fixed gitee/I10XWC 允许根据 TableField 信息判断自定义类型

hubin 6 years ago
parent
commit
a502206f16

+ 14 - 0
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/ITypeConvert.java

@@ -15,6 +15,7 @@
  */
 package com.baomidou.mybatisplus.generator.config;
 
+import com.baomidou.mybatisplus.generator.config.po.TableField;
 import com.baomidou.mybatisplus.generator.config.rules.IColumnType;
 
 /**
@@ -26,6 +27,19 @@ import com.baomidou.mybatisplus.generator.config.rules.IColumnType;
 public interface ITypeConvert {
 
 
+    /**
+     * 执行类型转换
+     *
+     * @param globalConfig 全局配置
+     * @param tableField   字段列信息
+     * @return ignore
+     */
+    default IColumnType processTypeConvert(GlobalConfig globalConfig, TableField tableField) {
+        // 该方法提供重写
+        return processTypeConvert(globalConfig, tableField.getType());
+    }
+
+
     /**
      * 执行类型转换
      *

+ 1 - 1
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/ConfigBuilder.java

@@ -622,7 +622,7 @@ public class ConfigBuilder {
                     } else {
                         field.setPropertyName(strategyConfig, processName(field.getName(), config.getNaming()));
                     }
-                    field.setColumnType(dataSourceConfig.getTypeConvert().processTypeConvert(globalConfig, field.getType()));
+                    field.setColumnType(dataSourceConfig.getTypeConvert().processTypeConvert(globalConfig, field));
                     if (commentSupported) {
                         field.setComment(results.getString(dbQuery.fieldComment()));
                     }