yanyang #9
@ -56,7 +56,6 @@ public class FactoryController {
|
||||
//@PreAuthorize("@ex.hasAuthority('code:factory:page')")
|
||||
public Result<PageData<FactoryDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
PageData<FactoryDTO> page = factoryService.page(params);
|
||||
|
||||
return new Result<PageData<FactoryDTO>>().ok(page);
|
||||
}
|
||||
|
||||
|
@ -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[]{"my_interpretation_scheme"});
|
||||
mybatisPlusGenerator(new String[]{"product_type"});
|
||||
}
|
||||
|
||||
public static void mybatisPlusGenerator(String[] include){
|
||||
@ -36,9 +28,9 @@ public class CodeGenerator {
|
||||
Map<String, String> 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<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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user