miemie 6 éve
szülő
commit
e05be58856

+ 3 - 3
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/ConstVal.java

@@ -15,10 +15,10 @@
  */
 package com.baomidou.mybatisplus.generator.config;
 
-import java.nio.charset.Charset;
-
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 
+import java.nio.charset.StandardCharsets;
+
 /**
  * <p>
  * 定义常量
@@ -46,7 +46,7 @@ public interface ConstVal {
     String CONTROLLER_PATH = "controller_path";
 
     String JAVA_TMPDIR = "java.io.tmpdir";
-    String UTF8 = Charset.forName("UTF-8").name();
+    String UTF8 = StandardCharsets.UTF_8.name();
     String UNDERLINE = "_";
 
     String JAVA_SUFFIX = StringPool.DOT_JAVA;

+ 0 - 2
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/FileOutConfig.java

@@ -16,7 +16,6 @@
 package com.baomidou.mybatisplus.generator.config;
 
 import com.baomidou.mybatisplus.generator.config.po.TableInfo;
-
 import lombok.Data;
 import lombok.experimental.Accessors;
 
@@ -49,5 +48,4 @@ public abstract class FileOutConfig {
      * 输出文件
      */
     public abstract String outputFile(TableInfo tableInfo);
-
 }

+ 2 - 11
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/PackageConfig.java

@@ -16,14 +16,13 @@
 package com.baomidou.mybatisplus.generator.config;
 
 
-import java.util.Map;
-
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
-
 import lombok.Data;
 import lombok.experimental.Accessors;
 
+import java.util.Map;
+
 /**
  * <p>
  * 跟包相关的配置项
@@ -40,22 +39,18 @@ public class PackageConfig {
      * 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
      */
     private String parent = "com.baomidou";
-
     /**
      * 父包模块名
      */
     private String moduleName = null;
-
     /**
      * Entity包名
      */
     private String entity = "entity";
-
     /**
      * Service包名
      */
     private String service = "service";
-
     /**
      * Service Impl包名
      */
