|
|
@@ -1,62 +0,0 @@ |
|
|
|
package com.cnbm.generator.engine; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.generator.config.OutputFile; |
|
|
|
import com.baomidou.mybatisplus.generator.config.po.TableInfo; |
|
|
|
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine; |
|
|
|
import com.cnbm.generator.utils.IdWorker; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author weihongyang |
|
|
|
* @Date 2022/6/17 10:27 AM |
|
|
|
* @Version 1.0 |
|
|
|
*/ |
|
|
|
public class EnhanceVelocityTemplateEngine extends VelocityTemplateEngine { |
|
|
|
@Override |
|
|
|
protected void outputCustomFile(@NotNull Map<String, String> customFile, @NotNull TableInfo tableInfo, @NotNull Map<String, Object> objectMap) { |
|
|
|
String entityName = tableInfo.getEntityName(); |
|
|
|
System.out.println(entityName); |
|
|
|
// String otherPath = this.getPathInfo(OutputFile.other); |
|
|
|
File file = new File(""); |
|
|
|
String path = file.getAbsolutePath(); |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
objectMap.put("id"+ i, IdWorker.getId()); |
|
|
|
} |
|
|
|
customFile.forEach((key, value) -> { |
|
|
|
String fileName = ""; |
|
|
|
if ("DTO".equals(key)) { |
|
|
|
fileName = String.format((path+ File.separator +"src/main/java/com/cnbm/generator/code"+ File.separator + "dto" + File.separator + entityName + "%s" + ".java"), key); |
|
|
|
} |
|
|
|
if ("Excel".equals(key)) { |
|
|
|
fileName = String.format((path+ File.separator +"src/main/java/com/cnbm/generator/code"+ File.separator + "excel" + File.separator + entityName + "%s" + ".java"), key); |
|
|
|
} |
|
|
|
if ("mysql".equals(key)) { |
|
|
|
fileName = String.format((path+ File.separator +"src/main/java/com/cnbm/generator/code"+ File.separator + "mysql" + File.separator + entityName + "%s" + ".sql"), key); |
|
|
|
} |
|
|
|
this.outputFile(new File(fileName), objectMap, value); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// @Override |
|
|
|
// public void writer(Map<String, Object> objectMap, String templatePath, File outputFile) throws Exception { |
|
|
|
// // 获取table |
|
|
|
// TableInfo tableInfo = (TableInfo) objectMap.get("table"); |
|
|
|
// // 取出Service接口的名字,进行首字母小写处理 |
|
|
|
// String serviceNameFirstWord = tableInfo.getServiceName().substring(0,1).toLowerCase(); |
|
|
|
// String serviceNameFirstWordToLower = serviceNameFirstWord + tableInfo.getServiceName().substring(1); |
|
|
|
// objectMap.put("serviceNameFirstWordToLower", serviceNameFirstWordToLower); |
|
|
|
// |
|
|
|
// // 取出mapper接口的名字,进行首字母小写处理 |
|
|
|
// String mapperNameFirstWord = tableInfo.getMapperName().substring(0, 1).toLowerCase(); |
|
|
|
// String mapperNameFirstWordToLower = mapperNameFirstWord + tableInfo.getMapperName().substring(1); |
|
|
|
// objectMap.put("mapperNameFirstWordToLower", mapperNameFirstWordToLower); |
|
|
|
// |
|
|
|
// // 对Form、VO文件的处理 |
|
|
|
//// new FormHandler().handler(objectMap); |
|
|
|
// super.writer(objectMap, templatePath, outputFile); |
|
|
|
// } |
|
|
|
|
|
|
|
} |