This commit is contained in:
parent
ad5b63c50c
commit
facfaf5232
|
@ -66,7 +66,7 @@ public class JwtInterceptor implements HandlerInterceptor {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @date: 2023/2/6 12:46
|
* @date: 2023/2/6 12:46
|
||||||
* @author: zhouzhaodong
|
* @author:
|
||||||
* @description: 访问控制器方法后执行
|
* @description: 访问控制器方法后执行
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,26 +76,12 @@ public class JwtInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @date: 2023/2/6 12:46
|
* @date: 2023/2/6 12:46
|
||||||
* @author: zhouzhaodong
|
* @author:
|
||||||
* @description: postHandle方法执行完成后执行,一般用于释放资源
|
* @description: postHandle方法执行完成后执行,一般用于释放资源
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||||
log.info(new Date() + "--afterCompletion:" + request.getRequestURL());
|
log.info(new Date() + "--afterCompletion:" + request.getRequestURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderJson(HttpServletResponse response, Object object) {
|
|
||||||
response.reset();
|
|
||||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
|
||||||
response.setHeader("Access-Control-Allow-Methods", "*");
|
|
||||||
response.setHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
|
|
||||||
response.setContentType("application/json");
|
|
||||||
response.setCharacterEncoding("utf-8");
|
|
||||||
try {
|
|
||||||
response.getWriter().print(JSONObject.toJSONString(object));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,112 +1,112 @@
|
||||||
package code;
|
//package code;
|
||||||
|
//
|
||||||
import com.baomidou.mybatisplus.annotation.DbType;
|
//import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
//import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
//import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
//import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||||
import com.baomidou.mybatisplus.generator.config.*;
|
//import com.baomidou.mybatisplus.generator.config.*;
|
||||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
//import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
//import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
//import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||||
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
|
//import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
|
||||||
|
//
|
||||||
import java.util.ArrayList;
|
//import java.util.ArrayList;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
public class CodeGenerator {
|
//public class CodeGenerator {
|
||||||
|
//
|
||||||
public static void main(String[] args) {
|
// public static void main(String[] args) {
|
||||||
// 代码生成器
|
// // 代码生成器
|
||||||
AutoGenerator mpg = new AutoGenerator();
|
// AutoGenerator mpg = new AutoGenerator();
|
||||||
|
//
|
||||||
// 全局配置
|
// // 全局配置
|
||||||
GlobalConfig gc = new GlobalConfig();
|
// GlobalConfig gc = new GlobalConfig();
|
||||||
String projectPath = System.getProperty("user.dir");
|
// String projectPath = System.getProperty("user.dir");
|
||||||
gc.setOutputDir(projectPath + "/src/main/java");
|
// gc.setOutputDir(projectPath + "/src/main/java");
|
||||||
gc.setAuthor("ytChen");
|
// gc.setAuthor("ytChen");
|
||||||
gc.setOpen(false);
|
// gc.setOpen(false);
|
||||||
// gc.setEntityName("%sEntity");
|
//// gc.setEntityName("%sEntity");
|
||||||
gc.setBaseColumnList(true);
|
// gc.setBaseColumnList(true);
|
||||||
//去除生成的Service前缀I
|
// //去除生成的Service前缀I
|
||||||
gc.setServiceName("%sService");
|
// gc.setServiceName("%sService");
|
||||||
gc.setBaseResultMap(true);
|
// gc.setBaseResultMap(true);
|
||||||
gc.setDateType(DateType.ONLY_DATE);
|
// gc.setDateType(DateType.ONLY_DATE);
|
||||||
gc.setSwagger2(false); //实体属性 Swagger2 注解
|
// gc.setSwagger2(false); //实体属性 Swagger2 注解
|
||||||
mpg.setGlobalConfig(gc);
|
// mpg.setGlobalConfig(gc);
|
||||||
|
//
|
||||||
// 数据源配置
|
// // 数据源配置
|
||||||
DataSourceConfig dsc = new DataSourceConfig();
|
// DataSourceConfig dsc = new DataSourceConfig();
|
||||||
dsc.setUrl("jdbc:mysql://192.168.110.210:3306/hoe_admin?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useSSL=false");
|
// dsc.setUrl("jdbc:mysql://192.168.110.210:3306/hoe_admin?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useSSL=false");
|
||||||
//dsc.setDriverName("dm.jdbc.driver.DmDriver"); //jdk 1.8使用这个 9之后就要下面的
|
// //dsc.setDriverName("dm.jdbc.driver.DmDriver"); //jdk 1.8使用这个 9之后就要下面的
|
||||||
dsc.setDriverName("com.mysql.jdbc.Driver");
|
// dsc.setDriverName("com.mysql.jdbc.Driver");
|
||||||
dsc.setUsername("root");
|
// dsc.setUsername("root");
|
||||||
dsc.setPassword("12345678");
|
// dsc.setPassword("12345678");
|
||||||
dsc.setDbType(DbType.MYSQL);
|
// dsc.setDbType(DbType.MYSQL);
|
||||||
mpg.setDataSource(dsc);
|
// mpg.setDataSource(dsc);
|
||||||
|
//
|
||||||
// 包配置
|
// // 包配置
|
||||||
PackageConfig pc = new PackageConfig();
|
// PackageConfig pc = new PackageConfig();
|
||||||
// pc.setModuleName(scanner("模块名"));
|
//// pc.setModuleName(scanner("模块名"));
|
||||||
pc.setParent("com.recovery.order");
|
// pc.setParent("com.recovery.order");
|
||||||
mpg.setPackageInfo(pc);
|
// mpg.setPackageInfo(pc);
|
||||||
|
//
|
||||||
// 自定义配置
|
// // 自定义配置
|
||||||
InjectionConfig cfg = new InjectionConfig() {
|
// InjectionConfig cfg = new InjectionConfig() {
|
||||||
@Override
|
// @Override
|
||||||
public void initMap() {
|
// public void initMap() {
|
||||||
// to do nothing
|
// // to do nothing
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
// 如果模板引擎是 velocity
|
// // 如果模板引擎是 velocity
|
||||||
String templatePath = "/templates/mapper.xml.vm";
|
// String templatePath = "/templates/mapper.xml.vm";
|
||||||
|
//
|
||||||
// 自定义输出配置
|
// // 自定义输出配置
|
||||||
List<FileOutConfig> focList = new ArrayList<>();
|
// List<FileOutConfig> focList = new ArrayList<>();
|
||||||
// 自定义配置会被优先输出
|
// // 自定义配置会被优先输出
|
||||||
focList.add(new FileOutConfig(templatePath) {
|
// focList.add(new FileOutConfig(templatePath) {
|
||||||
@Override
|
// @Override
|
||||||
public String outputFile(TableInfo tableInfo) {
|
// public String outputFile(TableInfo tableInfo) {
|
||||||
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
|
// // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
|
||||||
// return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
|
//// return projectPath + "/src/main/resources/mapper/" + pc.getModuleName()
|
||||||
// + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
|
//// + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
|
||||||
return projectPath + "/src/main/resources/mapper" + pc.getModuleName()
|
// return projectPath + "/src/main/resources/mapper" + pc.getModuleName()
|
||||||
+ "/" + tableInfo.getEntityName() + "Mapper"
|
// + "/" + tableInfo.getEntityName() + "Mapper"
|
||||||
+ StringPool.DOT_XML;
|
// + StringPool.DOT_XML;
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
cfg.setFileOutConfigList(focList);
|
// cfg.setFileOutConfigList(focList);
|
||||||
mpg.setCfg(cfg);
|
// mpg.setCfg(cfg);
|
||||||
|
//
|
||||||
// 配置模板
|
// // 配置模板
|
||||||
TemplateConfig templateConfig = new TemplateConfig();
|
// TemplateConfig templateConfig = new TemplateConfig();
|
||||||
|
//
|
||||||
// 配置自定义输出模板
|
// // 配置自定义输出模板
|
||||||
//指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
|
// //指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
|
||||||
templateConfig.setEntity("templates/entity.java");
|
// templateConfig.setEntity("templates/entity.java");
|
||||||
// templateConfig.setService();
|
// // templateConfig.setService();
|
||||||
templateConfig.setController(null);
|
// templateConfig.setController(null);
|
||||||
templateConfig.setXml(null);
|
// templateConfig.setXml(null);
|
||||||
mpg.setTemplate(templateConfig);
|
// mpg.setTemplate(templateConfig);
|
||||||
|
//
|
||||||
// 策略配置
|
// // 策略配置
|
||||||
StrategyConfig strategy = new StrategyConfig();
|
// StrategyConfig strategy = new StrategyConfig();
|
||||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
// strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
// strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
||||||
// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
|
//// strategy.setSuperEntityClass("你自己的父类实体,没有就不用设置!");
|
||||||
strategy.setEntityLombokModel(true);
|
// strategy.setEntityLombokModel(true);
|
||||||
strategy.setRestControllerStyle(true);
|
// strategy.setRestControllerStyle(true);
|
||||||
// 公共父类
|
// // 公共父类
|
||||||
// strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!");
|
//// strategy.setSuperControllerClass("你自己的父类控制器,没有就不用设置!");
|
||||||
// 写于父类中的公共字段
|
// // 写于父类中的公共字段
|
||||||
// strategy.setSuperEntityColumns("id");
|
//// strategy.setSuperEntityColumns("id");
|
||||||
strategy.setInclude("tbl_order_in");
|
// strategy.setInclude("tbl_order_in");
|
||||||
strategy.setSuperMapperClass("com.recovery.common.mybatis.config.MyMapper");
|
// strategy.setSuperMapperClass("com.recovery.common.mybatis.config.MyMapper");
|
||||||
strategy.setControllerMappingHyphenStyle(true);
|
// strategy.setControllerMappingHyphenStyle(true);
|
||||||
strategy.setTablePrefix("tbl" + "_"); //生成实体时去掉表前缀
|
// strategy.setTablePrefix("tbl" + "_"); //生成实体时去掉表前缀
|
||||||
mpg.setStrategy(strategy);
|
// mpg.setStrategy(strategy);
|
||||||
mpg.setTemplateEngine(new VelocityTemplateEngine());
|
// mpg.setTemplateEngine(new VelocityTemplateEngine());
|
||||||
mpg.execute();
|
// mpg.execute();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
Loading…
Reference in New Issue