From 0b4f717fa85abb69a3ae21311a6f6e79e366b01a Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Tue, 23 Aug 2022 14:46:51 +0800 Subject: [PATCH] mark for pull --- .../basic/controller/FactoryController.java | 1 - .../cnbm/generator/build/CodeGenerator.java | 94 ++----------------- 2 files changed, 7 insertions(+), 88 deletions(-) diff --git a/ym-baisc/src/main/java/com/cnbm/basic/controller/FactoryController.java b/ym-baisc/src/main/java/com/cnbm/basic/controller/FactoryController.java index d205682..b799d0c 100644 --- a/ym-baisc/src/main/java/com/cnbm/basic/controller/FactoryController.java +++ b/ym-baisc/src/main/java/com/cnbm/basic/controller/FactoryController.java @@ -56,7 +56,6 @@ public class FactoryController { //@PreAuthorize("@ex.hasAuthority('code:factory:page')") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = factoryService.page(params); - return new Result>().ok(page); } diff --git a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java index 8f5f41f..d28c853 100644 --- a/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java +++ b/ym-generator/src/main/java/com/cnbm/generator/build/CodeGenerator.java @@ -1,21 +1,13 @@ package com.cnbm.generator.build; import com.baomidou.mybatisplus.generator.FastAutoGenerator; -import com.baomidou.mybatisplus.generator.config.*; -import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder; -import com.baomidou.mybatisplus.generator.config.po.TableInfo; -import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; -import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine; -import com.baomidou.mybatisplus.generator.function.ConverterFileName; import com.cnbm.generator.config.DataConfig; import com.cnbm.generator.engine.EnhanceVelocityTemplateEngine; -import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Test; import java.io.File; -import java.util.*; - -import static com.baomidou.mybatisplus.generator.config.ConstVal.MODULE_NAME; +import java.util.HashMap; +import java.util.Map; /** * @Author weihongyang @@ -27,7 +19,7 @@ public class CodeGenerator { @Test public void test(){ - mybatisPlusGenerator(new String[]{"product_features"}); + mybatisPlusGenerator(new String[]{"product_type"}); } public static void mybatisPlusGenerator(String[] include){ @@ -36,9 +28,9 @@ public class CodeGenerator { Map customFile = new HashMap<>(); customFile.put("DTO","/templates/DTO.java.vm"); customFile.put("Excel","/templates/Excel.java.vm"); + customFile.put("mysql","/templates/mysql.vm"); + -// customFile.put("Excel","/templates/excel.java.vm"); -// new TemplateConfig.Builder().serviceImpl("/templates/serviceImpl.java"); FastAutoGenerator.create(DataConfig.url,DataConfig.username,DataConfig.password) .globalConfig(builder -> { builder.author("why") @@ -62,86 +54,14 @@ public class CodeGenerator { builder.addInclude(include) //设置过滤表前缀 .addTablePrefix("sys_") -// .entityBuilder().formatFileName("%sEntity") -// .mapperBuilder().formatMapperFileName("%sMapper").formatXmlFileName("%sMapper") -// .controllerBuilder().formatFileName("%sController").enableRestStyle() -// .serviceBuilder().formatServiceFileName("%sService").formatServiceImplFileName("%sServiceImpl") - ; + //添加逻辑删除列 + .entityBuilder().logicDeleteColumnName("valid").build(); }) .injectionConfig(consumer -> { consumer.customFile(customFile); }) .templateEngine(new EnhanceVelocityTemplateEngine()) -// .templateEngine(new VelocityTemplateEngine(){ -// @Override -// protected void outputCustomFile(@NotNull Map customFile, @NotNull TableInfo tableInfo, @NotNull Map objectMap) { -// //存放取出的实体名称,用于生成路由 -// List entityNames = new ArrayList<>(); -// -// if (!entityNames.contains(tableInfo.getEntityName())) { -// entityNames.add(tableInfo.getEntityName()); -// } -// -// customFile.forEach((key, value) -> { -// String fileName = String.format(path + "/src/main/resources/static/" + tableInfo.getEntityName() + File.separator + tableInfo.getEntityName() + "%s", key); -// this.outputFile(new File(fileName), objectMap, ""); -// }); -// -// // 生成路由部分 -// Map routers = new HashMap<>(); -// routers.put("author", "why"); -// routers.put("date", new Date()); -// routers.put("entities", entityNames); -// -// // 使用 freemarker 模板引擎,路由页面路径 -// String templateRoutesPath = "/templates/DTO.java.vm"; -// -// // 生成的路由页面路径 -// File templateRoutesOutFile = new File(path + "/src/main/java/com/cnbm/generator/engine/"+tableInfo.getEntityName() +"DTO.java"); -// try { -// this.writer(routers, templateRoutesPath, templateRoutesOutFile); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } -// }) - - -// .templateEngine(new FreemarkerTemplateEngine(){ -// @Override -// protected void outputCustomFile(@NotNull Map customFile, @NotNull TableInfo tableInfo, @NotNull Map objectMap) { -// //存放取出的实体名称,用于生成路由 -// List entityNames = new ArrayList<>(); -// -// if (!entityNames.contains(tableInfo.getEntityName())) { -// entityNames.add(tableInfo.getEntityName()); -// } -// -// customFile.forEach((key, value) -> { -// String fileName = String.format(path + "/src/main/resources/static/" + tableInfo.getEntityName() + File.separator + tableInfo.getEntityName() + "%s", key); -// this.outputFile(new File(fileName), objectMap, ""); -// }); -// -// // 生成路由部分 -// Map routers = new HashMap<>(); -// routers.put("author", "why"); -// routers.put("date", new Date()); -// routers.put("entities", entityNames); -// -// // 使用 freemarker 模板引擎,路由页面路径 -// String templateRoutesPath = "/templates/excel.java.ftl"; -// -// // 生成的路由页面路径 -// File templateRoutesOutFile = new File(path + "/src/main/java/com/cnbm/generator/engine/excel.java"); -// try { -// this.writer(routers, templateRoutesPath, templateRoutesOutFile); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } -// -// }) .execute(); }