|
@@ -15,15 +15,17 @@
|
|
*/
|
|
*/
|
|
package com.baomidou.mybatisplus.generator.config.po;
|
|
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.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
|
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
|
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
|
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>
|
|
* <p>
|
|
@@ -33,12 +35,14 @@ import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
|
* @author YangHu
|
|
* @author YangHu
|
|
* @since 2016/8/30
|
|
* @since 2016/8/30
|
|
*/
|
|
*/
|
|
|
|
+@Data
|
|
|
|
+@Accessors(chain = true)
|
|
public class TableInfo {
|
|
public class TableInfo {
|
|
|
|
|
|
|
|
+ private final Set<String> importPackages = new HashSet<>();
|
|
private boolean convert;
|
|
private boolean convert;
|
|
private String name;
|
|
private String name;
|
|
private String comment;
|
|
private String comment;
|
|
-
|
|
|
|
private String entityName;
|
|
private String entityName;
|
|
private String mapperName;
|
|
private String mapperName;
|
|
private String xmlName;
|
|
private String xmlName;
|
|
@@ -50,14 +54,14 @@ public class TableInfo {
|
|
* 公共字段
|
|
* 公共字段
|
|
*/
|
|
*/
|
|
private List<TableField> commonFields;
|
|
private List<TableField> commonFields;
|
|
- private final Set<String> importPackages = new HashSet<>();
|
|
|
|
private String fieldNames;
|
|
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)) {
|
|
if (strategyConfig.containsTablePrefix(name)) {
|
|
// 包含前缀
|
|
// 包含前缀
|
|
this.convert = true;
|
|
this.convert = true;
|
|
@@ -75,93 +79,20 @@ public class TableInfo {
|
|
this.convert = true;
|
|
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() {
|
|
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.entityName = entityName;
|
|
this.setConvert(strategyConfig);
|
|
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)) {
|
|
if (CollectionUtils.isNotEmpty(fields)) {
|
|
this.fields = 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);
|
|
importPackages.add(pkg);
|
|
|
|
+ return this;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 逻辑删除
|
|
* 逻辑删除
|
|
*/
|
|
*/
|
|
public boolean isLogicDelete(String logicDeletePropertyName) {
|
|
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() {
|
|
public String getFieldNames() {
|
|
if (StringUtils.isEmpty(fieldNames)) {
|
|
if (StringUtils.isEmpty(fieldNames)) {
|
|
@@ -234,5 +153,4 @@ public class TableInfo {
|
|
}
|
|
}
|
|
return fieldNames;
|
|
return fieldNames;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|