yanyang #9

Merged
yanyang merged 4 commits from yanyang into master 2022-09-02 16:23:12 +08:00
2 changed files with 7 additions and 88 deletions
Showing only changes of commit 0fb22fa625 - Show all commits

View File

@ -56,7 +56,6 @@ public class FactoryController {
//@PreAuthorize("@ex.hasAuthority('code:factory:page')") //@PreAuthorize("@ex.hasAuthority('code:factory:page')")
public Result<PageData<FactoryDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ public Result<PageData<FactoryDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<FactoryDTO> page = factoryService.page(params); PageData<FactoryDTO> page = factoryService.page(params);
return new Result<PageData<FactoryDTO>>().ok(page); return new Result<PageData<FactoryDTO>>().ok(page);
} }

View File

@ -1,21 +1,13 @@
package com.cnbm.generator.build; package com.cnbm.generator.build;
import com.baomidou.mybatisplus.generator.FastAutoGenerator; 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.config.DataConfig;
import com.cnbm.generator.engine.EnhanceVelocityTemplateEngine; import com.cnbm.generator.engine.EnhanceVelocityTemplateEngine;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.File; import java.io.File;
import java.util.*; import java.util.HashMap;
import java.util.Map;
import static com.baomidou.mybatisplus.generator.config.ConstVal.MODULE_NAME;
/** /**
* @Author weihongyang * @Author weihongyang
@ -27,7 +19,7 @@ public class CodeGenerator {
@Test @Test
public void test(){ public void test(){
mybatisPlusGenerator(new String[]{"my_interpretation_scheme"}); mybatisPlusGenerator(new String[]{"product_type"});
} }
public static void mybatisPlusGenerator(String[] include){ public static void mybatisPlusGenerator(String[] include){
@ -36,9 +28,9 @@ public class CodeGenerator {
Map<String, String> customFile = new HashMap<>(); Map<String, String> customFile = new HashMap<>();
customFile.put("DTO","/templates/DTO.java.vm"); customFile.put("DTO","/templates/DTO.java.vm");
customFile.put("Excel","/templates/Excel.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) FastAutoGenerator.create(DataConfig.url,DataConfig.username,DataConfig.password)
.globalConfig(builder -> { .globalConfig(builder -> {
builder.author("why") builder.author("why")
@ -62,86 +54,14 @@ public class CodeGenerator {
builder.addInclude(include) builder.addInclude(include)
//设置过滤表前缀 //设置过滤表前缀
.addTablePrefix("sys_") .addTablePrefix("sys_")
// .entityBuilder().formatFileName("%sEntity") //添加逻辑删除列
// .mapperBuilder().formatMapperFileName("%sMapper").formatXmlFileName("%sMapper") .entityBuilder().logicDeleteColumnName("valid").build();
// .controllerBuilder().formatFileName("%sController").enableRestStyle()
// .serviceBuilder().formatServiceFileName("%sService").formatServiceImplFileName("%sServiceImpl")
;
}) })
.injectionConfig(consumer -> { .injectionConfig(consumer -> {
consumer.customFile(customFile); consumer.customFile(customFile);
}) })
.templateEngine(new EnhanceVelocityTemplateEngine()) .templateEngine(new EnhanceVelocityTemplateEngine())
// .templateEngine(new VelocityTemplateEngine(){
// @Override
// protected void outputCustomFile(@NotNull Map<String, String> customFile, @NotNull TableInfo tableInfo, @NotNull Map<String, Object> objectMap) {
// //存放取出的实体名称用于生成路由
// List<String> 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<String, Object> 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<String, String> customFile, @NotNull TableInfo tableInfo, @NotNull Map<String, Object> objectMap) {
// //存放取出的实体名称用于生成路由
// List<String> 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<String, Object> 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(); .execute();
} }