增加代码生成类
This commit is contained in:
@ -72,15 +72,15 @@ springdoc:
|
||||
swagger-ui:
|
||||
url: /v3/api-docs
|
||||
path: /doc.html
|
||||
packages-to-scan: com.sczx.user.controller # 替换为你的 controller 包路径
|
||||
packages-to-scan: com.sczx.store.controller # 替换为你的 controller 包路径
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:mapper/**/*.xml
|
||||
type-aliases-package: com.sczx.user.entity # 实体类包路径
|
||||
type-aliases-package: com.sczx.store.po # 实体类包路径
|
||||
configuration:
|
||||
mapUnderscoreToCamelCase: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 控制台打印 SQL(调试用)
|
||||
|
||||
auth:
|
||||
secret-key: his-is-a-very-long-and-secure-secret-key-for-jwt-signing-please-dont-use-short-keys
|
||||
token-expiration: 86400000 # 24小时
|
||||
#auth:
|
||||
# secret-key: his-is-a-very-long-and-secure-secret-key-for-jwt-signing-please-dont-use-short-keys
|
||||
# token-expiration: 86400000 # 24小时
|
||||
|
||||
41
src/test/java/com/sczx/store/CodeGenerator.java
Normal file
41
src/test/java/com/sczx/store/CodeGenerator.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.sczx.store;
|
||||
|
||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class CodeGenerator {
|
||||
|
||||
private static final String parentPackage = "com.sczx.store";
|
||||
private static final String jdbcUrl = "jdbc:mysql://115.190.8.52:3306/sczx?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&useSSL=false&serverTimezone=Asia/Shanghai";
|
||||
private static final String username = "sczx_user";
|
||||
private static final String password = "Sczx123";
|
||||
private static final String author = "zhangli";
|
||||
public static void main(String[] args) {
|
||||
DataSourceConfig.Builder DATA_SOURCE_CONFIG = new DataSourceConfig.Builder(jdbcUrl, username, password);
|
||||
|
||||
FastAutoGenerator.create(DATA_SOURCE_CONFIG)
|
||||
// 全局配置
|
||||
.globalConfig(builder -> builder.outputDir(System.getProperty("user.dir") + "/src/main/java")
|
||||
.author(author).disableOpenDir().enableSwagger()
|
||||
.dateType(DateType.TIME_PACK).commentDate("yyyy-MM-dd HH:mm:ss")
|
||||
.fileOverride())
|
||||
// 包配置
|
||||
.packageConfig(builder -> builder.parent(parentPackage).entity("po.base").service("repository.base").serviceImpl("repository.base.impl").xml("")
|
||||
.mapper("mapper.base").pathInfo(Collections.singletonMap(OutputFile.mapperXml, System.getProperty("user.dir") + "/src/main/resources/mapper/base")))
|
||||
|
||||
// 策略配置
|
||||
.strategyConfig((scanner, builder) -> builder.addInclude(scanner.apply("请输入表名:"))
|
||||
.addTablePrefix("t_"/*,"cd_"*/)//可支持多个,按逗号分隔
|
||||
.entityBuilder().formatFileName("%sPO").enableLombok()
|
||||
.mapperBuilder().formatMapperFileName("%sMapper").formatXmlFileName("%sMapper")
|
||||
.controllerBuilder().formatFileName("%sController").enableRestStyle()
|
||||
.serviceBuilder().formatServiceFileName("%sRepo").formatServiceImplFileName("%sRepoImpl"))
|
||||
.templateEngine(new FreemarkerTemplateEngine())
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user