diff --git a/docs/assets/images/ad/admin-banner.jpg b/docs/assets/images/ad/admin-banner.jpg index 7dd2cb06..49e717d6 100644 Binary files a/docs/assets/images/ad/admin-banner.jpg and b/docs/assets/images/ad/admin-banner.jpg differ diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ControllerConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ControllerConfig.java index 020c8fb7..c30b073e 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ControllerConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ControllerConfig.java @@ -27,6 +27,10 @@ import java.io.Serializable; public class ControllerConfig implements Serializable { private static final long serialVersionUID = 8391630904705910611L; + /** + * 代码生成目录,当未配置时,使用 PackageConfig 的配置 + */ + private String sourceDir; /** * Controller 类的前缀。 */ @@ -60,6 +64,14 @@ public class ControllerConfig implements Serializable { return superClass.getSimpleName(); } + public String getSourceDir() { + return sourceDir; + } + + public void setSourceDir(String sourceDir) { + this.sourceDir = sourceDir; + } + /** * 获取类前缀。 */ diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/EntityConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/EntityConfig.java index 85cac658..3da5760e 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/EntityConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/EntityConfig.java @@ -27,6 +27,11 @@ import java.io.Serializable; public class EntityConfig implements Serializable { private static final long serialVersionUID = -6790274333595436008L; + /** + * 代码生成目录,当未配置时,使用 PackageConfig 的配置 + */ + private String sourceDir; + /** * Entity 类的前缀。 */ @@ -82,6 +87,14 @@ public class EntityConfig implements Serializable { */ private int jdkVersion; + public String getSourceDir() { + return sourceDir; + } + + public void setSourceDir(String sourceDir) { + this.sourceDir = sourceDir; + } + /** * 获取类前缀。 */ diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/MapperConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/MapperConfig.java index 064310e8..a52b6679 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/MapperConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/MapperConfig.java @@ -29,6 +29,11 @@ import java.io.Serializable; public class MapperConfig implements Serializable { private static final long serialVersionUID = 1937442008907641534L; + /** + * 代码生成目录,当未配置时,使用 PackageConfig 的配置 + */ + private String sourceDir; + /** * Mapper 类的前缀。 */ @@ -62,6 +67,14 @@ public class MapperConfig implements Serializable { return superClass.getSimpleName(); } + public String getSourceDir() { + return sourceDir; + } + + public void setSourceDir(String sourceDir) { + this.sourceDir = sourceDir; + } + /** * 获取类前缀。 */ diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/PackageConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/PackageConfig.java index 69b8770b..9df0e852 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/PackageConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/PackageConfig.java @@ -44,7 +44,6 @@ public class PackageConfig implements Serializable { * Entity 所在包。 */ private String entityPackage; - /** * Mapper 所在包。 */ diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ServiceConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ServiceConfig.java index d42a64cd..0193eac2 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ServiceConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ServiceConfig.java @@ -30,6 +30,11 @@ import java.io.Serializable; public class ServiceConfig implements Serializable { private static final long serialVersionUID = -2152473328300910220L; + /** + * 代码生成目录,当未配置时,使用 PackageConfig 的配置 + */ + private String sourceDir; + /** * Service 类的前缀。 */ @@ -58,6 +63,14 @@ public class ServiceConfig implements Serializable { return superClass.getSimpleName(); } + public String getSourceDir() { + return sourceDir; + } + + public void setSourceDir(String sourceDir) { + this.sourceDir = sourceDir; + } + /** * 获取类前缀。 */ diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ServiceImplConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ServiceImplConfig.java index 5d705fee..52f22432 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ServiceImplConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/ServiceImplConfig.java @@ -27,6 +27,12 @@ import java.io.Serializable; public class ServiceImplConfig implements Serializable { private static final long serialVersionUID = 17115432462168151L; + + /** + * 代码生成目录,当未配置时,使用 PackageConfig 的配置 + */ + private String sourceDir; + /** * ServiceImpl 类的前缀。 */ @@ -52,6 +58,14 @@ public class ServiceImplConfig implements Serializable { */ private boolean cacheExample; + public String getSourceDir() { + return sourceDir; + } + + public void setSourceDir(String sourceDir) { + this.sourceDir = sourceDir; + } + public String buildSuperClassImport() { if (superClass == null) { return "com.mybatisflex.spring.service.impl.ServiceImpl"; diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/TableDefConfig.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/TableDefConfig.java index c2e9ed41..157e926c 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/TableDefConfig.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/config/TableDefConfig.java @@ -29,6 +29,10 @@ import java.io.Serializable; public class TableDefConfig implements Serializable { private static final long serialVersionUID = 8137903163796008036L; + /** + * 代码生成目录,当未配置时,使用 PackageConfig 的配置 + */ + private String sourceDir; /** * TableDef 类的前缀。 */ @@ -68,6 +72,14 @@ public class TableDefConfig implements Serializable { } } + public String getSourceDir() { + return sourceDir; + } + + public void setSourceDir(String sourceDir) { + this.sourceDir = sourceDir; + } + /** * 获取类前缀。 */ diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ControllerGenerator.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ControllerGenerator.java index ec59a22d..adda7bb5 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ControllerGenerator.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ControllerGenerator.java @@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.PackageConfig; import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.generator.IGenerator; +import com.mybatisflex.core.util.StringUtil; import java.io.File; import java.util.HashMap; @@ -54,8 +55,10 @@ public class ControllerGenerator implements IGenerator { PackageConfig packageConfig = globalConfig.getPackageConfig(); ControllerConfig controllerConfig = globalConfig.getControllerConfig(); + String sourceDir = StringUtil.isNotBlank(controllerConfig.getSourceDir()) ? controllerConfig.getSourceDir() : packageConfig.getSourceDir(); + String controllerPackagePath = packageConfig.getControllerPackage().replace(".", "/"); - File controllerJavaFile = new File(packageConfig.getSourceDir(), controllerPackagePath + "/" + + File controllerJavaFile = new File(sourceDir, controllerPackagePath + "/" + table.buildControllerClassName() + ".java"); diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/EntityGenerator.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/EntityGenerator.java index e4b12817..9a165c91 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/EntityGenerator.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/EntityGenerator.java @@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.PackageConfig; import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.generator.IGenerator; +import com.mybatisflex.core.util.StringUtil; import java.io.File; import java.util.HashMap; @@ -54,8 +55,10 @@ public class EntityGenerator implements IGenerator { PackageConfig packageConfig = globalConfig.getPackageConfig(); EntityConfig entityConfig = globalConfig.getEntityConfig(); + String sourceDir = StringUtil.isNotBlank(entityConfig.getSourceDir()) ? entityConfig.getSourceDir() : packageConfig.getSourceDir(); + String entityPackagePath = packageConfig.getEntityPackage().replace(".", "/"); - File entityJavaFile = new File(packageConfig.getSourceDir(), entityPackagePath + "/" + + File entityJavaFile = new File(sourceDir, entityPackagePath + "/" + table.buildEntityClassName() + ".java"); diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/MapperGenerator.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/MapperGenerator.java index 12bd7d61..c775e00b 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/MapperGenerator.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/MapperGenerator.java @@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.PackageConfig; import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.generator.IGenerator; +import com.mybatisflex.core.util.StringUtil; import java.io.File; import java.util.HashMap; @@ -54,8 +55,10 @@ public class MapperGenerator implements IGenerator { PackageConfig packageConfig = globalConfig.getPackageConfig(); MapperConfig mapperConfig = globalConfig.getMapperConfig(); + String sourceDir = StringUtil.isNotBlank(mapperConfig.getSourceDir()) ? mapperConfig.getSourceDir() : packageConfig.getSourceDir(); + String mapperPackagePath = packageConfig.getMapperPackage().replace(".", "/"); - File mapperJavaFile = new File(packageConfig.getSourceDir(), mapperPackagePath + "/" + + File mapperJavaFile = new File(sourceDir, mapperPackagePath + "/" + table.buildMapperClassName() + ".java"); diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ServiceGenerator.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ServiceGenerator.java index 3a7ce530..c00ed5fa 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ServiceGenerator.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ServiceGenerator.java @@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.ServiceConfig; import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.generator.IGenerator; +import com.mybatisflex.core.util.StringUtil; import java.io.File; import java.util.HashMap; @@ -54,8 +55,10 @@ public class ServiceGenerator implements IGenerator { PackageConfig packageConfig = globalConfig.getPackageConfig(); ServiceConfig serviceConfig = globalConfig.getServiceConfig(); + String sourceDir = StringUtil.isNotBlank(serviceConfig.getSourceDir()) ? serviceConfig.getSourceDir() : packageConfig.getSourceDir(); + String servicePackagePath = packageConfig.getServicePackage().replace(".", "/"); - File serviceJavaFile = new File(packageConfig.getSourceDir(), servicePackagePath + "/" + + File serviceJavaFile = new File(sourceDir, servicePackagePath + "/" + table.buildServiceClassName() + ".java"); diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ServiceImplGenerator.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ServiceImplGenerator.java index 1d9a74a0..736d818b 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ServiceImplGenerator.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/ServiceImplGenerator.java @@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.ServiceImplConfig; import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.generator.IGenerator; +import com.mybatisflex.core.util.StringUtil; import java.io.File; import java.util.HashMap; @@ -54,8 +55,10 @@ public class ServiceImplGenerator implements IGenerator { PackageConfig packageConfig = globalConfig.getPackageConfig(); ServiceImplConfig serviceImplConfig = globalConfig.getServiceImplConfig(); + String sourceDir = StringUtil.isNotBlank(serviceImplConfig.getSourceDir()) ? serviceImplConfig.getSourceDir() : packageConfig.getSourceDir(); + String serviceImplPackagePath = packageConfig.getServiceImplPackage().replace(".", "/"); - File serviceImplJavaFile = new File(packageConfig.getSourceDir(), serviceImplPackagePath + "/" + + File serviceImplJavaFile = new File(sourceDir, serviceImplPackagePath + "/" + table.buildServiceImplClassName() + ".java"); diff --git a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/TableDefGenerator.java b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/TableDefGenerator.java index 214e34d1..ac298555 100644 --- a/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/TableDefGenerator.java +++ b/mybatis-flex-codegen/src/main/java/com/mybatisflex/codegen/generator/impl/TableDefGenerator.java @@ -21,6 +21,7 @@ import com.mybatisflex.codegen.config.TableDefConfig; import com.mybatisflex.codegen.constant.TemplateConst; import com.mybatisflex.codegen.entity.Table; import com.mybatisflex.codegen.generator.IGenerator; +import com.mybatisflex.core.util.StringUtil; import java.io.File; import java.util.HashMap; @@ -54,8 +55,10 @@ public class TableDefGenerator implements IGenerator { PackageConfig packageConfig = globalConfig.getPackageConfig(); TableDefConfig tableDefConfig = globalConfig.getTableDefConfig(); + String sourceDir = StringUtil.isNotBlank(tableDefConfig.getSourceDir()) ? tableDefConfig.getSourceDir() : packageConfig.getSourceDir(); + String tableDefPackagePath = packageConfig.getTableDefPackage().replace(".", "/"); - File tableDefJavaFile = new File(packageConfig.getSourceDir(), tableDefPackagePath + "/" + + File tableDefJavaFile = new File(sourceDir, tableDefPackagePath + "/" + table.buildTableDefClassName() + ".java"); diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/alisa.sql b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/alisa.sql index e41c91d2..f8194e8c 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/alisa.sql +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/alisa.sql @@ -1,7 +1,8 @@ -- Alisa Test SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; +SET +FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for sys_dept @@ -9,16 +10,15 @@ SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS `sys_dept`; CREATE TABLE `sys_dept` ( - `id` int NOT NULL AUTO_INCREMENT, - `dept_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, - `create_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, - `update_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `id` int NOT NULL AUTO_INCREMENT, + `dept_name` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `update_time` datetime NULL DEFAULT NULL, + `create_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, + `update_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 - COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC; -- ---------------------------- @@ -33,17 +33,16 @@ VALUES (1, '开发岗', NULL, NULL, 'DEPT', 'DEPT'); DROP TABLE IF EXISTS `sys_role`; CREATE TABLE `sys_role` ( - `id` int NOT NULL AUTO_INCREMENT, - `role_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, - `role_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, - `create_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, - `update_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `id` int NOT NULL AUTO_INCREMENT, + `role_key` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, + `role_name` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `update_time` datetime NULL DEFAULT NULL, + `create_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, + `update_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 - COLLATE = utf8mb4_0900_ai_ci 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`; CREATE TABLE `sys_user` ( - `id` int NOT NULL AUTO_INCREMENT, - `user_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, - `age` int NULL DEFAULT NULL, - `birthday` datetime NULL DEFAULT NULL, - `create_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, - `update_by` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, + `id` int NOT NULL AUTO_INCREMENT, + `user_name` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, + `age` int NULL DEFAULT NULL, + `birthday` datetime NULL DEFAULT NULL, + `create_time` datetime NULL DEFAULT NULL, + `update_time` datetime NULL DEFAULT NULL, + `create_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, + `update_by` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 - COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC; -- ---------------------------- @@ -78,4 +76,5 @@ CREATE TABLE `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'); -SET FOREIGN_KEY_CHECKS = 1; +SET +FOREIGN_KEY_CHECKS = 1; diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml index 0ce252f9..c6ae79f0 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml @@ -7,7 +7,7 @@ spring: # driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/flex_test username: root - password: 12345678 + password: 123456 # driver-class-name: # datasource: # driver-class-name: org.h2.Driver diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/flex_test.sql b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/flex_test.sql index 0de88288..bb2f4131 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/flex_test.sql +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/flex_test.sql @@ -1,5 +1,6 @@ SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; +SET +FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for tb_account @@ -7,12 +8,12 @@ SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS `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, - `age` int NULL DEFAULT NULL, - `birthday` datetime NULL DEFAULT NULL, - `gender` int NULL DEFAULT NULL, - `is_delete` tinyint(3) UNSIGNED ZEROFILL NULL DEFAULT NULL, + `age` int NULL DEFAULT NULL, + `birthday` datetime NULL DEFAULT NULL, + `gender` int NULL DEFAULT NULL, + `is_delete` tinyint(3) UNSIGNED ZEROFILL NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 5 @@ -35,11 +36,11 @@ VALUES (5, '王五', 18, '2023-07-04 15:00:26', NULL, 000); DROP TABLE IF EXISTS `tb_article`; CREATE TABLE `tb_article` ( - `id` int NOT NULL AUTO_INCREMENT, - `account_id` int NULL DEFAULT NULL, + `id` int NOT NULL AUTO_INCREMENT, + `account_id` int NULL DEFAULT NULL, `title` varchar(100) CHARACTER SET utf8mb4 NULL DEFAULT NULL, - `content` text CHARACTER SET utf8mb4 NULL, - `is_delete` int NULL DEFAULT NULL, + `content` text CHARACTER SET utf8mb4 NULL, + `is_delete` int NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 3 @@ -62,9 +63,9 @@ VALUES (3, 1, '标题3', '内容3', 0); DROP TABLE IF EXISTS `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, - `price` decimal(10, 2) NULL DEFAULT NULL, + `price` decimal(10, 2) NULL DEFAULT NULL, PRIMARY KEY (`good_id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 10 @@ -101,7 +102,7 @@ VALUES (10, '近代化学导论', 67.00); DROP TABLE IF EXISTS `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, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB @@ -126,7 +127,7 @@ VALUES (4, 'A33E8BAA-93F2-4E28-A161-15CF7D0AE6D0'); DROP TABLE IF EXISTS `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, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB @@ -146,7 +147,7 @@ VALUES (2, 'inner type'); DROP TABLE IF EXISTS `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, PRIMARY KEY (`order_id`) USING BTREE ) ENGINE = InnoDB @@ -218,7 +219,7 @@ VALUES (6, 10); DROP TABLE IF EXISTS `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, PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB @@ -238,7 +239,7 @@ VALUES (1, 'outer 01'); DROP TABLE IF EXISTS `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_name` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, PRIMARY KEY (`role_id`) USING BTREE @@ -265,7 +266,7 @@ VALUES (4, 'admin', '管理员用户'); DROP TABLE IF EXISTS `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, `password` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL, PRIMARY KEY (`user_id`) USING BTREE @@ -352,4 +353,5 @@ VALUES (4, 4); INSERT INTO `tb_user_role` VALUES (5, 1); -SET FOREIGN_KEY_CHECKS = 1; +SET +FOREIGN_KEY_CHECKS = 1; diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java index 128a4c0e..e924d8e7 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java @@ -1,6 +1,5 @@ package com.mybatisflex.test; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.BindMode; import org.testcontainers.containers.GenericContainer; @@ -12,6 +11,7 @@ import java.util.Collections; 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 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(); @@ -19,13 +19,14 @@ public class TestInfrastructure { static GenericContainer mysql = new MySQLContainer<>(DockerImageName.parse("mysql:8.2.0")) .waitingFor(Wait.forLogMessage(".*ready for connections.*\\n", 1)) .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(PATIENT_DATA_SPLIT_TEST_DDL, DOCKER_INITDB_PATH + "patient_data_split_test.sql", BindMode.READ_ONLY) .withDatabaseName("flex_test") .withReuse(true) .withPassword("123456"); - @BeforeAll +// @BeforeAll public static void start() { mysql.setPortBindings(Collections.singletonList("3306:3306")); mysql.start();