|
@@ -0,0 +1,108 @@
|
|
|
+package com.usky.issue.controller;
|
|
|
+
|
|
|
+
|
|
|
+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.NamingStrategy;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+ * @author yq
|
|
|
+ * @date 2021/7/6 11:42
|
|
|
+ */
|
|
|
+public class MybatisGeneratorUtils {
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+ shell("service-issue","service-issue-biz");
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void shell(String parentName,String model) {
|
|
|
+
|
|
|
+ AutoGenerator mpg = new AutoGenerator();
|
|
|
+
|
|
|
+ GlobalConfig gc = new GlobalConfig();
|
|
|
+
|
|
|
+
|
|
|
+ String projectPath = System.getProperty("user.dir");
|
|
|
+ projectPath+="/"+parentName;
|
|
|
+ projectPath+="/"+model;
|
|
|
+ gc.setOutputDir(projectPath+ "/src/main/java");
|
|
|
+
|
|
|
+ gc.setAuthor("han");
|
|
|
+ gc.setOpen(false);
|
|
|
+ gc.setFileOverride(true);
|
|
|
+ gc.setServiceName("%sService");
|
|
|
+ gc.setBaseResultMap(true);
|
|
|
+ mpg.setGlobalConfig(gc);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ DataSourceConfig dsc = new DataSourceConfig();
|
|
|
+ dsc.setUrl("jdbc:mysql://172.16.120.165:3306/usky-cloud?useUnicode=true&serverTimezone=GMT&useSSL=false&characterEncoding=utf8");
|
|
|
+ dsc.setDriverName("com.mysql.jdbc.Driver");
|
|
|
+ dsc.setUsername("usky");
|
|
|
+ dsc.setPassword("Yt#75Usky");
|
|
|
+ mpg.setDataSource(dsc);
|
|
|
+
|
|
|
+
|
|
|
+ PackageConfig pc = new PackageConfig();
|
|
|
+ pc.setParent("com.usky.issue");
|
|
|
+ pc.setController("controller.web");
|
|
|
+ pc.setEntity("domain");
|
|
|
+ pc.setMapper("mapper");
|
|
|
+ pc.setService("service");
|
|
|
+ pc.setServiceImpl("service.impl");
|
|
|
+
|
|
|
+
|
|
|
+ mpg.setPackageInfo(pc);
|
|
|
+
|
|
|
+
|
|
|
+ StrategyConfig strategy = new StrategyConfig();
|
|
|
+ strategy.setNaming(NamingStrategy.underline_to_camel);
|
|
|
+ strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
|
|
+ strategy.setSuperMapperClass("com.usky.common.mybatis.core.CrudMapper");
|
|
|
+ strategy.setSuperServiceClass("com.usky.common.mybatis.core.CrudService");
|
|
|
+ strategy.setSuperServiceImplClass("com.usky.common.mybatis.core.AbstractCrudService");
|
|
|
+
|
|
|
+ strategy.setEntityLombokModel(true);
|
|
|
+
|
|
|
+ strategy.setInclude("base_alarm_notice_result");
|
|
|
+ mpg.setStrategy(strategy);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ TemplateConfig tc = new TemplateConfig();
|
|
|
+
|
|
|
+ InjectionConfig cfg = new InjectionConfig() {
|
|
|
+ @Override
|
|
|
+ public void initMap() {
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ String templatePath = "/templates/mapper.xml.vm";
|
|
|
+
|
|
|
+ List<FileOutConfig> focList = new ArrayList<>();
|
|
|
+
|
|
|
+ String finalProjectPath = projectPath;
|
|
|
+ focList.add(new FileOutConfig(templatePath) {
|
|
|
+ @Override
|
|
|
+ public String outputFile(TableInfo tableInfo) {
|
|
|
+
|
|
|
+ return finalProjectPath + "/src/main/resources/mapper/issue" + "/"
|
|
|
+ + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ cfg.setFileOutConfigList(focList);
|
|
|
+ mpg.setCfg(cfg);
|
|
|
+ tc.setXml(null);
|
|
|
+ mpg.setTemplate(tc);
|
|
|
+
|
|
|
+ mpg.execute();
|
|
|
+ }
|
|
|
+}
|