@@ -64,23 +59,19 @@ public class PackageConfig {
      * Mapper包名
      */
     private String mapper = "mapper";
-
     /**
      * Mapper XML包名
      */
     private String xml = "mapper.xml";
-
     /**
      * Controller包名
      */
     private String controller = "controller";
-
     /**
      * 路径配置信息
      */
     private Map<String, String> pathInfo;
 
-
     /**
      * 父包名
      */

+ 8 - 56
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/TemplateConfig.java

@@ -15,6 +15,11 @@
  */
 package com.baomidou.mybatisplus.generator.config;
 
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.Getter;
+import lombok.experimental.Accessors;
+
 /**
  * <p>
  * 模板路径配置项
@@ -23,8 +28,11 @@ package com.baomidou.mybatisplus.generator.config;
  * @author tzg hubin
  * @since 2017-06-17
  */
+@Data
+@Accessors(chain = true)
 public class TemplateConfig {
 
+    @Getter(AccessLevel.NONE)
     private String entity = ConstVal.TEMPLATE_ENTITY_JAVA;
 
     private String entityKt = ConstVal.TEMPLATE_ENTITY_KT;
@@ -42,60 +50,4 @@ public class TemplateConfig {
     public String getEntity(boolean kotlin) {
         return kotlin ? entityKt : entity;
     }
-
-    public TemplateConfig setEntityKt(String entityKt) {
-        this.entityKt = entityKt;
-        return this;
-    }
-
-    public TemplateConfig setEntity(String entity) {
-        this.entity = entity;
-        return this;
-    }
-
-    public String getService() {
-        return service;
-    }
-
-    public TemplateConfig setService(String service) {
-        this.service = service;
-        return this;
-    }
-
-    public String getServiceImpl() {
-        return serviceImpl;
-    }
-
-    public TemplateConfig setServiceImpl(String serviceImpl) {
-        this.serviceImpl = serviceImpl;
-        return this;
-    }
-
-    public String getMapper() {
-        return mapper;
-    }
-
-    public TemplateConfig setMapper(String mapper) {
-        this.mapper = mapper;
-        return this;
-    }
-
-    public String getXml() {
-        return xml;
-    }
-
-    public TemplateConfig setXml(String xml) {
-        this.xml = xml;
-        return this;
-    }
-
-    public String getController() {
-        return controller;
-    }
-
-    public TemplateConfig setController(String controller) {
-        this.controller = controller;
-        return this;
-    }
-
 }

+ 13 - 78
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableField.java

@@ -15,13 +15,15 @@
  */
 package com.baomidou.mybatisplus.generator.config.po;
 
-import java.util.Map;
-
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.generator.config.StrategyConfig;
 import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
 import com.baomidou.mybatisplus.generator.config.rules.IColumnType;
 import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Map;
 
 /**
  * <p>
@@ -31,6 +33,8 @@ import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
  * @author YangHu
  * @since 2016-12-03
  */
+@Data
+@Accessors(chain = true)
 public class TableField {
 
     private boolean convert;
@@ -50,18 +54,15 @@ public class TableField {
      */
     private Map<String, Object> customMap;
 
-    public boolean isConvert() {
-        return convert;
-    }
-
-    public void setConvert(boolean convert) {
+    public TableField setConvert(boolean convert) {
         this.convert = convert;
+        return this;
     }
 
-    protected void setConvert(StrategyConfig strategyConfig) {
+    protected TableField setConvert(StrategyConfig strategyConfig) {
         if (strategyConfig.isEntityTableFieldAnnotationEnable()) {
             this.convert = true;
-            return;
+            return this;
         }
         if (strategyConfig.isCapitalModeNaming(name)) {
             this.convert = false;
@@ -76,55 +77,13 @@ public class TableField {
                 this.convert = true;
             }
         }
+        return this;
     }
 
-    public boolean isKeyFlag() {
-        return keyFlag;
-    }
-
-    public void setKeyFlag(boolean keyFlag) {
-        this.keyFlag = keyFlag;
-    }
-
-    public boolean isKeyIdentityFlag() {
-        return keyIdentityFlag;
-    }
-
-    public void setKeyIdentityFlag(boolean keyIdentityFlag) {
-        this.keyIdentityFlag = keyIdentityFlag;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public String getPropertyName() {
-        return propertyName;
-    }
-
-    public void setPropertyName(StrategyConfig strategyConfig, String propertyName) {
+    public TableField setPropertyName(StrategyConfig strategyConfig, String propertyName) {
         this.propertyName = propertyName;
         this.setConvert(strategyConfig);
-    }
-
-    public IColumnType getColumnType() {
-        return columnType;
-    }
-
-    public void setColumnType(IColumnType columnType) {
-        this.columnType = columnType;
+        return this;
     }
 
     public String getPropertyType() {
@@ -134,14 +93,6 @@ public class TableField {
         return null;
     }
 
-    public String getComment() {
-        return comment;
-    }
-
-    public void setComment(String comment) {
-        this.comment = comment;
-    }
-
     /**
      * 按JavaBean规则来生成get和set方法
      */
@@ -161,20 +112,4 @@ public class TableField {
         }
         return firstChar.toUpperCase() + setGetName.substring(1);
     }
-
-    public String getFill() {
-        return fill;
-    }
-
-    public void setFill(String fill) {
-        this.fill = fill;
-    }
-
-    public Map<String, Object> getCustomMap() {
-        return customMap;
-    }
-
-    public void setCustomMap(Map<String, Object> customMap) {
-        this.customMap = customMap;
-    }
 }

+ 0 - 5
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableFill.java

@@ -16,7 +16,6 @@
 package com.baomidou.mybatisplus.generator.config.po;
 
 import com.baomidou.mybatisplus.annotation.FieldFill;
-
 import lombok.Data;
 
 /**
@@ -39,10 +38,6 @@ public class TableFill {
      */
     private FieldFill fieldFill;
 
-    private TableFill() {
-        // to do nothing
-    }
-
     public TableFill(String fieldName, FieldFill ignore) {
         this.fieldName = fieldName;
         this.fieldFill = ignore;

+ 24 - 106
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableInfo.java

@@ -15,15 +15,17 @@
  */
 package com.baomidou.mybatisplus.generator.config.po;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.IntStream;
-
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.generator.config.StrategyConfig;
 import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.IntStream;
 
 /**
  * <p>
@@ -33,12 +35,14 @@ import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
  * @author YangHu
  * @since 2016/8/30
  */
+@Data
+@Accessors(chain = true)
 public class TableInfo {
 
+    private final Set<String> importPackages = new HashSet<>();
     private boolean convert;
     private String name;
     private String comment;
-
     private String entityName;
     private String mapperName;
     private String xmlName;
@@ -50,14 +54,14 @@ public class TableInfo {
      * 公共字段
      */
     private List<TableField> commonFields;
-    private final Set<String> importPackages = new HashSet<>();
     private String fieldNames;
 
-    public boolean isConvert() {
-        return convert;
+    public TableInfo setConvert(boolean convert) {
+        this.convert = convert;
+        return this;
     }
 
-    protected void setConvert(StrategyConfig strategyConfig) {
+    protected TableInfo setConvert(StrategyConfig strategyConfig) {
         if (strategyConfig.containsTablePrefix(name)) {
             // 包含前缀
             this.convert = true;
@@ -75,93 +79,20 @@ public class TableInfo {
                 this.convert = true;
             }
         }
-    }
-
-    public void setConvert(boolean convert) {
-        this.convert = convert;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getComment() {
-        return comment;
-    }
-
-    public void setComment(String comment) {
-        this.comment = comment;
+        return this;
     }
 
     public String getEntityPath() {
-        StringBuilder ep = new StringBuilder();
-        ep.append(entityName.substring(0, 1).toLowerCase());
-        ep.append(entityName.substring(1));
-        return ep.toString();
-    }
-
-    public String getEntityName() {
-        return entityName;
-    }
-
-    public void setEntityName(String entityName) {
-        this.entityName = entityName;
+        return entityName.substring(0, 1).toLowerCase() + entityName.substring(1);
     }
 
-    public void setEntityName(StrategyConfig strategyConfig, String entityName) {
+    public TableInfo setEntityName(StrategyConfig strategyConfig, String entityName) {
         this.entityName = entityName;
         this.setConvert(strategyConfig);
+        return this;
     }
 
-    public String getMapperName() {
-        return mapperName;
-    }
-
-    public void setMapperName(String mapperName) {
-        this.mapperName = mapperName;
-    }
-
-    public String getXmlName() {
-        return xmlName;
-    }
-
-    public void setXmlName(String xmlName) {
-        this.xmlName = xmlName;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public void setServiceName(String serviceName) {
-        this.serviceName = serviceName;
-    }
-
-    public String getServiceImplName() {
-        return serviceImplName;
-    }
-
-    public void setServiceImplName(String serviceImplName) {
-        this.serviceImplName = serviceImplName;
-    }
-
-    public String getControllerName() {
-        return controllerName;
-    }
-
-    public void setControllerName(String controllerName) {
-        this.controllerName = controllerName;
-    }
-
-    public List<TableField> getFields() {
-        return fields;
-    }
-
-    public void setFields(List<TableField> fields) {
+    public TableInfo setFields(List<TableField> fields) {
         if (CollectionUtils.isNotEmpty(fields)) {
             this.fields = fields;
             // 收集导入包信息
@@ -189,35 +120,23 @@ public class TableInfo {
                 }
             }
         }
+        return this;
     }
 
-    public List<TableField> getCommonFields() {
-        return commonFields;
-    }
-
-    public void setCommonFields(List<TableField> commonFields) {
-        this.commonFields = commonFields;
-    }
-
-    public Set<String> getImportPackages() {
-        return importPackages;
-    }
-
-    public void setImportPackages(String pkg) {
+    public TableInfo setImportPackages(String pkg) {
         importPackages.add(pkg);
+        return this;
     }
 
     /**
      * 逻辑删除
      */
     public boolean isLogicDelete(String logicDeletePropertyName) {
-        return fields.stream().anyMatch(tf -> tf.getName().equals(logicDeletePropertyName));
+        return fields.parallelStream().anyMatch(tf -> tf.getName().equals(logicDeletePropertyName));
     }
 
     /**
-     * 转换filed实体为xmlmapper中的basecolumn字符串信息
-     *
-     * @return
+     * 转换filed实体为 xml mapper 中的 base column 字符串信息
      */
     public String getFieldNames() {
         if (StringUtils.isEmpty(fieldNames)) {
@@ -234,5 +153,4 @@ public class TableInfo {
         }
         return fieldNames;
     }
-
 }