whyclxw
2021-04-16 3f465acb40c133a36933692a6667cec0188abbdb
提交
8个文件已修改
10个文件已添加
181 ■■■■■ 已修改文件
.idea/libraries/Maven__com_baomidou_mybatis_plus_generator_3_1_2.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/libraries/Maven__org_apache_commons_commons_lang3_3_8_1.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.idea/libraries/Maven__org_apache_velocity_velocity_engine_core_2_3.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SpringBootF_1.iml 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/example/lxw/pojo/User_inf.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/example/lxw/GeneratorCode.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
target/classes/com/example/lxw/controller/User_infController.class 补丁 | 查看 | 原始文档 | blame | 历史
target/classes/com/example/lxw/mapper/User_InfMapper.class 补丁 | 查看 | 原始文档 | blame | 历史
target/classes/com/example/lxw/pojo/User_inf.class 补丁 | 查看 | 原始文档 | blame | 历史
target/classes/com/example/lxw/pojo/vo/UserInfo.class 补丁 | 查看 | 原始文档 | blame | 历史
target/classes/com/example/lxw/service/User_infService.class 补丁 | 查看 | 原始文档 | blame | 历史
target/classes/mapper/User_infMapper.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst 补丁 | 查看 | 原始文档 | blame | 历史
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
target/test-classes/com/example/lxw/GeneratorCode.class 补丁 | 查看 | 原始文档 | blame | 历史
.idea/libraries/Maven__com_baomidou_mybatis_plus_generator_3_1_2.xml
New file
@@ -0,0 +1,13 @@
<component name="libraryTable">
  <library name="Maven: com.baomidou:mybatis-plus-generator:3.1.2">
    <CLASSES>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/com/baomidou/mybatis-plus-generator/3.1.2/mybatis-plus-generator-3.1.2.jar!/" />
    </CLASSES>
    <JAVADOC>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/com/baomidou/mybatis-plus-generator/3.1.2/mybatis-plus-generator-3.1.2-javadoc.jar!/" />
    </JAVADOC>
    <SOURCES>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/com/baomidou/mybatis-plus-generator/3.1.2/mybatis-plus-generator-3.1.2-sources.jar!/" />
    </SOURCES>
  </library>
</component>
.idea/libraries/Maven__org_apache_commons_commons_lang3_3_8_1.xml
New file
@@ -0,0 +1,13 @@
<component name="libraryTable">
  <library name="Maven: org.apache.commons:commons-lang3:3.8.1">
    <CLASSES>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar!/" />
    </CLASSES>
    <JAVADOC>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1-javadoc.jar!/" />
    </JAVADOC>
    <SOURCES>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1-sources.jar!/" />
    </SOURCES>
  </library>
</component>
.idea/libraries/Maven__org_apache_velocity_velocity_engine_core_2_3.xml
New file
@@ -0,0 +1,13 @@
<component name="libraryTable">
  <library name="Maven: org.apache.velocity:velocity-engine-core:2.3">
    <CLASSES>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/org/apache/velocity/velocity-engine-core/2.3/velocity-engine-core-2.3.jar!/" />
    </CLASSES>
    <JAVADOC>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/org/apache/velocity/velocity-engine-core/2.3/velocity-engine-core-2.3-javadoc.jar!/" />
    </JAVADOC>
    <SOURCES>
      <root url="jar://$PROJECT_DIR$/../../maven/apache-maven-3.6.3/maven_jar/org/apache/velocity/velocity-engine-core/2.3/velocity-engine-core-2.3-sources.jar!/" />
    </SOURCES>
  </library>
</component>
SpringBootF_1.iml
@@ -40,7 +40,6 @@
    <orderEntry type="library" name="Maven: org.thymeleaf:thymeleaf:3.0.11.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.attoparser:attoparser:2.0.5.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.unbescape:unbescape:1.1.6.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
    <orderEntry type="library" name="Maven: org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.4.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.12.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.12.RELEASE" level="project" />
@@ -131,5 +130,9 @@
    <orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" />
    <orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:2.9.2" level="project" />
    <orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-ui:2.0.2" level="project" />
    <orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-generator:3.1.2" level="project" />
    <orderEntry type="library" name="Maven: org.apache.velocity:velocity-engine-core:2.3" level="project" />
    <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" />
    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
  </component>
</module>
pom.xml
@@ -97,6 +97,17 @@
                </exclusion>
            </exclusions>-->
        </dependency>
        <!--代码生成器-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-core</artifactId>
            <version>2.3</version>
        </dependency>
    </dependencies>
    <build>
src/main/java/com/example/lxw/pojo/User_inf.java
@@ -56,11 +56,4 @@
    private List<UserBattgroupBaojigroupUsr> baojigroupUsrs;
    public void setBaojigroupUsrs(List<UserBattgroupBaojigroupUsr> baojigroupUsrs) {
        this.baojigroupUsrs = baojigroupUsrs;
    }
    public List<UserBattgroupBaojigroupUsr> getBaojigroupUsrs() {
        return baojigroupUsrs;
    }
}
src/test/java/com/example/lxw/GeneratorCode.java
New file
@@ -0,0 +1,78 @@
package com.example.lxw;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.po.TableFill;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import java.util.ArrayList;
import java.util.ArrayList;
/**
 * @author lxw
 * @create 2021-04-15 16:48
 */
