Merge remote-tracking branch 'origin/main'

# Conflicts:
#	mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java
This commit is contained in:
Suomm 2024-01-27 19:48:07 +08:00
commit e71a40c59f
17 changed files with 148 additions and 53 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 197 KiB

View File

@ -27,6 +27,10 @@ import java.io.Serializable;
public class ControllerConfig implements Serializable { public class ControllerConfig implements Serializable {
private static final long serialVersionUID = 8391630904705910611L; private static final long serialVersionUID = 8391630904705910611L;
/**
* 代码生成目录当未配置时使用 PackageConfig 的配置
*/
private String sourceDir;
/** /**
* Controller 类的前缀 * Controller 类的前缀
*/ */
@ -60,6 +64,14 @@ public class ControllerConfig implements Serializable {
return superClass.getSimpleName(); return superClass.getSimpleName();
} }
public String getSourceDir() {
return sourceDir;
}
public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}
/** /**
* 获取类前缀 * 获取类前缀
*/ */

View File

@ -27,6 +27,11 @@ import java.io.Serializable;
public class EntityConfig implements Serializable { public class EntityConfig implements Serializable {
private static final long serialVersionUID = -6790274333595436008L; private static final long serialVersionUID = -6790274333595436008L;
/**
* 代码生成目录当未配置时使用 PackageConfig 的配置
*/
private String sourceDir;
/** /**
* Entity 类的前缀 * Entity 类的前缀
*/ */
@ -82,6 +87,14 @@ public class EntityConfig implements Serializable {
*/ */
private int jdkVersion; private int jdkVersion;
public String getSourceDir() {
return sourceDir;
}
public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}
/** /**
* 获取类前缀 * 获取类前缀
*/ */

View File

@ -29,6 +29,11 @@ import java.io.Serializable;
public class MapperConfig implements Serializable { public class MapperConfig implements Serializable {
private static final long serialVersionUID = 1937442008907641534L; private static final long serialVersionUID = 1937442008907641534L;
/**
* 代码生成目录当未配置时使用 PackageConfig 的配置
*/
private String sourceDir;
/** /**
* Mapper 类的前缀 * Mapper 类的前缀
*/ */
@ -62,6 +67,14 @@ public class MapperConfig implements Serializable {
return superClass.getSimpleName(); return superClass.getSimpleName();
} }
public String getSourceDir() {
return sourceDir;
}
public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}
/** /**
* 获取类前缀 * 获取类前缀
*/ */

View File

@ -44,7 +44,6 @@ public class PackageConfig implements Serializable {
* Entity 所在包 * Entity 所在包
*/ */
private String entityPackage; private String entityPackage;
/** /**
* Mapper 所在包 * Mapper 所在包
*/ */

View File

@ -30,6 +30,11 @@ import java.io.Serializable;
public class ServiceConfig implements Serializable { public class ServiceConfig implements Serializable {
private static final long serialVersionUID = -2152473328300910220L; private static final long serialVersionUID = -2152473328300910220L;
/**
* 代码生成目录当未配置时使用 PackageConfig 的配置
*/
private String sourceDir;
/** /**
* Service 类的前缀 * Service 类的前缀
*/ */
@ -58,6 +63,14 @@ public class ServiceConfig implements Serializable {
return superClass.getSimpleName(); return superClass.getSimpleName();
} }
public String getSourceDir() {
return sourceDir;
}
public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}
/** /**
* 获取类前缀 * 获取类前缀
*/ */

View File

@ -27,6 +27,12 @@ import java.io.Serializable;
public class ServiceImplConfig implements Serializable { public class ServiceImplConfig implements Serializable {
private static final long serialVersionUID = 17115432462168151L; private static final long serialVersionUID = 17115432462168151L;
/**
* 代码生成目录当未配置时使用 PackageConfig 的配置
*/
private String sourceDir;
/** /**
* ServiceImpl 类的前缀 * ServiceImpl 类的前缀
*/ */
@ -52,6 +58,14 @@ public class ServiceImplConfig implements Serializable {
*/ */
private boolean cacheExample; private boolean cacheExample;
public String getSourceDir() {
return sourceDir;
}
public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}
public String buildSuperClassImport() { public String buildSuperClassImport() {
if (superClass == null) { if (superClass == null) {
return "com.mybatisflex.spring.service.impl.ServiceImpl"; return "com.mybatisflex.spring.service.impl.ServiceImpl";

View File

@ -29,6 +29,10 @@ import java.io.Serializable;
public class TableDefConfig implements Serializable { public class TableDefConfig implements Serializable {
private static final long serialVersionUID = 8137903163796008036L; private static final long serialVersionUID = 8137903163796008036L;
/**
* 代码生成目录当未配置时使用 PackageConfig 的配置
*/
private String sourceDir;
/** /**
* TableDef 类的前缀 * TableDef 类的前缀
*/ */
@ -68,6 +72,14 @@ public class TableDefConfig implements Serializable {
} }
} }
public String getSourceDir() {
return sourceDir;
}
public void setSourceDir(String sourceDir) {
this.sourceDir = sourceDir;
}
/** /**
* 获取类前缀 * 获取类前缀
*/ */

View File

@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.PackageConfig;
import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.constant.TemplateConst;
import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.entity.Table;
import com.mybatisflex.codegen.generator.IGenerator; import com.mybatisflex.codegen.generator.IGenerator;
import com.mybatisflex.core.util.StringUtil;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@ -54,8 +55,10 @@ public class ControllerGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig(); PackageConfig packageConfig = globalConfig.getPackageConfig();
ControllerConfig controllerConfig = globalConfig.getControllerConfig(); ControllerConfig controllerConfig = globalConfig.getControllerConfig();
String sourceDir = StringUtil.isNotBlank(controllerConfig.getSourceDir()) ? controllerConfig.getSourceDir() : packageConfig.getSourceDir();
String controllerPackagePath = packageConfig.getControllerPackage().replace(".", "/"); String controllerPackagePath = packageConfig.getControllerPackage().replace(".", "/");
File controllerJavaFile = new File(packageConfig.getSourceDir(), controllerPackagePath + "/" + File controllerJavaFile = new File(sourceDir, controllerPackagePath + "/" +
table.buildControllerClassName() + ".java"); table.buildControllerClassName() + ".java");

View File

@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.PackageConfig;
import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.constant.TemplateConst;
import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.entity.Table;
import com.mybatisflex.codegen.generator.IGenerator; import com.mybatisflex.codegen.generator.IGenerator;
import com.mybatisflex.core.util.StringUtil;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@ -54,8 +55,10 @@ public class EntityGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig(); PackageConfig packageConfig = globalConfig.getPackageConfig();
EntityConfig entityConfig = globalConfig.getEntityConfig(); EntityConfig entityConfig = globalConfig.getEntityConfig();
String sourceDir = StringUtil.isNotBlank(entityConfig.getSourceDir()) ? entityConfig.getSourceDir() : packageConfig.getSourceDir();
String entityPackagePath = packageConfig.getEntityPackage().replace(".", "/"); String entityPackagePath = packageConfig.getEntityPackage().replace(".", "/");
File entityJavaFile = new File(packageConfig.getSourceDir(), entityPackagePath + "/" + File entityJavaFile = new File(sourceDir, entityPackagePath + "/" +
table.buildEntityClassName() + ".java"); table.buildEntityClassName() + ".java");

View File

@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.PackageConfig;
import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.constant.TemplateConst;
import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.entity.Table;
import com.mybatisflex.codegen.generator.IGenerator; import com.mybatisflex.codegen.generator.IGenerator;
import com.mybatisflex.core.util.StringUtil;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@ -54,8 +55,10 @@ public class MapperGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig(); PackageConfig packageConfig = globalConfig.getPackageConfig();
MapperConfig mapperConfig = globalConfig.getMapperConfig(); MapperConfig mapperConfig = globalConfig.getMapperConfig();
String sourceDir = StringUtil.isNotBlank(mapperConfig.getSourceDir()) ? mapperConfig.getSourceDir() : packageConfig.getSourceDir();
String mapperPackagePath = packageConfig.getMapperPackage().replace(".", "/"); String mapperPackagePath = packageConfig.getMapperPackage().replace(".", "/");
File mapperJavaFile = new File(packageConfig.getSourceDir(), mapperPackagePath + "/" + File mapperJavaFile = new File(sourceDir, mapperPackagePath + "/" +
table.buildMapperClassName() + ".java"); table.buildMapperClassName() + ".java");

View File

@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.ServiceConfig;
import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.constant.TemplateConst;
import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.entity.Table;
import com.mybatisflex.codegen.generator.IGenerator; import com.mybatisflex.codegen.generator.IGenerator;
import com.mybatisflex.core.util.StringUtil;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@ -54,8 +55,10 @@ public class ServiceGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig(); PackageConfig packageConfig = globalConfig.getPackageConfig();
ServiceConfig serviceConfig = globalConfig.getServiceConfig(); ServiceConfig serviceConfig = globalConfig.getServiceConfig();
String sourceDir = StringUtil.isNotBlank(serviceConfig.getSourceDir()) ? serviceConfig.getSourceDir() : packageConfig.getSourceDir();
String servicePackagePath = packageConfig.getServicePackage().replace(".", "/"); String servicePackagePath = packageConfig.getServicePackage().replace(".", "/");
File serviceJavaFile = new File(packageConfig.getSourceDir(), servicePackagePath + "/" + File serviceJavaFile = new File(sourceDir, servicePackagePath + "/" +
table.buildServiceClassName() + ".java"); table.buildServiceClassName() + ".java");

View File

@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.ServiceImplConfig;
import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.constant.TemplateConst;
import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.entity.Table;
import com.mybatisflex.codegen.generator.IGenerator; import com.mybatisflex.codegen.generator.IGenerator;
import com.mybatisflex.core.util.StringUtil;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@ -54,8 +55,10 @@ public class ServiceImplGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig(); PackageConfig packageConfig = globalConfig.getPackageConfig();
ServiceImplConfig serviceImplConfig = globalConfig.getServiceImplConfig(); ServiceImplConfig serviceImplConfig = globalConfig.getServiceImplConfig();
String sourceDir = StringUtil.isNotBlank(serviceImplConfig.getSourceDir()) ? serviceImplConfig.getSourceDir() : packageConfig.getSourceDir();
String serviceImplPackagePath = packageConfig.getServiceImplPackage().replace(".", "/"); String serviceImplPackagePath = packageConfig.getServiceImplPackage().replace(".", "/");
File serviceImplJavaFile = new File(packageConfig.getSourceDir(), serviceImplPackagePath + "/" + File serviceImplJavaFile = new File(sourceDir, serviceImplPackagePath + "/" +
table.buildServiceImplClassName() + ".java"); table.buildServiceImplClassName() + ".java");

View File

@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.TableDefConfig;
import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.constant.TemplateConst;
import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.entity.Table;
import com.mybatisflex.codegen.generator.IGenerator; import com.mybatisflex.codegen.generator.IGenerator;
import com.mybatisflex.core.util.StringUtil;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@ -54,8 +55,10 @@ public class TableDefGenerator implements IGenerator {
PackageConfig packageConfig = globalConfig.getPackageConfig(); PackageConfig packageConfig = globalConfig.getPackageConfig();
TableDefConfig tableDefConfig = globalConfig.getTableDefConfig(); TableDefConfig tableDefConfig = globalConfig.getTableDefConfig();
String sourceDir = StringUtil.isNotBlank(tableDefConfig.getSourceDir()) ? tableDefConfig.getSourceDir() : packageConfig.getSourceDir();
String tableDefPackagePath = packageConfig.getTableDefPackage().replace(".", "/"); String tableDefPackagePath = packageConfig.getTableDefPackage().replace(".", "/");
File tableDefJavaFile = new File(packageConfig.getSourceDir(), tableDefPackagePath + "/" + File tableDefJavaFile = new File(sourceDir, tableDefPackagePath + "/" +
table.buildTableDefClassName() + ".java"); table.buildTableDefClassName() + ".java");

View File

@ -1,7 +1,8 @@
-- Alisa Test -- Alisa Test
SET NAMES utf8mb4; SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0; SET
FOREIGN_KEY_CHECKS = 0;
-- ---------------------------- -- ----------------------------
-- Table structure for sys_dept -- Table structure for sys_dept
@ -10,15 +11,14 @@ DROP TABLE IF EXISTS `sys_dept`;
CREATE TABLE `sys_dept` CREATE TABLE `sys_dept`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`dept_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `dept_name` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL, `create_time` datetime NULL DEFAULT NULL,
`update_time` datetime NULL DEFAULT NULL, `update_time` datetime NULL DEFAULT NULL,
`create_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `create_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`update_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `update_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
CHARACTER SET = utf8mb4 CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci
ROW_FORMAT = DYNAMIC; ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
@ -34,16 +34,15 @@ DROP TABLE IF EXISTS `sys_role`;
CREATE TABLE `sys_role` CREATE TABLE `sys_role`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`role_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `role_key` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`role_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `role_name` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL, `create_time` datetime NULL DEFAULT NULL,
`update_time` datetime NULL DEFAULT NULL, `update_time` datetime NULL DEFAULT NULL,
`create_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `create_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`update_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `update_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
CHARACTER SET = utf8mb4 CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci
ROW_FORMAT = DYNAMIC; ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
@ -59,17 +58,16 @@ DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` CREATE TABLE `sys_user`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`user_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `user_name` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`age` int NULL DEFAULT NULL, `age` int NULL DEFAULT NULL,
`birthday` datetime NULL DEFAULT NULL, `birthday` datetime NULL DEFAULT NULL,
`create_time` datetime NULL DEFAULT NULL, `create_time` datetime NULL DEFAULT NULL,
`update_time` datetime NULL DEFAULT NULL, `update_time` datetime NULL DEFAULT NULL,
`create_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `create_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`update_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, `update_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
CHARACTER SET = utf8mb4 CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci
ROW_FORMAT = DYNAMIC; ROW_FORMAT = DYNAMIC;
-- ---------------------------- -- ----------------------------
@ -78,4 +76,5 @@ CREATE TABLE `sys_user`
INSERT INTO `sys_user` INSERT INTO `sys_user`
VALUES (1, '张三', 18, '2023-11-17 22:14:40', '2023-11-17 22:54:34', '2023-11-21 22:14:54', 'USER', 'USER'); VALUES (1, '张三', 18, '2023-11-17 22:14:40', '2023-11-17 22:54:34', '2023-11-21 22:14:54', 'USER', 'USER');
SET FOREIGN_KEY_CHECKS = 1; SET
FOREIGN_KEY_CHECKS = 1;

View File

@ -7,7 +7,7 @@ spring:
# driver-class-name: com.mysql.cj.jdbc.Driver # driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/flex_test url: jdbc:mysql://localhost:3306/flex_test
username: root username: root
password: 12345678 password: 123456
# driver-class-name: # driver-class-name:
# datasource: # datasource:
# driver-class-name: org.h2.Driver # driver-class-name: org.h2.Driver

View File

@ -1,5 +1,6 @@
SET NAMES utf8mb4; SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0; SET
FOREIGN_KEY_CHECKS = 0;
-- ---------------------------- -- ----------------------------
-- Table structure for tb_account -- Table structure for tb_account
@ -352,4 +353,5 @@ VALUES (4, 4);
INSERT INTO `tb_user_role` INSERT INTO `tb_user_role`
VALUES (5, 1); VALUES (5, 1);
SET FOREIGN_KEY_CHECKS = 1; SET
FOREIGN_KEY_CHECKS = 1;