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