public class GeneratorCode {
    public static void main(String[] args) {
        // 需要构建一个 代码自动生成器 对象
        AutoGenerator mpg = new AutoGenerator();
        // 配置策略
        // 1、全局配置
        GlobalConfig gc = new GlobalConfig();
        String projectPath = System.getProperty("user.dir");
        gc.setOutputDir(projectPath+"/src/main/java/com/example");
        gc.setAuthor("lxw");
        gc.setOpen(false);
        gc.setFileOverride(false); // 是否覆盖
        gc.setServiceName("%sService"); // 去Service的I前缀
        gc.setIdType(IdType.ID_WORKER);
        gc.setDateType(DateType.ONLY_DATE);
        //gc.setSwagger2(true);
        mpg.setGlobalConfig(gc);
        //2、设置数据源
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl("jdbc:mysql://192.168.10.79:3360/db_user?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8");
        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
        dsc.setUsername("root");
        dsc.setPassword("lmx8688139");
        dsc.setDbType(DbType.MYSQL);
        mpg.setDataSource(dsc);
        //3、包的配置
        PackageConfig pc = new PackageConfig();
        pc.setModuleName("blog");
        pc.setParent("com.generator");
        pc.setEntity("entity");
        pc.setMapper("mapper");
        pc.setService("service");
        pc.setController("controller");
        mpg.setPackageInfo(pc);
        //4、策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setInclude("tb_user_inf","tb_user_battgroup_baojigroup","tb_user_battgroup_baojigroup_battgroup","tb_user_battgroup_baojigroup_usr"); // 设置要映射的表名
                strategy.setNaming(NamingStrategy.underline_to_camel);
        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
        strategy.setEntityLombokModel(true); // 自动lombok;
        strategy.setLogicDeleteFieldName("deleted");
        // 自动填充配置
        TableFill gmtCreate = new TableFill("gmt_create", FieldFill.INSERT);
        TableFill gmtModified = new TableFill("gmt_modified",FieldFill.INSERT_UPDATE);
        ArrayList<TableFill> tableFills = new ArrayList<>();
        tableFills.add(gmtCreate);
        tableFills.add(gmtModified);
        strategy.setTableFillList(tableFills);
        // 乐观锁
        strategy.setVersionFieldName("version");
        strategy.setRestControllerStyle(true);
        strategy.setControllerMappingHyphenStyle(true); //localhost:8080/hello_id_2mpg.setStrategy(strategy);
        mpg.execute(); //执行
    }
}
target/classes/com/example/lxw/controller/User_infController.class
Binary files differ
target/classes/com/example/lxw/mapper/User_InfMapper.class
Binary files differ
target/classes/com/example/lxw/pojo/User_inf.class
Binary files differ
target/classes/com/example/lxw/pojo/vo/UserInfo.class
Binary files differ
target/classes/com/example/lxw/service/User_infService.class
Binary files differ
target/classes/mapper/User_infMapper.xml
@@ -10,10 +10,25 @@
        </collection>
    </resultMap>
    <resultMap id="baojiUserMap2" type="UserInfo">
        <result column="uSnId" property="uSnId" />
        <result column="uName" property="uName" />
        <collection property="usrList" ofType="UserBattgroupBaojigroupUsr">
            <result column="baoji_group_id" property="baojiGroupId" />
        </collection>
    </resultMap>
    <select id="searchByBaojiUsr" resultMap="baojiUserMap">
        SELECT tb_user_inf.*,tb_user_battgroup_baojigroup_usr.baoji_group_id
        from tb_user_inf
        LEFT JOIN tb_user_battgroup_baojigroup_usr ON tb_user_inf.uId=tb_user_battgroup_baojigroup_usr.uId
        order by tb_user_inf.uid
    </select>
    <select id="searchByBaojiUsr2" resultMap="baojiUserMap2">
        SELECT tb_user_inf.*,tb_user_battgroup_baojigroup_usr.baoji_group_id
        from tb_user_inf
                 LEFT JOIN tb_user_battgroup_baojigroup_usr ON tb_user_inf.uId=tb_user_battgroup_baojigroup_usr.uId
        order by tb_user_inf.uid
    </select>
</mapper>
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
New file
@@ -0,0 +1,12 @@
com\example\lxw\websocket\WebSocketServer.class
com\example\lxw\config\SwaggerConfig4Knife.class
com\example\lxw\pojo\User_inf.class
com\example\lxw\mapper\User_InfMapper.class
com\example\lxw\config\MvcConfig.class
com\example\lxw\controller\User_infController.class
com\example\lxw\LxwApplication.class
com\example\lxw\pojo\UserBattgroupBaojigroupUsr.class
com\example\lxw\pojo\ServiceModel.class
com\example\lxw\service\User_infService.class
com\example\lxw\websocket\WebSocketServer$1.class
com\example\lxw\config\MybatisPlusConfig.class
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
New file
@@ -0,0 +1,11 @@
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\pojo\User_inf.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\service\User_infService.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\pojo\ServiceModel.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\mapper\User_InfMapper.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\config\MvcConfig.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\LxwApplication.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\config\SwaggerConfig4Knife.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\config\MybatisPlusConfig.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\controller\User_infController.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\websocket\WebSocketServer.java
D:\Eworkspqce\SpringBootF_1\src\main\java\com\example\lxw\pojo\UserBattgroupBaojigroupUsr.java
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
New file
@@ -0,0 +1,3 @@
D:\Eworkspqce\SpringBootF_1\src\test\java\com\example\lxw\GeneratorCode.java
D:\Eworkspqce\SpringBootF_1\src\test\java\com\example\lxw\LxwApplicationTests.java
D:\Eworkspqce\SpringBootF_1\src\test\java\com\example\lxw\MpperTest.java
target/test-classes/com/example/lxw/GeneratorCode.class
Binary files differ