Merge branch 'mybatis-flex:main' into main

This commit is contained in:
Robot.L 2024-01-26 13:46:04 +08:00 committed by GitHub
commit 9b3c594fa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 151 additions and 55 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
@ -9,16 +10,15 @@ SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `sys_dept`; 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;
-- ---------------------------- -- ----------------------------
@ -33,17 +33,16 @@ VALUES (1, '开发岗', NULL, NULL, 'DEPT', 'DEPT');
DROP TABLE IF EXISTS `sys_role`; 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;
-- ---------------------------- -- ----------------------------
@ -58,18 +57,17 @@ VALUES (1, 'ROOT', '超级管理员', '2000-11-17 22:15:20', '2000-11-17 22:54:1
DROP TABLE IF EXISTS `sys_user`; 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
@ -7,12 +8,12 @@ SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS `tb_account`; DROP TABLE IF EXISTS `tb_account`;
CREATE TABLE `tb_account` CREATE TABLE `tb_account`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`user_name` varchar(100) CHARACTER SET utf8mb4 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,
`gender` int NULL DEFAULT NULL, `gender` int NULL DEFAULT NULL,
`is_delete` tinyint(3) UNSIGNED ZEROFILL NULL DEFAULT NULL, `is_delete` tinyint(3) UNSIGNED ZEROFILL NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT = 5 AUTO_INCREMENT = 5
@ -35,11 +36,11 @@ VALUES (5, '王五', 18, '2023-07-04 15:00:26', NULL, 000);
DROP TABLE IF EXISTS `tb_article`; DROP TABLE IF EXISTS `tb_article`;
CREATE TABLE `tb_article` CREATE TABLE `tb_article`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`account_id` int NULL DEFAULT NULL, `account_id` int NULL DEFAULT NULL,
`title` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `title` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`content` text CHARACTER SET utf8mb4 NULL, `content` text CHARACTER SET utf8mb4 NULL,
`is_delete` int NULL DEFAULT NULL, `is_delete` int NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT = 3 AUTO_INCREMENT = 3
@ -62,9 +63,9 @@ VALUES (3, 1, '标题3', '内容3', 0);
DROP TABLE IF EXISTS `tb_good`; DROP TABLE IF EXISTS `tb_good`;
CREATE TABLE `tb_good` CREATE TABLE `tb_good`
( (
`good_id` int NOT NULL AUTO_INCREMENT, `good_id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`price` decimal(10, 2) NULL DEFAULT NULL, `price` decimal(10, 2) NULL DEFAULT NULL,
PRIMARY KEY (`good_id`) USING BTREE PRIMARY KEY (`good_id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
AUTO_INCREMENT = 10 AUTO_INCREMENT = 10
@ -101,7 +102,7 @@ VALUES (10, '近代化学导论', 67.00);
DROP TABLE IF EXISTS `tb_id_card`; DROP TABLE IF EXISTS `tb_id_card`;
CREATE TABLE `tb_id_card` CREATE TABLE `tb_id_card`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`id_number` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `id_number` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
@ -126,7 +127,7 @@ VALUES (4, 'A33E8BAA-93F2-4E28-A161-15CF7D0AE6D0');
DROP TABLE IF EXISTS `tb_inner`; DROP TABLE IF EXISTS `tb_inner`;
CREATE TABLE `tb_inner` CREATE TABLE `tb_inner`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`type` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `type` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
@ -146,7 +147,7 @@ VALUES (2, 'inner type');
DROP TABLE IF EXISTS `tb_order`; DROP TABLE IF EXISTS `tb_order`;
CREATE TABLE `tb_order` CREATE TABLE `tb_order`
( (
`order_id` int NOT NULL AUTO_INCREMENT, `order_id` int NOT NULL AUTO_INCREMENT,
`create_time` datetime NULL DEFAULT NULL, `create_time` datetime NULL DEFAULT NULL,
PRIMARY KEY (`order_id`) USING BTREE PRIMARY KEY (`order_id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
@ -218,7 +219,7 @@ VALUES (6, 10);
DROP TABLE IF EXISTS `tb_outer`; DROP TABLE IF EXISTS `tb_outer`;
CREATE TABLE `tb_outer` CREATE TABLE `tb_outer`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB ) ENGINE = InnoDB
@ -238,7 +239,7 @@ VALUES (1, 'outer 01');
DROP TABLE IF EXISTS `tb_role`; DROP TABLE IF EXISTS `tb_role`;
CREATE TABLE `tb_role` CREATE TABLE `tb_role`
( (
`role_id` int NOT NULL AUTO_INCREMENT, `role_id` int NOT NULL AUTO_INCREMENT,
`role_key` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `role_key` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`role_name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `role_name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
PRIMARY KEY (`role_id`) USING BTREE PRIMARY KEY (`role_id`) USING BTREE
@ -265,7 +266,7 @@ VALUES (4, 'admin', '管理员用户');
DROP TABLE IF EXISTS `tb_user`; DROP TABLE IF EXISTS `tb_user`;
CREATE TABLE `tb_user` CREATE TABLE `tb_user`
( (
`user_id` int NOT NULL AUTO_INCREMENT, `user_id` int NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `user_name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, `password` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL,
PRIMARY KEY (`user_id`) USING BTREE PRIMARY KEY (`user_id`) USING BTREE
@ -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;

View File

@ -1,6 +1,5 @@
package com.mybatisflex.test; package com.mybatisflex.test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.containers.BindMode; import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
@ -12,6 +11,7 @@ import java.util.Collections;
public class TestInfrastructure { public class TestInfrastructure {
static final String ALIAS_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("alisa.sql").getPath();
static final String FLEX_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("flex_test.sql").getPath(); static final String FLEX_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("flex_test.sql").getPath();
static final String FIELD_MAPPING_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("field_mapping_test.sql").getPath(); static final String FIELD_MAPPING_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("field_mapping_test.sql").getPath();
static final String PATIENT_DATA_SPLIT_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("patient_data_split_test.sql").getPath(); static final String PATIENT_DATA_SPLIT_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("patient_data_split_test.sql").getPath();
@ -19,13 +19,14 @@ public class TestInfrastructure {
static GenericContainer<?> mysql = new MySQLContainer<>(DockerImageName.parse("mysql:8.2.0")) static GenericContainer<?> mysql = new MySQLContainer<>(DockerImageName.parse("mysql:8.2.0"))
.waitingFor(Wait.forLogMessage(".*ready for connections.*\\n", 1)) .waitingFor(Wait.forLogMessage(".*ready for connections.*\\n", 1))
.withFileSystemBind(FLEX_TEST_DDL, DOCKER_INITDB_PATH + "flex_test.sql", BindMode.READ_ONLY) .withFileSystemBind(FLEX_TEST_DDL, DOCKER_INITDB_PATH + "flex_test.sql", BindMode.READ_ONLY)
.withFileSystemBind(ALIAS_TEST_DDL, DOCKER_INITDB_PATH + "alisa.sql", BindMode.READ_ONLY)
.withFileSystemBind(FIELD_MAPPING_TEST_DDL, DOCKER_INITDB_PATH + "field_mapping_test.sql", BindMode.READ_ONLY) .withFileSystemBind(FIELD_MAPPING_TEST_DDL, DOCKER_INITDB_PATH + "field_mapping_test.sql", BindMode.READ_ONLY)
.withFileSystemBind(PATIENT_DATA_SPLIT_TEST_DDL, DOCKER_INITDB_PATH + "patient_data_split_test.sql", BindMode.READ_ONLY) .withFileSystemBind(PATIENT_DATA_SPLIT_TEST_DDL, DOCKER_INITDB_PATH + "patient_data_split_test.sql", BindMode.READ_ONLY)
.withDatabaseName("flex_test") .withDatabaseName("flex_test")
.withReuse(true) .withReuse(true)
.withPassword("123456"); .withPassword("123456");
@BeforeAll // @BeforeAll
public static void start() { public static void start() {
mysql.setPortBindings(Collections.singletonList("3306:3306")); mysql.setPortBindings(Collections.singletonList("3306:3306"));
mysql.start(); mysql.start();