Commit 106fb729 authored by xiemouren's avatar xiemouren

增加DeleteGenerateFiles工具类

parent 47a1954e
......@@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
class CodeGenerator {
public static void main(String[] args) {
......@@ -71,7 +70,7 @@ class CodeGenerator {
@Override
public String outputFile(TableInfo tableInfo) {
//TODO 改动
// return projectPath + "/src/main/resources/mapper/" + pc.getModuleName() + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
// return projectPath + "/src/main/resources/mapper/" + pc.getModuleName() + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
return projectPath + "/src/main/resources/mapper/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
}
});
......
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 删除生成的文件
* Created by XGL on 2022/4/21
*/
public class DeleteGenerateFiles {
public static void main(String[] args) {
String projectPath = System.getProperty("user.dir");
String path1 = projectPath + "/src/main/java/com";
String path2 = projectPath + "/src/main/resources/mapper";
List<String> pathList = new ArrayList<>(Arrays.asList(path1, path2));
for (String path : pathList) {
boolean result = deleteDir(new File(path));
if (result) {
System.out.println(path + "路径下的文件批量删除成功!");
} else {
System.out.println(path + "路径下的文件批量删除失败!");
}
}
}
public static boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
return dir.delete();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment