Commit 677a6d348f659eac9d95d729ef1c85f02140df72

Authored by dhb52
2 parents cba0b087 29ff4180

Merge remote-tracking branch 'upstream/master'

Showing 236 changed files with 13585 additions and 1647 deletions

Too many changes.

To preserve performance only 100 of 236 files are displayed.

sql/mysql/ruoyi-vue-pro.sql
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 Target Server Version : 80034 11 Target Server Version : 80034
12 File Encoding : 65001 12 File Encoding : 65001
13 13
14 - Date: 04/11/2023 20:42:49 14 + Date: 18/11/2023 17:48:18
15 */ 15 */
16 16
17 SET NAMES utf8mb4; 17 SET NAMES utf8mb4;
@@ -385,7 +385,7 @@ CREATE TABLE `infra_api_error_log` ( @@ -385,7 +385,7 @@ CREATE TABLE `infra_api_error_log` (
385 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 385 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
386 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 386 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
387 PRIMARY KEY (`id`) USING BTREE 387 PRIMARY KEY (`id`) USING BTREE
388 -) ENGINE = InnoDB AUTO_INCREMENT = 1781 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志'; 388 +) ENGINE = InnoDB AUTO_INCREMENT = 1964 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志';
389 389
390 -- ---------------------------- 390 -- ----------------------------
391 -- Records of infra_api_error_log 391 -- Records of infra_api_error_log
@@ -423,7 +423,7 @@ CREATE TABLE `infra_codegen_column` ( @@ -423,7 +423,7 @@ CREATE TABLE `infra_codegen_column` (
423 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 423 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
424 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 424 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
425 PRIMARY KEY (`id`) USING BTREE 425 PRIMARY KEY (`id`) USING BTREE
426 -) ENGINE = InnoDB AUTO_INCREMENT = 1804 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表字段定义'; 426 +) ENGINE = InnoDB AUTO_INCREMENT = 1905 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表字段定义';
427 427
428 -- ---------------------------- 428 -- ----------------------------
429 -- Records of infra_codegen_column 429 -- Records of infra_codegen_column
@@ -450,13 +450,18 @@ CREATE TABLE `infra_codegen_table` ( @@ -450,13 +450,18 @@ CREATE TABLE `infra_codegen_table` (
450 `template_type` tinyint NOT NULL DEFAULT 1 COMMENT '模板类型', 450 `template_type` tinyint NOT NULL DEFAULT 1 COMMENT '模板类型',
451 `front_type` tinyint NOT NULL COMMENT '前端类型', 451 `front_type` tinyint NOT NULL COMMENT '前端类型',
452 `parent_menu_id` bigint NULL DEFAULT NULL COMMENT '父菜单编号', 452 `parent_menu_id` bigint NULL DEFAULT NULL COMMENT '父菜单编号',
  453 + `master_table_id` bigint NULL DEFAULT NULL COMMENT '主表的编号',
  454 + `sub_join_column_id` bigint NULL DEFAULT NULL COMMENT '子表关联主表的字段编号',
  455 + `sub_join_many` bit(1) NULL DEFAULT NULL COMMENT '主表与子表是否一对多',
  456 + `tree_parent_column_id` bigint NULL DEFAULT NULL COMMENT '树表的父字段编号',
  457 + `tree_name_column_id` bigint NULL DEFAULT NULL COMMENT '树表的名字字段编号',
453 `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', 458 `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
454 `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 459 `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
455 `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', 460 `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
456 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 461 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
457 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 462 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
458 PRIMARY KEY (`id`) USING BTREE 463 PRIMARY KEY (`id`) USING BTREE
459 -) ENGINE = InnoDB AUTO_INCREMENT = 136 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表定义'; 464 +) ENGINE = InnoDB AUTO_INCREMENT = 146 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表定义';
460 465
461 -- ---------------------------- 466 -- ----------------------------
462 -- Records of infra_codegen_table 467 -- Records of infra_codegen_table
@@ -522,6 +527,150 @@ BEGIN; @@ -522,6 +527,150 @@ BEGIN;
522 COMMIT; 527 COMMIT;
523 528
524 -- ---------------------------- 529 -- ----------------------------
  530 +-- Table structure for infra_demo01_contact
  531 +-- ----------------------------
  532 +DROP TABLE IF EXISTS `infra_demo01_contact`;
  533 +CREATE TABLE `infra_demo01_contact` (
  534 + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  535 + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名字',
  536 + `sex` tinyint(1) NOT NULL COMMENT '性别',
  537 + `birthday` datetime NOT NULL COMMENT '出生年',
  538 + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '简介',
  539 + `avatar` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '头像',
  540 + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  541 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  542 + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  543 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  544 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  545 + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  546 + PRIMARY KEY (`id`) USING BTREE
  547 +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '示例联系人表';
  548 +
  549 +-- ----------------------------
  550 +-- Records of infra_demo01_contact
  551 +-- ----------------------------
  552 +BEGIN;
  553 +INSERT INTO `infra_demo01_contact` (`id`, `name`, `sex`, `birthday`, `description`, `avatar`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, '土豆', 2, '2023-11-07 00:00:00', '<p>天蚕土豆!呀</p>', 'http://127.0.0.1:48080/admin-api/infra/file/4/get/46f8fa1a37db3f3960d8910ff2fe3962ab3b2db87cf2f8ccb4dc8145b8bdf237.jpeg', '1', '2023-11-15 23:34:30', '1', '2023-11-15 23:47:39', b'0', 1);
  554 +COMMIT;
  555 +
  556 +-- ----------------------------
  557 +-- Table structure for infra_demo02_category
  558 +-- ----------------------------
  559 +DROP TABLE IF EXISTS `infra_demo02_category`;
  560 +CREATE TABLE `infra_demo02_category` (
  561 + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  562 + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名字',
  563 + `parent_id` bigint NOT NULL COMMENT '父级编号',
  564 + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  565 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  566 + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  567 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  568 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  569 + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  570 + PRIMARY KEY (`id`) USING BTREE
  571 +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '示例分类表';
  572 +
  573 +-- ----------------------------
  574 +-- Records of infra_demo02_category
  575 +-- ----------------------------
  576 +BEGIN;
  577 +INSERT INTO `infra_demo02_category` (`id`, `name`, `parent_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, '土豆', 0, '1', '2023-11-15 23:34:30', '1', '2023-11-16 20:24:23', b'0', 1);
  578 +INSERT INTO `infra_demo02_category` (`id`, `name`, `parent_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, '番茄', 0, '1', '2023-11-16 20:24:00', '1', '2023-11-16 20:24:15', b'0', 1);
  579 +INSERT INTO `infra_demo02_category` (`id`, `name`, `parent_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (3, '怪怪', 0, '1', '2023-11-16 20:24:32', '1', '2023-11-16 20:24:32', b'0', 1);
  580 +INSERT INTO `infra_demo02_category` (`id`, `name`, `parent_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, '小番茄', 2, '1', '2023-11-16 20:24:39', '1', '2023-11-16 20:24:39', b'0', 1);
  581 +INSERT INTO `infra_demo02_category` (`id`, `name`, `parent_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, '大番茄', 2, '1', '2023-11-16 20:24:46', '1', '2023-11-16 20:24:46', b'0', 1);
  582 +COMMIT;
  583 +
  584 +-- ----------------------------
  585 +-- Table structure for infra_demo03_course
  586 +-- ----------------------------
  587 +DROP TABLE IF EXISTS `infra_demo03_course`;
  588 +CREATE TABLE `infra_demo03_course` (
  589 + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  590 + `student_id` bigint NOT NULL COMMENT '学生编号',
  591 + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名字',
  592 + `score` tinyint NOT NULL COMMENT '分数',
  593 + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  594 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  595 + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  596 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  597 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  598 + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  599 + PRIMARY KEY (`id`) USING BTREE
  600 +) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '学生课程表';
  601 +
  602 +-- ----------------------------
  603 +-- Records of infra_demo03_course
  604 +-- ----------------------------
  605 +BEGIN;
  606 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, 2, '语文', 66, '1', '2023-11-16 23:21:49', '1', '2023-11-16 23:21:49', b'0', 1);
  607 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (3, 2, '数学', 22, '1', '2023-11-16 23:21:49', '1', '2023-11-16 23:21:49', b'0', 1);
  608 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (6, 5, '体育', 23, '1', '2023-11-16 23:22:46', '1', '2023-11-16 15:44:40', b'1', 1);
  609 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (7, 5, '计算机', 11, '1', '2023-11-16 23:22:46', '1', '2023-11-16 15:44:40', b'1', 1);
  610 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (8, 5, '体育', 23, '1', '2023-11-16 23:22:46', '1', '2023-11-16 15:47:09', b'1', 1);
  611 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (9, 5, '计算机', 11, '1', '2023-11-16 23:22:46', '1', '2023-11-16 15:47:09', b'1', 1);
  612 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (10, 5, '体育', 23, '1', '2023-11-16 23:22:46', '1', '2023-11-16 23:47:10', b'0', 1);
  613 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (11, 5, '计算机', 11, '1', '2023-11-16 23:22:46', '1', '2023-11-16 23:47:10', b'0', 1);
  614 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (12, 2, '电脑', 33, '1', '2023-11-17 00:20:42', '1', '2023-11-16 16:20:45', b'1', 1);
  615 +INSERT INTO `infra_demo03_course` (`id`, `student_id`, `name`, `score`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (13, 9, '滑雪', 12, '1', '2023-11-17 13:13:20', '1', '2023-11-17 13:13:20', b'0', 1);
  616 +COMMIT;
  617 +
  618 +-- ----------------------------
  619 +-- Table structure for infra_demo03_grade
  620 +-- ----------------------------
  621 +DROP TABLE IF EXISTS `infra_demo03_grade`;
  622 +CREATE TABLE `infra_demo03_grade` (
  623 + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  624 + `student_id` bigint NOT NULL COMMENT '学生编号',
  625 + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名字',
  626 + `teacher` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '班主任',
  627 + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  628 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  629 + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  630 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  631 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  632 + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  633 + PRIMARY KEY (`id`) USING BTREE
  634 +) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '学生班级表';
  635 +
  636 +-- ----------------------------
  637 +-- Records of infra_demo03_grade
  638 +-- ----------------------------
  639 +BEGIN;
  640 +INSERT INTO `infra_demo03_grade` (`id`, `student_id`, `name`, `teacher`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (7, 2, '三年 2 班', '周杰伦', '1', '2023-11-16 23:21:49', '1', '2023-11-16 23:21:49', b'0', 1);
  641 +INSERT INTO `infra_demo03_grade` (`id`, `student_id`, `name`, `teacher`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (8, 5, '华为', '遥遥领先', '1', '2023-11-16 23:22:46', '1', '2023-11-16 23:47:10', b'0', 1);
  642 +INSERT INTO `infra_demo03_grade` (`id`, `student_id`, `name`, `teacher`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (9, 9, '小图', '小娃111', '1', '2023-11-17 13:10:23', '1', '2023-11-17 13:10:23', b'0', 1);
  643 +COMMIT;
  644 +
  645 +-- ----------------------------
  646 +-- Table structure for infra_demo03_student
  647 +-- ----------------------------
  648 +DROP TABLE IF EXISTS `infra_demo03_student`;
  649 +CREATE TABLE `infra_demo03_student` (
  650 + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  651 + `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名字',
  652 + `sex` tinyint NOT NULL COMMENT '性别',
  653 + `birthday` datetime NOT NULL COMMENT '出生日期',
  654 + `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '简介',
  655 + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  656 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  657 + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  658 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  659 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  660 + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  661 + PRIMARY KEY (`id`) USING BTREE
  662 +) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '学生表';
  663 +
  664 +-- ----------------------------
  665 +-- Records of infra_demo03_student
  666 +-- ----------------------------
  667 +BEGIN;
  668 +INSERT INTO `infra_demo03_student` (`id`, `name`, `sex`, `birthday`, `description`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, '小白', 1, '2023-11-16 00:00:00', '<p>厉害</p>', '1', '2023-11-16 23:21:49', '1', '2023-11-17 16:49:06', b'0', 1);
  669 +INSERT INTO `infra_demo03_student` (`id`, `name`, `sex`, `birthday`, `description`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, '大黑', 2, '2023-11-13 00:00:00', '<p>你在教我做事?</p>', '1', '2023-11-16 23:22:46', '1', '2023-11-17 16:49:07', b'0', 1);
  670 +INSERT INTO `infra_demo03_student` (`id`, `name`, `sex`, `birthday`, `description`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (9, '小花', 1, '2023-11-07 00:00:00', '<p>哈哈哈</p>', '1', '2023-11-17 00:04:47', '1', '2023-11-17 16:49:08', b'0', 1);
  671 +COMMIT;
  672 +
  673 +-- ----------------------------
525 -- Table structure for infra_file 674 -- Table structure for infra_file
526 -- ---------------------------- 675 -- ----------------------------
527 DROP TABLE IF EXISTS `infra_file`; 676 DROP TABLE IF EXISTS `infra_file`;
@@ -539,7 +688,7 @@ CREATE TABLE `infra_file` ( @@ -539,7 +688,7 @@ CREATE TABLE `infra_file` (
539 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 688 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
540 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 689 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
541 PRIMARY KEY (`id`) USING BTREE 690 PRIMARY KEY (`id`) USING BTREE
542 -) ENGINE = InnoDB AUTO_INCREMENT = 1108 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表'; 691 +) ENGINE = InnoDB AUTO_INCREMENT = 1128 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表';
543 692
544 -- ---------------------------- 693 -- ----------------------------
545 -- Records of infra_file 694 -- Records of infra_file
@@ -588,7 +737,7 @@ CREATE TABLE `infra_file_content` ( @@ -588,7 +737,7 @@ CREATE TABLE `infra_file_content` (
588 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 737 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
589 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 738 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
590 PRIMARY KEY (`id`) USING BTREE 739 PRIMARY KEY (`id`) USING BTREE
591 -) ENGINE = InnoDB AUTO_INCREMENT = 202 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表'; 740 +) ENGINE = InnoDB AUTO_INCREMENT = 221 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表';
592 741
593 -- ---------------------------- 742 -- ----------------------------
594 -- Records of infra_file_content 743 -- Records of infra_file_content
@@ -666,31 +815,6 @@ BEGIN; @@ -666,31 +815,6 @@ BEGIN;
666 COMMIT; 815 COMMIT;
667 816
668 -- ---------------------------- 817 -- ----------------------------
669 --- Table structure for infra_test_demo  
670 --- ----------------------------  
671 -DROP TABLE IF EXISTS `infra_test_demo`;  
672 -CREATE TABLE `infra_test_demo` (  
673 - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',  
674 - `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名字',  
675 - `status` tinyint NOT NULL DEFAULT 0 COMMENT '状态',  
676 - `type` tinyint NOT NULL COMMENT '类型',  
677 - `category` tinyint NOT NULL COMMENT '分类',  
678 - `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',  
679 - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',  
680 - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',  
681 - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',  
682 - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',  
683 - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',  
684 - PRIMARY KEY (`id`) USING BTREE  
685 -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典类型表';  
686 -  
687 --- ----------------------------  
688 --- Records of infra_test_demo  
689 --- ----------------------------  
690 -BEGIN;  
691 -COMMIT;  
692 -  
693 --- ----------------------------  
694 -- Table structure for member_address 818 -- Table structure for member_address
695 -- ---------------------------- 819 -- ----------------------------
696 DROP TABLE IF EXISTS `member_address`; 820 DROP TABLE IF EXISTS `member_address`;
@@ -1131,7 +1255,7 @@ CREATE TABLE `system_dept` ( @@ -1131,7 +1255,7 @@ CREATE TABLE `system_dept` (
1131 -- Records of system_dept 1255 -- Records of system_dept
1132 -- ---------------------------- 1256 -- ----------------------------
1133 BEGIN; 1257 BEGIN;
1134 -INSERT INTO `system_dept` (`id`, `name`, `parent_id`, `sort`, `leader_user_id`, `phone`, `email`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, '芋道源码', 0, 0, 1, '15888888888', 'ry@qq.com', 0, 'admin', '2021-01-05 17:03:47', '1', '2022-06-19 00:29:10', b'0', 1); 1258 +INSERT INTO `system_dept` (`id`, `name`, `parent_id`, `sort`, `leader_user_id`, `phone`, `email`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, '芋道源码', 0, 0, 1, '15888888888', 'ry@qq.com', 0, 'admin', '2021-01-05 17:03:47', '1', '2023-11-14 23:30:36', b'0', 1);
1135 INSERT INTO `system_dept` (`id`, `name`, `parent_id`, `sort`, `leader_user_id`, `phone`, `email`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (101, '深圳总公司', 100, 1, 104, '15888888888', 'ry@qq.com', 0, 'admin', '2021-01-05 17:03:47', '1', '2022-05-16 20:25:23', b'0', 1); 1259 INSERT INTO `system_dept` (`id`, `name`, `parent_id`, `sort`, `leader_user_id`, `phone`, `email`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (101, '深圳总公司', 100, 1, 104, '15888888888', 'ry@qq.com', 0, 'admin', '2021-01-05 17:03:47', '1', '2022-05-16 20:25:23', b'0', 1);
1136 INSERT INTO `system_dept` (`id`, `name`, `parent_id`, `sort`, `leader_user_id`, `phone`, `email`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (102, '长沙分公司', 100, 2, NULL, '15888888888', 'ry@qq.com', 0, 'admin', '2021-01-05 17:03:47', '', '2021-12-15 05:01:40', b'0', 1); 1260 INSERT INTO `system_dept` (`id`, `name`, `parent_id`, `sort`, `leader_user_id`, `phone`, `email`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (102, '长沙分公司', 100, 2, NULL, '15888888888', 'ry@qq.com', 0, 'admin', '2021-01-05 17:03:47', '', '2021-12-15 05:01:40', b'0', 1);
1137 INSERT INTO `system_dept` (`id`, `name`, `parent_id`, `sort`, `leader_user_id`, `phone`, `email`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, '研发部门', 101, 1, 104, '15888888888', 'ry@qq.com', 0, 'admin', '2021-01-05 17:03:47', '103', '2022-01-14 01:04:14', b'0', 1); 1261 INSERT INTO `system_dept` (`id`, `name`, `parent_id`, `sort`, `leader_user_id`, `phone`, `email`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, '研发部门', 101, 1, 104, '15888888888', 'ry@qq.com', 0, 'admin', '2021-01-05 17:03:47', '103', '2022-01-14 01:04:14', b'0', 1);
@@ -1165,14 +1289,14 @@ CREATE TABLE `system_dict_data` ( @@ -1165,14 +1289,14 @@ CREATE TABLE `system_dict_data` (
1165 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 1289 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
1166 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 1290 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
1167 PRIMARY KEY (`id`) USING BTREE 1291 PRIMARY KEY (`id`) USING BTREE
1168 -) ENGINE = InnoDB AUTO_INCREMENT = 1435 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典数据表'; 1292 +) ENGINE = InnoDB AUTO_INCREMENT = 1447 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典数据表';
1169 1293
1170 -- ---------------------------- 1294 -- ----------------------------
1171 -- Records of system_dict_data 1295 -- Records of system_dict_data
1172 -- ---------------------------- 1296 -- ----------------------------
1173 BEGIN; 1297 BEGIN;
1174 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, 1, '男', '1', 'system_user_sex', 0, 'default', 'A', '性别男', 'admin', '2021-01-05 17:03:48', '1', '2022-03-29 00:14:39', b'0'); 1298 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, 1, '男', '1', 'system_user_sex', 0, 'default', 'A', '性别男', 'admin', '2021-01-05 17:03:48', '1', '2022-03-29 00:14:39', b'0');
1175 -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2, 2, '女', '2', 'system_user_sex', 1, 'success', '', '性别女', 'admin', '2021-01-05 17:03:48', '1', '2022-02-16 01:30:51', b'0'); 1299 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2, 2, '女', '2', 'system_user_sex', 0, 'success', '', '性别女', 'admin', '2021-01-05 17:03:48', '1', '2023-11-15 23:30:37', b'0');
1176 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (8, 1, '正常', '1', 'infra_job_status', 0, 'success', '', '正常状态', 'admin', '2021-01-05 17:03:48', '1', '2022-02-16 19:33:38', b'0'); 1300 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (8, 1, '正常', '1', 'infra_job_status', 0, 'success', '', '正常状态', 'admin', '2021-01-05 17:03:48', '1', '2022-02-16 19:33:38', b'0');
1177 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (9, 2, '暂停', '2', 'infra_job_status', 0, 'danger', '', '停用状态', 'admin', '2021-01-05 17:03:48', '1', '2022-02-16 19:33:45', b'0'); 1301 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (9, 2, '暂停', '2', 'infra_job_status', 0, 'danger', '', '停用状态', 'admin', '2021-01-05 17:03:48', '1', '2022-02-16 19:33:45', b'0');
1178 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (12, 1, '系统内置', '1', 'infra_config_type', 0, 'danger', '', '参数类型 - 系统内置', 'admin', '2021-01-05 17:03:48', '1', '2022-02-16 19:06:02', b'0'); 1302 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (12, 1, '系统内置', '1', 'infra_config_type', 0, 'danger', '', '参数类型 - 系统内置', 'admin', '2021-01-05 17:03:48', '1', '2022-02-16 19:06:02', b'0');
@@ -1474,6 +1598,12 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st @@ -1474,6 +1598,12 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st
1474 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1438, 31, '微信公众平台', '31', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:18', '1', '2023-11-04 13:05:18', b'0'); 1598 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1438, 31, '微信公众平台', '31', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:18', '1', '2023-11-04 13:05:18', b'0');
1475 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1439, 32, '微信开放平台', '32', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:30', '1', '2023-11-04 13:05:30', b'0'); 1599 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1439, 32, '微信开放平台', '32', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:30', '1', '2023-11-04 13:05:30', b'0');
1476 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1440, 34, '微信小程序', '34', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:38', '1', '2023-11-04 13:07:16', b'0'); 1600 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1440, 34, '微信小程序', '34', 'system_social_type', 0, '', '', '', '1', '2023-11-04 13:05:38', '1', '2023-11-04 13:07:16', b'0');
  1601 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1441, 1, '上架', '1', 'crm_product_status', 0, 'success', '', '', '1', '2023-10-30 21:49:34', '1', '2023-10-30 21:49:34', b'0');
  1602 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1442, 0, '下架', '0', 'crm_product_status', 0, 'success', '', '', '1', '2023-10-30 21:49:13', '1', '2023-10-30 21:49:13', b'0');
  1603 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1443, 15, '子表', '15', 'infra_codegen_template_type', 0, 'default', '', '', '1', '2023-11-13 23:06:16', '1', '2023-11-13 23:06:16', b'0');
  1604 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1444, 10, '主表(标准模式)', '10', 'infra_codegen_template_type', 0, 'default', '', '', '1', '2023-11-14 12:32:49', '1', '2023-11-14 12:32:49', b'0');
  1605 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1445, 11, '主表(ERP 模式)', '11', 'infra_codegen_template_type', 0, 'default', '', '', '1', '2023-11-14 12:33:05', '1', '2023-11-14 12:33:05', b'0');
  1606 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1446, 12, '主表(内嵌模式)', '12', 'infra_codegen_template_type', 0, '', '', '', '1', '2023-11-14 12:33:31', '1', '2023-11-14 12:33:31', b'0');
1477 COMMIT; 1607 COMMIT;
1478 1608
1479 -- ---------------------------- 1609 -- ----------------------------
@@ -1494,7 +1624,7 @@ CREATE TABLE `system_dict_type` ( @@ -1494,7 +1624,7 @@ CREATE TABLE `system_dict_type` (
1494 `deleted_time` datetime NULL DEFAULT NULL COMMENT '删除时间', 1624 `deleted_time` datetime NULL DEFAULT NULL COMMENT '删除时间',
1495 PRIMARY KEY (`id`) USING BTREE, 1625 PRIMARY KEY (`id`) USING BTREE,
1496 UNIQUE INDEX `dict_type`(`type` ASC) USING BTREE 1626 UNIQUE INDEX `dict_type`(`type` ASC) USING BTREE
1497 -) ENGINE = InnoDB AUTO_INCREMENT = 600 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典类型表'; 1627 +) ENGINE = InnoDB AUTO_INCREMENT = 605 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典类型表';
1498 1628
1499 -- ---------------------------- 1629 -- ----------------------------
1500 -- Records of system_dict_type 1630 -- Records of system_dict_type
@@ -1573,6 +1703,7 @@ INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creat @@ -1573,6 +1703,7 @@ INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creat
1573 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (188, '客户来源', 'crm_customer_source', 0, 'CRM 客户来源', '1', '2023-10-28 23:00:34', '1', '2023-10-28 15:11:16', b'0', NULL); 1703 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (188, '客户来源', 'crm_customer_source', 0, 'CRM 客户来源', '1', '2023-10-28 23:00:34', '1', '2023-10-28 15:11:16', b'0', NULL);
1574 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (600, 'Banner 位置', 'promotion_banner_position', 0, '', '1', '2023-10-08 07:24:25', '1', '2023-11-04 13:04:02', b'0', '1970-01-01 00:00:00'); 1704 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (600, 'Banner 位置', 'promotion_banner_position', 0, '', '1', '2023-10-08 07:24:25', '1', '2023-11-04 13:04:02', b'0', '1970-01-01 00:00:00');
1575 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (601, '社交类型', 'system_social_type', 0, '', '1', '2023-11-04 13:03:54', '1', '2023-11-04 13:03:54', b'0', '1970-01-01 00:00:00'); 1705 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (601, '社交类型', 'system_social_type', 0, '', '1', '2023-11-04 13:03:54', '1', '2023-11-04 13:03:54', b'0', '1970-01-01 00:00:00');
  1706 +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (604, '产品状态', 'crm_product_status', 0, '', '1', '2023-10-30 21:47:59', '1', '2023-10-30 21:48:45', b'0', '1970-01-01 00:00:00');
1576 COMMIT; 1707 COMMIT;
1577 1708
1578 -- ---------------------------- 1709 -- ----------------------------
@@ -1621,7 +1752,7 @@ CREATE TABLE `system_login_log` ( @@ -1621,7 +1752,7 @@ CREATE TABLE `system_login_log` (
1621 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 1752 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
1622 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 1753 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
1623 PRIMARY KEY (`id`) USING BTREE 1754 PRIMARY KEY (`id`) USING BTREE
1624 -) ENGINE = InnoDB AUTO_INCREMENT = 2631 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录'; 1755 +) ENGINE = InnoDB AUTO_INCREMENT = 2647 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录';
1625 1756
1626 -- ---------------------------- 1757 -- ----------------------------
1627 -- Records of system_login_log 1758 -- Records of system_login_log
@@ -1751,7 +1882,7 @@ CREATE TABLE `system_menu` ( @@ -1751,7 +1882,7 @@ CREATE TABLE `system_menu` (
1751 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 1882 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
1752 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 1883 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
1753 PRIMARY KEY (`id`) USING BTREE 1884 PRIMARY KEY (`id`) USING BTREE
1754 -) ENGINE = InnoDB AUTO_INCREMENT = 2449 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '菜单权限表'; 1885 +) ENGINE = InnoDB AUTO_INCREMENT = 2504 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '菜单权限表';
1755 1886
1756 -- ---------------------------- 1887 -- ----------------------------
1757 -- Records of system_menu 1888 -- Records of system_menu
@@ -1839,11 +1970,7 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i @@ -1839,11 +1970,7 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
1839 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1065, '设置用户角色', 'system:permission:assign-user-role', 3, 8, 101, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-01-07 10:23:28', '', '2022-04-20 17:03:10', b'0'); 1970 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1065, '设置用户角色', 'system:permission:assign-user-role', 3, 8, 101, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-01-07 10:23:28', '', '2022-04-20 17:03:10', b'0');
1840 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1066, '获得 Redis 监控信息', 'infra:redis:get-monitor-info', 3, 1, 113, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-01-26 01:02:31', '', '2022-04-20 17:03:10', b'0'); 1971 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1066, '获得 Redis 监控信息', 'infra:redis:get-monitor-info', 3, 1, 113, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-01-26 01:02:31', '', '2022-04-20 17:03:10', b'0');
1841 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1067, '获得 Redis Key 列表', 'infra:redis:get-key-list', 3, 2, 113, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-01-26 01:02:52', '', '2022-04-20 17:03:10', b'0'); 1972 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1067, '获得 Redis Key 列表', 'infra:redis:get-key-list', 3, 2, 113, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-01-26 01:02:52', '', '2022-04-20 17:03:10', b'0');
1842 -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1070, '代码生成示例', 'infra:test-demo:query', 2, 1, 2, 'test-demo', 'validCode', 'infra/testDemo/index', NULL, 0, b'1', b'1', b'1', '', '2021-02-06 12:42:49', '1', '2022-04-20 17:03:10', b'0');  
1843 -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1071, '测试示例表创建', 'infra:test-demo:create', 3, 1, 1070, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-02-06 12:42:49', '1', '2022-04-20 17:03:10', b'0');  
1844 -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1072, '测试示例表更新', 'infra:test-demo:update', 3, 2, 1070, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-02-06 12:42:49', '1', '2022-04-20 17:03:10', b'0');  
1845 -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1073, '测试示例表删除', 'infra:test-demo:delete', 3, 3, 1070, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-02-06 12:42:49', '1', '2022-04-20 17:03:10', b'0');  
1846 -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1074, '测试示例表导出', 'infra:test-demo:export', 3, 4, 1070, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-02-06 12:42:49', '1', '2022-04-20 17:03:10', b'0'); 1973 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1070, '代码生成案例', '', 1, 1, 2, 'demo', 'ep:aim', 'infra/testDemo/index', NULL, 0, b'1', b'1', b'1', '', '2021-02-06 12:42:49', '1', '2023-11-15 23:45:53', b'0');
1847 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1075, '任务触发', 'infra:job:trigger', 3, 8, 110, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-02-07 13:03:10', '', '2022-04-20 17:03:10', b'0'); 1974 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1075, '任务触发', 'infra:job:trigger', 3, 8, 110, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2021-02-07 13:03:10', '', '2022-04-20 17:03:10', b'0');
1848 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1076, '数据库文档', '', 2, 4, 2, 'db-doc', 'table', 'infra/dbDoc/index', 'InfraDBDoc', 0, b'1', b'1', b'1', '', '2021-02-08 01:41:47', '1', '2023-04-08 09:13:38', b'0'); 1975 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1076, '数据库文档', '', 2, 4, 2, 'db-doc', 'table', 'infra/dbDoc/index', 'InfraDBDoc', 0, b'1', b'1', b'1', '', '2021-02-08 01:41:47', '1', '2023-04-08 09:13:38', b'0');
1849 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1077, '监控平台', '', 2, 13, 2, 'skywalking', 'eye-open', 'infra/skywalking/index', 'InfraSkyWalking', 0, b'1', b'1', b'1', '', '2021-02-08 20:41:31', '1', '2023-04-08 10:39:06', b'0'); 1976 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1077, '监控平台', '', 2, 13, 2, 'skywalking', 'eye-open', 'infra/skywalking/index', 'InfraSkyWalking', 0, b'1', b'1', b'1', '', '2021-02-08 20:41:31', '1', '2023-04-08 10:39:06', b'0');
@@ -2310,6 +2437,26 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i @@ -2310,6 +2437,26 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
2310 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2451, '三方应用更新', 'system:social-client:update', 3, 3, 2448, '', '', '', '', 0, b'1', b'1', b'1', '1', '2023-11-04 12:44:27', '1', '2023-11-04 12:44:27', b'0'); 2437 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2451, '三方应用更新', 'system:social-client:update', 3, 3, 2448, '', '', '', '', 0, b'1', b'1', b'1', '1', '2023-11-04 12:44:27', '1', '2023-11-04 12:44:27', b'0');
2311 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2452, '三方应用删除', 'system:social-client:delete', 3, 4, 2448, '', '', '', '', 0, b'1', b'1', b'1', '1', '2023-11-04 12:44:43', '1', '2023-11-04 12:44:43', b'0'); 2438 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2452, '三方应用删除', 'system:social-client:delete', 3, 4, 2448, '', '', '', '', 0, b'1', b'1', b'1', '1', '2023-11-04 12:44:43', '1', '2023-11-04 12:44:43', b'0');
2312 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2453, '三方用户', 'system:social-user:query', 2, 2, 2447, 'user', 'ep:avatar', 'system/social/user/index.vue', 'SocialUser', 0, b'1', b'1', b'1', '1', '2023-11-04 14:01:05', '1', '2023-11-04 14:01:05', b'0'); 2439 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2453, '三方用户', 'system:social-user:query', 2, 2, 2447, 'user', 'ep:avatar', 'system/social/user/index.vue', 'SocialUser', 0, b'1', b'1', b'1', '1', '2023-11-04 14:01:05', '1', '2023-11-04 14:01:05', b'0');
  2440 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2472, '主子表(内嵌)', '', 2, 12, 1070, 'demo03-inner', 'fa:power-off', 'infra/demo/demo03/inner/index', 'Demo03StudentInner', 0, b'1', b'1', b'1', '', '2023-11-13 04:39:51', '1', '2023-11-16 23:53:46', b'0');
  2441 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2478, '单表(增删改查)', '', 2, 1, 1070, 'demo01-contact', 'ep:bicycle', 'infra/demo/demo01/index', 'Demo01Contact', 0, b'1', b'1', b'1', '', '2023-11-15 14:42:30', '1', '2023-11-16 20:34:40', b'0');
  2442 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2479, '示例联系人查询', 'infra:demo01-contact:query', 3, 1, 2478, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-15 14:42:30', '', '2023-11-15 14:42:30', b'0');
  2443 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2480, '示例联系人创建', 'infra:demo01-contact:create', 3, 2, 2478, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-15 14:42:30', '', '2023-11-15 14:42:30', b'0');
  2444 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2481, '示例联系人更新', 'infra:demo01-contact:update', 3, 3, 2478, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-15 14:42:30', '', '2023-11-15 14:42:30', b'0');
  2445 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2482, '示例联系人删除', 'infra:demo01-contact:delete', 3, 4, 2478, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-15 14:42:30', '', '2023-11-15 14:42:30', b'0');
  2446 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2483, '示例联系人导出', 'infra:demo01-contact:export', 3, 5, 2478, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-15 14:42:30', '', '2023-11-15 14:42:30', b'0');
  2447 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2484, '树表(增删改查)', '', 2, 2, 1070, 'demo02-category', 'fa:tree', 'infra/demo/demo02/index', 'Demo02Category', 0, b'1', b'1', b'1', '', '2023-11-16 12:18:27', '1', '2023-11-16 20:35:01', b'0');
  2448 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2485, '示例分类查询', 'infra:demo02-category:query', 3, 1, 2484, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:18:27', '', '2023-11-16 12:18:27', b'0');
  2449 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2486, '示例分类创建', 'infra:demo02-category:create', 3, 2, 2484, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:18:27', '', '2023-11-16 12:18:27', b'0');
  2450 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2487, '示例分类更新', 'infra:demo02-category:update', 3, 3, 2484, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:18:27', '', '2023-11-16 12:18:27', b'0');
  2451 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2488, '示例分类删除', 'infra:demo02-category:delete', 3, 4, 2484, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:18:27', '', '2023-11-16 12:18:27', b'0');
  2452 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2489, '示例分类导出', 'infra:demo02-category:export', 3, 5, 2484, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:18:27', '', '2023-11-16 12:18:27', b'0');
  2453 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2490, '主子表(标准)', '', 2, 10, 1070, 'demo03-normal', 'fa:battery-3', 'infra/demo/demo03/normal/index', 'Demo03StudentNormal', 0, b'1', b'1', b'1', '', '2023-11-16 12:53:37', '1', '2023-11-16 23:10:03', b'0');
  2454 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2491, '学生查询', 'infra:demo03-student:query', 3, 1, 2490, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:53:37', '', '2023-11-16 12:53:37', b'0');
  2455 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2492, '学生创建', 'infra:demo03-student:create', 3, 2, 2490, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:53:37', '', '2023-11-16 12:53:37', b'0');
  2456 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2493, '学生更新', 'infra:demo03-student:update', 3, 3, 2490, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:53:37', '', '2023-11-16 12:53:37', b'0');
  2457 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2494, '学生删除', 'infra:demo03-student:delete', 3, 4, 2490, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:53:37', '', '2023-11-16 12:53:37', b'0');
  2458 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2495, '学生导出', 'infra:demo03-student:export', 3, 5, 2490, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-16 12:53:37', '', '2023-11-16 12:53:37', b'0');
  2459 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2497, '主子表(ERP)', '', 2, 11, 1070, 'demo03-erp', 'ep:calendar', 'infra/demo/demo03/erp/index', 'Demo03StudentERP', 0, b'1', b'1', b'1', '', '2023-11-16 15:50:59', '1', '2023-11-17 13:19:56', b'0');
2313 COMMIT; 2460 COMMIT;
2314 2461
2315 -- ---------------------------- 2462 -- ----------------------------
@@ -2336,7 +2483,7 @@ CREATE TABLE `system_notice` ( @@ -2336,7 +2483,7 @@ CREATE TABLE `system_notice` (
2336 -- ---------------------------- 2483 -- ----------------------------
2337 BEGIN; 2484 BEGIN;
2338 INSERT INTO `system_notice` (`id`, `title`, `content`, `type`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, '芋道的公众', '<p>新版本内容133</p>', 1, 0, 'admin', '2021-01-05 17:03:48', '1', '2022-05-04 21:00:20', b'0', 1); 2485 INSERT INTO `system_notice` (`id`, `title`, `content`, `type`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, '芋道的公众', '<p>新版本内容133</p>', 1, 0, 'admin', '2021-01-05 17:03:48', '1', '2022-05-04 21:00:20', b'0', 1);
2339 -INSERT INTO `system_notice` (`id`, `title`, `content`, `type`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, '维护通知:2018-07-01 若依系统凌晨维护', '<p><img src=\"http://test.yudao.iocoder.cn/b7cb3cf49b4b3258bf7309a09dd2f4e5.jpg\">维护内容</p>', 2, 1, 'admin', '2021-01-05 17:03:48', '1', '2022-05-11 12:34:24', b'0', 1); 2486 +INSERT INTO `system_notice` (`id`, `title`, `content`, `type`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, '维护通知:2018-07-01 若依系统凌晨维护', '<p><img src=\"http://test.yudao.iocoder.cn/b7cb3cf49b4b3258bf7309a09dd2f4e5.jpg\" alt=\"\" data-href=\"\" style=\"\"/>1111</p>', 2, 1, 'admin', '2021-01-05 17:03:48', '1', '2023-11-11 12:51:11', b'0', 1);
2340 INSERT INTO `system_notice` (`id`, `title`, `content`, `type`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, '我是测试标题', '<p>哈哈哈哈123</p>', 1, 0, '110', '2022-02-22 01:01:25', '110', '2022-02-22 01:01:46', b'0', 121); 2487 INSERT INTO `system_notice` (`id`, `title`, `content`, `type`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, '我是测试标题', '<p>哈哈哈哈123</p>', 1, 0, '110', '2022-02-22 01:01:25', '110', '2022-02-22 01:01:46', b'0', 121);
2341 COMMIT; 2488 COMMIT;
2342 2489
@@ -2430,7 +2577,7 @@ CREATE TABLE `system_oauth2_access_token` ( @@ -2430,7 +2577,7 @@ CREATE TABLE `system_oauth2_access_token` (
2430 PRIMARY KEY (`id`) USING BTREE, 2577 PRIMARY KEY (`id`) USING BTREE,
2431 INDEX `idx_access_token`(`access_token` ASC) USING BTREE, 2578 INDEX `idx_access_token`(`access_token` ASC) USING BTREE,
2432 INDEX `idx_refresh_token`(`refresh_token` ASC) USING BTREE 2579 INDEX `idx_refresh_token`(`refresh_token` ASC) USING BTREE
2433 -) ENGINE = InnoDB AUTO_INCREMENT = 3152 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌'; 2580 +) ENGINE = InnoDB AUTO_INCREMENT = 3467 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌';
2434 2581
2435 -- ---------------------------- 2582 -- ----------------------------
2436 -- Records of system_oauth2_access_token 2583 -- Records of system_oauth2_access_token
@@ -2552,7 +2699,7 @@ CREATE TABLE `system_oauth2_refresh_token` ( @@ -2552,7 +2699,7 @@ CREATE TABLE `system_oauth2_refresh_token` (
2552 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 2699 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
2553 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 2700 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
2554 PRIMARY KEY (`id`) USING BTREE 2701 PRIMARY KEY (`id`) USING BTREE
2555 -) ENGINE = InnoDB AUTO_INCREMENT = 1099 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 刷新令牌'; 2702 +) ENGINE = InnoDB AUTO_INCREMENT = 1115 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 刷新令牌';
2556 2703
2557 -- ---------------------------- 2704 -- ----------------------------
2558 -- Records of system_oauth2_refresh_token 2705 -- Records of system_oauth2_refresh_token
@@ -2592,7 +2739,7 @@ CREATE TABLE `system_operate_log` ( @@ -2592,7 +2739,7 @@ CREATE TABLE `system_operate_log` (
2592 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 2739 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
2593 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 2740 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
2594 PRIMARY KEY (`id`) USING BTREE 2741 PRIMARY KEY (`id`) USING BTREE
2595 -) ENGINE = InnoDB AUTO_INCREMENT = 8845 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录'; 2742 +) ENGINE = InnoDB AUTO_INCREMENT = 9090 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录';
2596 2743
2597 -- ---------------------------- 2744 -- ----------------------------
2598 -- Records of system_operate_log 2745 -- Records of system_operate_log
@@ -2618,15 +2765,15 @@ CREATE TABLE `system_post` ( @@ -2618,15 +2765,15 @@ CREATE TABLE `system_post` (
2618 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 2765 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
2619 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 2766 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
2620 PRIMARY KEY (`id`) USING BTREE 2767 PRIMARY KEY (`id`) USING BTREE
2621 -) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '岗位信息表'; 2768 +) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '岗位信息表';
2622 2769
2623 -- ---------------------------- 2770 -- ----------------------------
2624 -- Records of system_post 2771 -- Records of system_post
2625 -- ---------------------------- 2772 -- ----------------------------
2626 BEGIN; 2773 BEGIN;
2627 INSERT INTO `system_post` (`id`, `code`, `name`, `sort`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'ceo', '董事长', 1, 0, '', 'admin', '2021-01-06 17:03:48', '1', '2023-02-11 15:19:04', b'0', 1); 2774 INSERT INTO `system_post` (`id`, `code`, `name`, `sort`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'ceo', '董事长', 1, 0, '', 'admin', '2021-01-06 17:03:48', '1', '2023-02-11 15:19:04', b'0', 1);
2628 -INSERT INTO `system_post` (`id`, `code`, `name`, `sort`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, 'se', '项目经理', 2, 0, '', 'admin', '2021-01-05 17:03:48', '1', '2021-12-12 10:47:47', b'0', 1);  
2629 -INSERT INTO `system_post` (`id`, `code`, `name`, `sort`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, 'user', '普通员工', 4, 0, '111', 'admin', '2021-01-05 17:03:48', '1', '2023-02-11 15:19:00', b'0', 1); 2775 +INSERT INTO `system_post` (`id`, `code`, `name`, `sort`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, 'se', '项目经理', 2, 0, '', 'admin', '2021-01-05 17:03:48', '1', '2023-11-15 09:18:20', b'0', 1);
  2776 +INSERT INTO `system_post` (`id`, `code`, `name`, `sort`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, 'user', '普通员工', 4, 0, '111', 'admin', '2021-01-05 17:03:48', '1', '2023-11-15 09:18:18', b'0', 1);
2630 COMMIT; 2777 COMMIT;
2631 2778
2632 -- ---------------------------- 2779 -- ----------------------------
@@ -2819,10 +2966,6 @@ INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_t @@ -2819,10 +2966,6 @@ INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_t
2819 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1657, 101, 1066, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1); 2966 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1657, 101, 1066, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);
2820 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1658, 101, 1067, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1); 2967 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1658, 101, 1067, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);
2821 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1659, 101, 1070, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1); 2968 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1659, 101, 1070, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);
2822 -INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1660, 101, 1071, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);  
2823 -INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1661, 101, 1072, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);  
2824 -INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1662, 101, 1073, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);  
2825 -INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1663, 101, 1074, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);  
2826 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1664, 101, 1075, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1); 2969 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1664, 101, 1075, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);
2827 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1665, 101, 1076, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1); 2970 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1665, 101, 1076, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);
2828 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1666, 101, 1077, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1); 2971 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1666, 101, 1077, '1', '2022-04-01 22:21:37', '1', '2022-04-01 22:21:37', b'0', 1);
@@ -3140,10 +3283,6 @@ INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_t @@ -3140,10 +3283,6 @@ INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_t
3140 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2027, 2, 1066, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1); 3283 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2027, 2, 1066, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);
3141 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2028, 2, 1067, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1); 3284 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2028, 2, 1067, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);
3142 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2029, 2, 1070, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1); 3285 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2029, 2, 1070, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);
3143 -INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2030, 2, 1071, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);  
3144 -INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2031, 2, 1072, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);  
3145 -INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2032, 2, 1073, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);  
3146 -INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2033, 2, 1074, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);  
3147 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2034, 2, 1075, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1); 3286 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2034, 2, 1075, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);
3148 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2035, 2, 1076, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1); 3287 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2035, 2, 1076, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);
3149 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2036, 2, 1082, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1); 3288 INSERT INTO `system_role_menu` (`id`, `role_id`, `menu_id`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2036, 2, 1082, '1', '2023-01-25 08:42:52', '1', '2023-01-25 08:42:52', b'0', 1);
@@ -3643,7 +3782,7 @@ CREATE TABLE `system_sms_log` ( @@ -3643,7 +3782,7 @@ CREATE TABLE `system_sms_log` (
3643 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 3782 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
3644 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 3783 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
3645 PRIMARY KEY (`id`) USING BTREE 3784 PRIMARY KEY (`id`) USING BTREE
3646 -) ENGINE = InnoDB AUTO_INCREMENT = 503 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '短信日志'; 3785 +) ENGINE = InnoDB AUTO_INCREMENT = 502 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '短信日志';
3647 3786
3648 -- ---------------------------- 3787 -- ----------------------------
3649 -- Records of system_sms_log 3788 -- Records of system_sms_log
@@ -3673,7 +3812,7 @@ CREATE TABLE `system_sms_template` ( @@ -3673,7 +3812,7 @@ CREATE TABLE `system_sms_template` (
3673 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 3812 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
3674 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 3813 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
3675 PRIMARY KEY (`id`) USING BTREE 3814 PRIMARY KEY (`id`) USING BTREE
3676 -) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '短信模板'; 3815 +) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '短信模板';
3677 3816
3678 -- ---------------------------- 3817 -- ----------------------------
3679 -- Records of system_sms_template 3818 -- Records of system_sms_template
@@ -3803,9 +3942,9 @@ CREATE TABLE `system_tenant` ( @@ -3803,9 +3942,9 @@ CREATE TABLE `system_tenant` (
3803 -- Records of system_tenant 3942 -- Records of system_tenant
3804 -- ---------------------------- 3943 -- ----------------------------
3805 BEGIN; 3944 BEGIN;
3806 -INSERT INTO `system_tenant` (`id`, `name`, `contact_user_id`, `contact_name`, `contact_mobile`, `status`, `website`, `package_id`, `expire_time`, `account_count`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '芋道源码', NULL, '芋艿', '17321315478', 0, 'https://www.iocoder.cn', 0, '2099-02-19 17:14:16', 9999, '1', '2021-01-05 17:03:47', '1', '2022-02-23 12:15:11', b'0');  
3807 -INSERT INTO `system_tenant` (`id`, `name`, `contact_user_id`, `contact_name`, `contact_mobile`, `status`, `website`, `package_id`, `expire_time`, `account_count`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (121, '小租户', 110, '小王2', '15601691300', 0, 'http://www.iocoder.cn', 111, '2024-03-11 00:00:00', 20, '1', '2022-02-22 00:56:14', '1', '2023-09-16 16:59:42', b'0');  
3808 -INSERT INTO `system_tenant` (`id`, `name`, `contact_user_id`, `contact_name`, `contact_mobile`, `status`, `website`, `package_id`, `expire_time`, `account_count`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (122, '测试租户', 113, '芋道', '15601691300', 0, 'https://www.iocoder.cn', 111, '2022-04-30 00:00:00', 50, '1', '2022-03-07 21:37:58', '1', '2023-09-16 16:59:27', b'0'); 3945 +INSERT INTO `system_tenant` (`id`, `name`, `contact_user_id`, `contact_name`, `contact_mobile`, `status`, `website`, `package_id`, `expire_time`, `account_count`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '芋道源码', NULL, '芋艿', '17321315478', 0, 'www.iocoder.cn', 0, '2099-02-19 17:14:16', 9999, '1', '2021-01-05 17:03:47', '1', '2023-11-06 11:41:41', b'0');
  3946 +INSERT INTO `system_tenant` (`id`, `name`, `contact_user_id`, `contact_name`, `contact_mobile`, `status`, `website`, `package_id`, `expire_time`, `account_count`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (121, '小租户', 110, '小王2', '15601691300', 0, 'zsxq.iocoder.cn', 111, '2024-03-11 00:00:00', 20, '1', '2022-02-22 00:56:14', '1', '2023-11-06 11:41:47', b'0');
  3947 +INSERT INTO `system_tenant` (`id`, `name`, `contact_user_id`, `contact_name`, `contact_mobile`, `status`, `website`, `package_id`, `expire_time`, `account_count`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (122, '测试租户', 113, '芋道', '15601691300', 0, 'test.iocoder.cn', 111, '2022-04-30 00:00:00', 50, '1', '2022-03-07 21:37:58', '1', '2023-11-06 11:41:53', b'0');
3809 COMMIT; 3948 COMMIT;
3810 3949
3811 -- ---------------------------- 3950 -- ----------------------------
@@ -3944,7 +4083,7 @@ CREATE TABLE `system_users` ( @@ -3944,7 +4083,7 @@ CREATE TABLE `system_users` (
3944 -- Records of system_users 4083 -- Records of system_users
3945 -- ---------------------------- 4084 -- ----------------------------
3946 BEGIN; 4085 BEGIN;
3947 -INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$mRMIYLDtRHlf6.9ipiqH1.Z.bh/R9dO9d5iHiGYPigi6r5KOoR2Wm', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://127.0.0.1:48080/admin-api/infra/file/4/get/37e56010ecbee472cdd821ac4b608e151e62a74d9633f15d085aee026eedeb60.png', 0, '0:0:0:0:0:0:0:1', '2023-11-04 10:33:16', 'admin', '2021-01-05 17:03:47', NULL, '2023-11-04 10:33:16', b'0', 1); 4086 +INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$mRMIYLDtRHlf6.9ipiqH1.Z.bh/R9dO9d5iHiGYPigi6r5KOoR2Wm', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://127.0.0.1:48080/admin-api/infra/file/4/get/37e56010ecbee472cdd821ac4b608e151e62a74d9633f15d085aee026eedeb60.png', 0, '0:0:0:0:0:0:0:1', '2023-11-18 17:19:30', 'admin', '2021-01-05 17:03:47', NULL, '2023-11-18 17:19:30', b'0', 1);
3948 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, 'yudao', '$2a$10$11U48RhyJ5pSBYWSn12AD./ld671.ycSzJHbyrtpeoMeYiw31eo8a', '芋道', '不要吓我', 104, '[1]', 'yudao@iocoder.cn', '15601691300', 1, '', 1, '127.0.0.1', '2022-07-09 23:03:33', '', '2021-01-07 09:07:17', NULL, '2022-07-09 23:03:33', b'0', 1); 4087 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, 'yudao', '$2a$10$11U48RhyJ5pSBYWSn12AD./ld671.ycSzJHbyrtpeoMeYiw31eo8a', '芋道', '不要吓我', 104, '[1]', 'yudao@iocoder.cn', '15601691300', 1, '', 1, '127.0.0.1', '2022-07-09 23:03:33', '', '2021-01-07 09:07:17', NULL, '2022-07-09 23:03:33', b'0', 1);
3949 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, 'yuanma', '$2a$10$YMpimV4T6BtDhIaA8jSW.u8UTGBeGhc/qwXP4oxoMr4mOw9.qttt6', '源码', NULL, 106, NULL, 'yuanma@iocoder.cn', '15601701300', 0, '', 0, '127.0.0.1', '2022-07-08 01:26:27', '', '2021-01-13 23:50:35', NULL, '2022-07-08 01:26:27', b'0', 1); 4088 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, 'yuanma', '$2a$10$YMpimV4T6BtDhIaA8jSW.u8UTGBeGhc/qwXP4oxoMr4mOw9.qttt6', '源码', NULL, 106, NULL, 'yuanma@iocoder.cn', '15601701300', 0, '', 0, '127.0.0.1', '2022-07-08 01:26:27', '', '2021-01-13 23:50:35', NULL, '2022-07-08 01:26:27', b'0', 1);
3950 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (104, 'test', '$2a$10$GP8zvqHB//TekuzYZSBYAuBQJiNq1.fxQVDYJ.uBCOnWCtDVKE4H6', '测试号', NULL, 107, '[1,2]', '111@qq.com', '15601691200', 1, '', 0, '0:0:0:0:0:0:0:1', '2023-09-24 18:21:19', '', '2021-01-21 02:13:53', NULL, '2023-09-24 18:21:19', b'0', 1); 4089 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (104, 'test', '$2a$10$GP8zvqHB//TekuzYZSBYAuBQJiNq1.fxQVDYJ.uBCOnWCtDVKE4H6', '测试号', NULL, 107, '[1,2]', '111@qq.com', '15601691200', 1, '', 0, '0:0:0:0:0:0:0:1', '2023-09-24 18:21:19', '', '2021-01-21 02:13:53', NULL, '2023-09-24 18:21:19', b'0', 1);
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/pojo/PageParam.java
@@ -15,6 +15,13 @@ public class PageParam implements Serializable { @@ -15,6 +15,13 @@ public class PageParam implements Serializable {
15 private static final Integer PAGE_NO = 1; 15 private static final Integer PAGE_NO = 1;
16 private static final Integer PAGE_SIZE = 10; 16 private static final Integer PAGE_SIZE = 10;
17 17
  18 + /**
  19 + * 每页条数 - 不分页
  20 + *
  21 + * 例如说,导出接口,可以设置 {@link #pageSize} 为 -1 不分页,查询所有数据。
  22 + */
  23 + public static final Integer PAGE_SIZE_NONE = -1;
  24 +
18 @Schema(description = "页码,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1") 25 @Schema(description = "页码,从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1")
19 @NotNull(message = "页码不能为空") 26 @NotNull(message = "页码不能为空")
20 @Min(value = 1, message = "页码最小值为 1") 27 @Min(value = 1, message = "页码最小值为 1")
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java
@@ -238,7 +238,7 @@ public class CollectionUtils { @@ -238,7 +238,7 @@ public class CollectionUtils {
238 if (CollUtil.isEmpty(from)) { 238 if (CollUtil.isEmpty(from)) {
239 return null; 239 return null;
240 } 240 }
241 - assert from.size() > 0; // 断言,避免告警 241 + assert !from.isEmpty(); // 断言,避免告警
242 T t = from.stream().max(Comparator.comparing(valueFunc)).get(); 242 T t = from.stream().max(Comparator.comparing(valueFunc)).get();
243 return valueFunc.apply(t); 243 return valueFunc.apply(t);
244 } 244 }
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.common.util.json; @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.common.util.json;
3 import cn.hutool.core.util.ArrayUtil; 3 import cn.hutool.core.util.ArrayUtil;
4 import cn.hutool.core.util.StrUtil; 4 import cn.hutool.core.util.StrUtil;
5 import cn.hutool.json.JSONUtil; 5 import cn.hutool.json.JSONUtil;
  6 +import com.fasterxml.jackson.annotation.JsonInclude;
6 import com.fasterxml.jackson.core.type.TypeReference; 7 import com.fasterxml.jackson.core.type.TypeReference;
7 import com.fasterxml.jackson.databind.DeserializationFeature; 8 import com.fasterxml.jackson.databind.DeserializationFeature;
8 import com.fasterxml.jackson.databind.JsonNode; 9 import com.fasterxml.jackson.databind.JsonNode;
@@ -30,6 +31,7 @@ public class JsonUtils { @@ -30,6 +31,7 @@ public class JsonUtils {
30 static { 31 static {
31 objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); 32 objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
32 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 33 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  34 + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // 忽略 null 值
33 objectMapper.registerModules(new JavaTimeModule()); // 解决 LocalDateTime 的序列化 35 objectMapper.registerModules(new JavaTimeModule()); // 解决 LocalDateTime 的序列化
34 } 36 }
35 37
@@ -71,6 +73,20 @@ public class JsonUtils { @@ -71,6 +73,20 @@ public class JsonUtils {
71 } 73 }
72 } 74 }
73 75
  76 + public static <T> T parseObject(String text, String path, Class<T> clazz) {
  77 + if (StrUtil.isEmpty(text)) {
  78 + return null;
  79 + }
  80 + try {
  81 + JsonNode treeNode = objectMapper.readTree(text);
  82 + JsonNode pathNode = treeNode.path(path);
  83 + return objectMapper.readValue(pathNode.toString(), clazz);
  84 + } catch (IOException e) {
  85 + log.error("json parse err,json:{}", text, e);
  86 + throw new RuntimeException(e);
  87 + }
  88 + }
  89 +
74 public static <T> T parseObject(String text, Type type) { 90 public static <T> T parseObject(String text, Type type) {
75 if (StrUtil.isEmpty(text)) { 91 if (StrUtil.isEmpty(text)) {
76 return null; 92 return null;
@@ -132,6 +148,20 @@ public class JsonUtils { @@ -132,6 +148,20 @@ public class JsonUtils {
132 } 148 }
133 } 149 }
134 150
  151 + public static <T> List<T> parseArray(String text, String path, Class<T> clazz) {
  152 + if (StrUtil.isEmpty(text)) {
  153 + return null;
  154 + }
  155 + try {
  156 + JsonNode treeNode = objectMapper.readTree(text);
  157 + JsonNode pathNode = treeNode.path(path);
  158 + return objectMapper.readValue(pathNode.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
  159 + } catch (IOException e) {
  160 + log.error("json parse err,json:{}", text, e);
  161 + throw new RuntimeException(e);
  162 + }
  163 + }
  164 +
135 public static JsonNode parseTree(String text) { 165 public static JsonNode parseTree(String text) {
136 try { 166 try {
137 return objectMapper.readTree(text); 167 return objectMapper.readTree(text);
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/object/BeanUtils.java 0 → 100644
  1 +package cn.iocoder.yudao.framework.common.util.object;
  2 +
  3 +import cn.hutool.core.bean.BeanUtil;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
  6 +
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * Bean 工具类
  11 + *
  12 + * 1. 默认使用 {@link cn.hutool.core.bean.BeanUtil} 作为实现类,虽然不同 bean 工具的性能有差别,但是对绝大多数同学的项目,不用在意这点性能
  13 + * 2. 针对复杂的对象转换,可以搜参考 AuthConvert 实现,通过 mapstruct + default 配合实现
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +public class BeanUtils {
  18 +
  19 + public static <T> T toBean(Object source, Class<T> targetClass) {
  20 + return BeanUtil.toBean(source, targetClass);
  21 + }
  22 +
  23 + public static <S, T> List<T> toBean(List<S> source, Class<T> targetType) {
  24 + if (source == null) {
  25 + return null;
  26 + }
  27 + return CollectionUtils.convertList(source, s -> toBean(s, targetType));
  28 + }
  29 +
  30 + public static <S, T> PageResult<T> toBean(PageResult<S> source, Class<T> targetType) {
  31 + if (source == null) {
  32 + return null;
  33 + }
  34 + return new PageResult<>(toBean(source.getList(), targetType), source.getTotal());
  35 + }
  36 +
  37 +}
0 \ No newline at end of file 38 \ No newline at end of file
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/string/StrUtils.java
@@ -50,4 +50,20 @@ public class StrUtils { @@ -50,4 +50,20 @@ public class StrUtils {
50 return Arrays.stream(integers).boxed().collect(Collectors.toList()); 50 return Arrays.stream(integers).boxed().collect(Collectors.toList());
51 } 51 }
52 52
  53 + /**
  54 + * 移除字符串中,包含指定字符串的行
  55 + *
  56 + * @param content 字符串
  57 + * @param sequence 包含的字符串
  58 + * @return 移除后的字符串
  59 + */
  60 + public static String removeLineContains(String content, String sequence) {
  61 + if (StrUtil.isEmpty(content) || StrUtil.isEmpty(sequence)) {
  62 + return content;
  63 + }
  64 + return Arrays.stream(content.split("\n"))
  65 + .filter(line -> !line.contains(sequence))
  66 + .collect(Collectors.joining("\n"));
  67 + }
  68 +
53 } 69 }
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
@@ -26,6 +26,12 @@ import java.util.List; @@ -26,6 +26,12 @@ import java.util.List;
26 public interface BaseMapperX<T> extends MPJBaseMapper<T> { 26 public interface BaseMapperX<T> extends MPJBaseMapper<T> {
27 27
28 default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) { 28 default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) {
  29 + // 特殊:不分页,直接查询全部
  30 + if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageNo())) {
  31 + List<T> list = selectList(queryWrapper);
  32 + return new PageResult<>(list, (long) list.size());
  33 + }
  34 +
29 // MyBatis Plus 查询 35 // MyBatis Plus 查询
30 IPage<T> mpPage = MyBatisUtils.buildPage(pageParam); 36 IPage<T> mpPage = MyBatisUtils.buildPage(pageParam);
31 selectPage(mpPage, queryWrapper); 37 selectPage(mpPage, queryWrapper);
@@ -93,10 +99,15 @@ public interface BaseMapperX&lt;T&gt; extends MPJBaseMapper&lt;T&gt; { @@ -93,10 +99,15 @@ public interface BaseMapperX&lt;T&gt; extends MPJBaseMapper&lt;T&gt; {
93 return selectList(new LambdaQueryWrapper<T>().in(field, values)); 99 return selectList(new LambdaQueryWrapper<T>().in(field, values));
94 } 100 }
95 101
  102 + @Deprecated
96 default List<T> selectList(SFunction<T, ?> leField, SFunction<T, ?> geField, Object value) { 103 default List<T> selectList(SFunction<T, ?> leField, SFunction<T, ?> geField, Object value) {
97 return selectList(new LambdaQueryWrapper<T>().le(leField, value).ge(geField, value)); 104 return selectList(new LambdaQueryWrapper<T>().le(leField, value).ge(geField, value));
98 } 105 }
99 106
  107 + default List<T> selectList(SFunction<T, ?> field1, Object value1, SFunction<T, ?> field2, Object value2) {
  108 + return selectList(new LambdaQueryWrapper<T>().eq(field1, value1).eq(field2, value2));
  109 + }
  110 +
100 /** 111 /**
101 * 批量插入,适合大量数据插入 112 * 批量插入,适合大量数据插入
102 * 113 *
@@ -128,8 +139,20 @@ public interface BaseMapperX&lt;T&gt; extends MPJBaseMapper&lt;T&gt; { @@ -128,8 +139,20 @@ public interface BaseMapperX&lt;T&gt; extends MPJBaseMapper&lt;T&gt; {
128 Db.updateBatchById(entities, size); 139 Db.updateBatchById(entities, size);
129 } 140 }
130 141
131 - default void saveOrUpdateBatch(Collection<T> collection) { 142 + default void insertOrUpdate(T entity) {
  143 + Db.saveOrUpdate(entity);
  144 + }
  145 +
  146 + default void insertOrUpdateBatch(Collection<T> collection) {
132 Db.saveOrUpdateBatch(collection); 147 Db.saveOrUpdateBatch(collection);
133 } 148 }
134 149
  150 + default int delete(String field, String value) {
  151 + return delete(new QueryWrapper<T>().eq(field, value));
  152 + }
  153 +
  154 + default int delete(SFunction<T, ?> field, Object value) {
  155 + return delete(new LambdaQueryWrapper<T>().eq(field, value));
  156 + }
  157 +
135 } 158 }
yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java
@@ -42,9 +42,10 @@ public interface ErrorCodeConstants { @@ -42,9 +42,10 @@ public interface ErrorCodeConstants {
42 ErrorCode CODEGEN_SYNC_NONE_CHANGE = new ErrorCode(1_003_001_007, "同步失败,不存在改变"); 42 ErrorCode CODEGEN_SYNC_NONE_CHANGE = new ErrorCode(1_003_001_007, "同步失败,不存在改变");
43 ErrorCode CODEGEN_TABLE_INFO_TABLE_COMMENT_IS_NULL = new ErrorCode(1_003_001_008, "数据库的表注释未填写"); 43 ErrorCode CODEGEN_TABLE_INFO_TABLE_COMMENT_IS_NULL = new ErrorCode(1_003_001_008, "数据库的表注释未填写");
44 ErrorCode CODEGEN_TABLE_INFO_COLUMN_COMMENT_IS_NULL = new ErrorCode(1_003_001_009, "数据库的表字段({})注释未填写"); 44 ErrorCode CODEGEN_TABLE_INFO_COLUMN_COMMENT_IS_NULL = new ErrorCode(1_003_001_009, "数据库的表字段({})注释未填写");
45 -  
46 - // ========== 字典类型(测试)1-001-005-000 ==========  
47 - ErrorCode TEST_DEMO_NOT_EXISTS = new ErrorCode(1_001_005_000, "测试示例不存在"); 45 + ErrorCode CODEGEN_MASTER_TABLE_NOT_EXISTS = new ErrorCode(1_003_001_010, "主表(id={})定义不存在,请检查");
  46 + ErrorCode CODEGEN_SUB_COLUMN_NOT_EXISTS = new ErrorCode(1_003_001_011, "子表的字段(id={})不存在,请检查");
  47 + ErrorCode CODEGEN_MASTER_GENERATION_FAIL_NO_SUB_TABLE = new ErrorCode(1_003_001_012, "主表生成代码失败,原因:它没有子表");
  48 + ErrorCode CODEGEN_MASTER_GENERATION_FAIL_NO_SUB_COLUMN = new ErrorCode(1_003_001_013, "主表生成代码失败,原因:它的子表({})没有字段");
48 49
49 // ========== 文件配置 1-001-006-000 ========== 50 // ========== 文件配置 1-001-006-000 ==========
50 ErrorCode FILE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_006_000, "文件配置不存在"); 51 ErrorCode FILE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_006_000, "文件配置不存在");
@@ -54,4 +55,19 @@ public interface ErrorCodeConstants { @@ -54,4 +55,19 @@ public interface ErrorCodeConstants {
54 ErrorCode DATA_SOURCE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_007_000, "数据源配置不存在"); 55 ErrorCode DATA_SOURCE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_007_000, "数据源配置不存在");
55 ErrorCode DATA_SOURCE_CONFIG_NOT_OK = new ErrorCode(1_001_007_001, "数据源配置不正确,无法进行连接"); 56 ErrorCode DATA_SOURCE_CONFIG_NOT_OK = new ErrorCode(1_001_007_001, "数据源配置不正确,无法进行连接");
56 57
  58 + // ========== 数据源配置 1-001-107-000 ==========
  59 + ErrorCode DEMO_STUDENT_NOT_EXISTS = new ErrorCode(1_001_107_000, "学生不存在");
  60 +
  61 + // ========== 学生 1-001-201-000 ==========
  62 + ErrorCode DEMO01_CONTACT_NOT_EXISTS = new ErrorCode(1_001_201_000, "示例联系人不存在");
  63 + ErrorCode DEMO02_CATEGORY_NOT_EXISTS = new ErrorCode(1_001_201_001, "示例分类不存在");
  64 + ErrorCode DEMO02_CATEGORY_EXITS_CHILDREN = new ErrorCode(1_001_201_002, "存在存在子示例分类,无法删除");
  65 + ErrorCode DEMO02_CATEGORY_PARENT_NOT_EXITS = new ErrorCode(1_001_201_003,"父级示例分类不存在");
  66 + ErrorCode DEMO02_CATEGORY_PARENT_ERROR = new ErrorCode(1_001_201_004, "不能设置自己为父示例分类");
  67 + ErrorCode DEMO02_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_001_201_005, "已经存在该名字的示例分类");
  68 + ErrorCode DEMO02_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_001_201_006, "不能设置自己的子示例分类为父示例分类");
  69 + ErrorCode DEMO03_STUDENT_NOT_EXISTS = new ErrorCode(1_001_201_007, "学生不存在");
  70 + ErrorCode DEMO03_GRADE_NOT_EXISTS = new ErrorCode(1_001_201_008, "学生班级不存在");
  71 + ErrorCode DEMO03_GRADE_EXISTS = new ErrorCode(1_001_201_009, "学生班级已存在");
  72 +
57 } 73 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/CodegenController.java
@@ -60,10 +60,19 @@ public class CodegenController { @@ -60,10 +60,19 @@ public class CodegenController {
60 return success(codegenService.getDatabaseTableList(dataSourceConfigId, name, comment)); 60 return success(codegenService.getDatabaseTableList(dataSourceConfigId, name, comment));
61 } 61 }
62 62
  63 + @GetMapping("/table/list")
  64 + @Operation(summary = "获得表定义列表")
  65 + @Parameter(name = "dataSourceConfigId", description = "数据源配置的编号", required = true, example = "1")
  66 + @PreAuthorize("@ss.hasPermission('infra:codegen:query')")
  67 + public CommonResult<List<CodegenTableRespVO>> getCodegenTableList(@RequestParam(value = "dataSourceConfigId") Long dataSourceConfigId) {
  68 + List<CodegenTableDO> list = codegenService.getCodegenTableList(dataSourceConfigId);
  69 + return success(CodegenConvert.INSTANCE.convertList05(list));
  70 + }
  71 +
63 @GetMapping("/table/page") 72 @GetMapping("/table/page")
64 @Operation(summary = "获得表定义分页") 73 @Operation(summary = "获得表定义分页")
65 @PreAuthorize("@ss.hasPermission('infra:codegen:query')") 74 @PreAuthorize("@ss.hasPermission('infra:codegen:query')")
66 - public CommonResult<PageResult<CodegenTableRespVO>> getCodeGenTablePage(@Valid CodegenTablePageReqVO pageReqVO) { 75 + public CommonResult<PageResult<CodegenTableRespVO>> getCodegenTablePage(@Valid CodegenTablePageReqVO pageReqVO) {
67 PageResult<CodegenTableDO> pageResult = codegenService.getCodegenTablePage(pageReqVO); 76 PageResult<CodegenTableDO> pageResult = codegenService.getCodegenTablePage(pageReqVO);
68 return success(CodegenConvert.INSTANCE.convertPage(pageResult)); 77 return success(CodegenConvert.INSTANCE.convertPage(pageResult));
69 } 78 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/CodegenUpdateReqVO.java
@@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil; @@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
4 import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.column.CodegenColumnBaseVO; 4 import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.column.CodegenColumnBaseVO;
5 import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.CodegenTableBaseVO; 5 import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.table.CodegenTableBaseVO;
6 import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum; 6 import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum;
  7 +import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum;
  8 +import com.fasterxml.jackson.annotation.JsonIgnore;
7 import io.swagger.v3.oas.annotations.media.Schema; 9 import io.swagger.v3.oas.annotations.media.Schema;
8 import lombok.Data; 10 import lombok.Data;
9 import lombok.EqualsAndHashCode; 11 import lombok.EqualsAndHashCode;
@@ -37,12 +39,27 @@ public class CodegenUpdateReqVO { @@ -37,12 +39,27 @@ public class CodegenUpdateReqVO {
37 private Long id; 39 private Long id;
38 40
39 @AssertTrue(message = "上级菜单不能为空,请前往 [修改生成配置 -> 生成信息] 界面,设置“上级菜单”字段") 41 @AssertTrue(message = "上级菜单不能为空,请前往 [修改生成配置 -> 生成信息] 界面,设置“上级菜单”字段")
  42 + @JsonIgnore
40 public boolean isParentMenuIdValid() { 43 public boolean isParentMenuIdValid() {
41 // 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的 44 // 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的
42 return ObjectUtil.notEqual(getScene(), CodegenSceneEnum.ADMIN.getScene()) 45 return ObjectUtil.notEqual(getScene(), CodegenSceneEnum.ADMIN.getScene())
43 || getParentMenuId() != null; 46 || getParentMenuId() != null;
44 } 47 }
45 48
  49 + @AssertTrue(message = "关联的父表信息不全")
  50 + @JsonIgnore
  51 + public boolean isSubValid() {
  52 + return ObjectUtil.notEqual(getTemplateType(), CodegenTemplateTypeEnum.SUB)
  53 + || (ObjectUtil.isAllNotEmpty(getMasterTableId(), getSubJoinColumnId(), getSubJoinMany()));
  54 + }
  55 +
  56 + @AssertTrue(message = "关联的树表信息不全")
  57 + @JsonIgnore
  58 + public boolean isTreeValid() {
  59 + return ObjectUtil.notEqual(getTemplateType(), CodegenTemplateTypeEnum.TREE)
  60 + || (ObjectUtil.isAllNotEmpty(getTreeParentColumnId(), getTreeNameColumnId()));
  61 + }
  62 +
46 } 63 }
47 64
48 @Schema(description = "更新表定义") 65 @Schema(description = "更新表定义")
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableBaseVO.java
@@ -58,4 +58,16 @@ public class CodegenTableBaseVO { @@ -58,4 +58,16 @@ public class CodegenTableBaseVO {
58 @Schema(description = "父菜单编号", example = "1024") 58 @Schema(description = "父菜单编号", example = "1024")
59 private Long parentMenuId; 59 private Long parentMenuId;
60 60
  61 + @Schema(description = "主表的编号", example = "2048")
  62 + private Long masterTableId;
  63 + @Schema(description = "子表关联主表的字段编号", example = "4096")
  64 + private Long subJoinColumnId;
  65 + @Schema(description = "主表与子表是否一对多", example = "4096")
  66 + private Boolean subJoinMany;
  67 +
  68 + @Schema(description = "树表的父字段编号", example = "8192")
  69 + private Long treeParentColumnId;
  70 + @Schema(description = "树表的名字字段编号", example = "16384")
  71 + private Long treeNameColumnId;
  72 +
61 } 73 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  7 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  8 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  9 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
  10 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactRespVO;
  11 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
  12 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
  13 +import cn.iocoder.yudao.module.infra.service.demo.demo01.Demo01ContactService;
  14 +import io.swagger.v3.oas.annotations.Operation;
  15 +import io.swagger.v3.oas.annotations.Parameter;
  16 +import io.swagger.v3.oas.annotations.tags.Tag;
  17 +import org.springframework.security.access.prepost.PreAuthorize;
  18 +import org.springframework.validation.annotation.Validated;
  19 +import org.springframework.web.bind.annotation.*;
  20 +
  21 +import javax.annotation.Resource;
  22 +import javax.servlet.http.HttpServletResponse;
  23 +import javax.validation.Valid;
  24 +import java.io.IOException;
  25 +import java.util.List;
  26 +
  27 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  28 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
  29 +
  30 +@Tag(name = "管理后台 - 示例联系人")
  31 +@RestController
  32 +@RequestMapping("/infra/demo01-contact")
  33 +@Validated
  34 +public class Demo01ContactController {
  35 +
  36 + @Resource
  37 + private Demo01ContactService demo01ContactService;
  38 +
  39 + @PostMapping("/create")
  40 + @Operation(summary = "创建示例联系人")
  41 + @PreAuthorize("@ss.hasPermission('infra:demo01-contact:create')")
  42 + public CommonResult<Long> createDemo01Contact(@Valid @RequestBody Demo01ContactSaveReqVO createReqVO) {
  43 + return success(demo01ContactService.createDemo01Contact(createReqVO));
  44 + }
  45 +
  46 + @PutMapping("/update")
  47 + @Operation(summary = "更新示例联系人")
  48 + @PreAuthorize("@ss.hasPermission('infra:demo01-contact:update')")
  49 + public CommonResult<Boolean> updateDemo01Contact(@Valid @RequestBody Demo01ContactSaveReqVO updateReqVO) {
  50 + demo01ContactService.updateDemo01Contact(updateReqVO);
  51 + return success(true);
  52 + }
  53 +
  54 + @DeleteMapping("/delete")
  55 + @Operation(summary = "删除示例联系人")
  56 + @Parameter(name = "id", description = "编号", required = true)
  57 + @PreAuthorize("@ss.hasPermission('infra:demo01-contact:delete')")
  58 + public CommonResult<Boolean> deleteDemo01Contact(@RequestParam("id") Long id) {
  59 + demo01ContactService.deleteDemo01Contact(id);
  60 + return success(true);
  61 + }
  62 +
  63 + @GetMapping("/get")
  64 + @Operation(summary = "获得示例联系人")
  65 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  66 + @PreAuthorize("@ss.hasPermission('infra:demo01-contact:query')")
  67 + public CommonResult<Demo01ContactRespVO> getDemo01Contact(@RequestParam("id") Long id) {
  68 + Demo01ContactDO demo01Contact = demo01ContactService.getDemo01Contact(id);
  69 + return success(BeanUtils.toBean(demo01Contact, Demo01ContactRespVO.class));
  70 + }
  71 +
  72 + @GetMapping("/page")
  73 + @Operation(summary = "获得示例联系人分页")
  74 + @PreAuthorize("@ss.hasPermission('infra:demo01-contact:query')")
  75 + public CommonResult<PageResult<Demo01ContactRespVO>> getDemo01ContactPage(@Valid Demo01ContactPageReqVO pageReqVO) {
  76 + PageResult<Demo01ContactDO> pageResult = demo01ContactService.getDemo01ContactPage(pageReqVO);
  77 + return success(BeanUtils.toBean(pageResult, Demo01ContactRespVO.class));
  78 + }
  79 +
  80 + @GetMapping("/export-excel")
  81 + @Operation(summary = "导出示例联系人 Excel")
  82 + @PreAuthorize("@ss.hasPermission('infra:demo01-contact:export')")
  83 + @OperateLog(type = EXPORT)
  84 + public void exportDemo01ContactExcel(@Valid Demo01ContactPageReqVO pageReqVO,
  85 + HttpServletResponse response) throws IOException {
  86 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  87 + List<Demo01ContactDO> list = demo01ContactService.getDemo01ContactPage(pageReqVO).getList();
  88 + // 导出 Excel
  89 + ExcelUtils.write(response, "示例联系人.xls", "数据", Demo01ContactRespVO.class,
  90 + BeanUtils.toBean(list, Demo01ContactRespVO.class));
  91 + }
  92 +
  93 +}
0 \ No newline at end of file 94 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoPageReqVO.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactPageReqVO.java 100755 → 100644
1 -package cn.iocoder.yudao.module.infra.controller.admin.test.vo;  
2 -import io.swagger.v3.oas.annotations.media.Schema;  
3 -import lombok.*; 1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
4 2
5 -import java.time.LocalDateTime; 3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
6 import cn.iocoder.yudao.framework.common.pojo.PageParam; 6 import cn.iocoder.yudao.framework.common.pojo.PageParam;
7 import org.springframework.format.annotation.DateTimeFormat; 7 import org.springframework.format.annotation.DateTimeFormat;
  8 +import java.time.LocalDateTime;
8 9
9 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 10 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
10 11
11 -@Schema(description = "管理后台 - 字典类型分页 Request VO") 12 +@Schema(description = "管理后台 - 示例联系人分页 Request VO")
12 @Data 13 @Data
13 @EqualsAndHashCode(callSuper = true) 14 @EqualsAndHashCode(callSuper = true)
14 @ToString(callSuper = true) 15 @ToString(callSuper = true)
15 -public class TestDemoPageReqVO extends PageParam { 16 +public class Demo01ContactPageReqVO extends PageParam {
16 17
17 - @Schema(description = "名字") 18 + @Schema(description = "名字", example = "张三")
18 private String name; 19 private String name;
19 20
20 - @Schema(description = "状态")  
21 - private Integer status; 21 + @Schema(description = "性别", example = "1")
  22 + private Integer sex;
22 23
23 - @Schema(description = "类型")  
24 - private Integer type;  
25 -  
26 - @Schema(description = "分类")  
27 - private Integer category;  
28 -  
29 - @Schema(description = "备注")  
30 - private String remark;  
31 -  
32 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
33 @Schema(description = "创建时间") 24 @Schema(description = "创建时间")
  25 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
34 private LocalDateTime[] createTime; 26 private LocalDateTime[] createTime;
35 27
36 -} 28 -}
  29 +}
37 \ No newline at end of file 30 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import java.util.*;
  7 +import org.springframework.format.annotation.DateTimeFormat;
  8 +import java.time.LocalDateTime;
  9 +import com.alibaba.excel.annotation.*;
  10 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  11 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  12 +
  13 +@Schema(description = "管理后台 - 示例联系人 Response VO")
  14 +@Data
  15 +@ExcelIgnoreUnannotated
  16 +public class Demo01ContactRespVO {
  17 +
  18 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21555")
  19 + @ExcelProperty("编号")
  20 + private Long id;
  21 +
  22 + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
  23 + @ExcelProperty("名字")
  24 + private String name;
  25 +
  26 + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  27 + @ExcelProperty(value = "性别", converter = DictConvert.class)
  28 + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
  29 + private Integer sex;
  30 +
  31 + @Schema(description = "出生年", requiredMode = Schema.RequiredMode.REQUIRED)
  32 + @ExcelProperty("出生年")
  33 + private LocalDateTime birthday;
  34 +
  35 + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
  36 + @ExcelProperty("简介")
  37 + private String description;
  38 +
  39 + @Schema(description = "头像")
  40 + @ExcelProperty("头像")
  41 + private String avatar;
  42 +
  43 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  44 + @ExcelProperty("创建时间")
  45 + private LocalDateTime createTime;
  46 +
  47 +}
0 \ No newline at end of file 48 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import javax.validation.constraints.NotEmpty;
  7 +import javax.validation.constraints.NotNull;
  8 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - 示例联系人新增/修改 Request VO")
  11 +@Data
  12 +public class Demo01ContactSaveReqVO {
  13 +
  14 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21555")
  15 + private Long id;
  16 +
  17 + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
  18 + @NotEmpty(message = "名字不能为空")
  19 + private String name;
  20 +
  21 + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  22 + @NotNull(message = "性别不能为空")
  23 + private Integer sex;
  24 +
  25 + @Schema(description = "出生年", requiredMode = Schema.RequiredMode.REQUIRED)
  26 + @NotNull(message = "出生年不能为空")
  27 + private LocalDateTime birthday;
  28 +
  29 + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
  30 + @NotEmpty(message = "简介不能为空")
  31 + private String description;
  32 +
  33 + @Schema(description = "头像")
  34 + private String avatar;
  35 +
  36 +}
0 \ No newline at end of file 37 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/Demo02CategoryController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  5 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  6 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  7 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
  8 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryRespVO;
  9 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
  10 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
  11 +import cn.iocoder.yudao.module.infra.service.demo.demo02.Demo02CategoryService;
  12 +import io.swagger.v3.oas.annotations.Operation;
  13 +import io.swagger.v3.oas.annotations.Parameter;
  14 +import io.swagger.v3.oas.annotations.tags.Tag;
  15 +import org.springframework.security.access.prepost.PreAuthorize;
  16 +import org.springframework.validation.annotation.Validated;
  17 +import org.springframework.web.bind.annotation.*;
  18 +
  19 +import javax.annotation.Resource;
  20 +import javax.servlet.http.HttpServletResponse;
  21 +import javax.validation.Valid;
  22 +import java.io.IOException;
  23 +import java.util.List;
  24 +
  25 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  26 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
  27 +
  28 +@Tag(name = "管理后台 - 示例分类")
  29 +@RestController
  30 +@RequestMapping("/infra/demo02-category")
  31 +@Validated
  32 +public class Demo02CategoryController {
  33 +
  34 + @Resource
  35 + private Demo02CategoryService demo02CategoryService;
  36 +
  37 + @PostMapping("/create")
  38 + @Operation(summary = "创建示例分类")
  39 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:create')")
  40 + public CommonResult<Long> createDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO createReqVO) {
  41 + return success(demo02CategoryService.createDemo02Category(createReqVO));
  42 + }
  43 +
  44 + @PutMapping("/update")
  45 + @Operation(summary = "更新示例分类")
  46 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:update')")
  47 + public CommonResult<Boolean> updateDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO updateReqVO) {
  48 + demo02CategoryService.updateDemo02Category(updateReqVO);
  49 + return success(true);
  50 + }
  51 +
  52 + @DeleteMapping("/delete")
  53 + @Operation(summary = "删除示例分类")
  54 + @Parameter(name = "id", description = "编号", required = true)
  55 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:delete')")
  56 + public CommonResult<Boolean> deleteDemo02Category(@RequestParam("id") Long id) {
  57 + demo02CategoryService.deleteDemo02Category(id);
  58 + return success(true);
  59 + }
  60 +
  61 + @GetMapping("/get")
  62 + @Operation(summary = "获得示例分类")
  63 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  64 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:query')")
  65 + public CommonResult<Demo02CategoryRespVO> getDemo02Category(@RequestParam("id") Long id) {
  66 + Demo02CategoryDO demo02Category = demo02CategoryService.getDemo02Category(id);
  67 + return success(BeanUtils.toBean(demo02Category, Demo02CategoryRespVO.class));
  68 + }
  69 +
  70 + @GetMapping("/list")
  71 + @Operation(summary = "获得示例分类列表")
  72 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:query')")
  73 + public CommonResult<List<Demo02CategoryRespVO>> getDemo02CategoryList(@Valid Demo02CategoryListReqVO listReqVO) {
  74 + List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
  75 + return success(BeanUtils.toBean(list, Demo02CategoryRespVO.class));
  76 + }
  77 +
  78 + @GetMapping("/export-excel")
  79 + @Operation(summary = "导出示例分类 Excel")
  80 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:export')")
  81 + @OperateLog(type = EXPORT)
  82 + public void exportDemo02CategoryExcel(@Valid Demo02CategoryListReqVO listReqVO,
  83 + HttpServletResponse response) throws IOException {
  84 + List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
  85 + // 导出 Excel
  86 + ExcelUtils.write(response, "示例分类.xls", "数据", Demo02CategoryRespVO.class,
  87 + BeanUtils.toBean(list, Demo02CategoryRespVO.class));
  88 + }
  89 +
  90 +}
0 \ No newline at end of file 91 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExportReqVO.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/vo/Demo02CategoryListReqVO.java 100755 → 100644
1 -package cn.iocoder.yudao.module.infra.controller.admin.test.vo; 1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo;
  2 +
2 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
3 -import lombok.*; 4 +import lombok.Data;
  5 +import org.springframework.format.annotation.DateTimeFormat;
4 6
5 import java.time.LocalDateTime; 7 import java.time.LocalDateTime;
6 -import org.springframework.format.annotation.DateTimeFormat;  
7 8
8 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 9 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
9 10
10 -@Schema(description = "管理后台 - 字典类型 Excel 导出 Request VO,参数和 TestDemoPageReqVO 是一致的") 11 +@Schema(description = "管理后台 - 示例分类列表 Request VO")
11 @Data 12 @Data
12 -public class TestDemoExportReqVO { 13 +public class Demo02CategoryListReqVO {
13 14
14 - @Schema(description = "名字") 15 + @Schema(description = "名字", example = "芋艿")
15 private String name; 16 private String name;
16 17
17 - @Schema(description = "状态")  
18 - private Integer status;  
19 -  
20 - @Schema(description = "类型")  
21 - private Integer type; 18 + @Schema(description = "父级编号", example = "6080")
  19 + private Long parentId;
22 20
23 - @Schema(description = "分类")  
24 - private Integer category;  
25 -  
26 - @Schema(description = "备注")  
27 - private String remark;  
28 -  
29 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
30 @Schema(description = "创建时间") 21 @Schema(description = "创建时间")
  22 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
31 private LocalDateTime[] createTime; 23 private LocalDateTime[] createTime;
32 24
33 -} 25 -}
  26 +}
34 \ No newline at end of file 27 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/vo/Demo02CategoryRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo;
  2 +
  3 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
  4 +import com.alibaba.excel.annotation.ExcelProperty;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import lombok.Data;
  7 +
  8 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - 示例分类 Response VO")
  11 +@Data
  12 +@ExcelIgnoreUnannotated
  13 +public class Demo02CategoryRespVO {
  14 +
  15 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10304")
  16 + @ExcelProperty("编号")
  17 + private Long id;
  18 +
  19 + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
  20 + @ExcelProperty("名字")
  21 + private String name;
  22 +
  23 + @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6080")
  24 + @ExcelProperty("父级编号")
  25 + private Long parentId;
  26 +
  27 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  28 + @ExcelProperty("创建时间")
  29 + private LocalDateTime createTime;
  30 +
  31 +}
0 \ No newline at end of file 32 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/vo/Demo02CategorySaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import javax.validation.constraints.NotEmpty;
  7 +import javax.validation.constraints.NotNull;
  8 +
  9 +@Schema(description = "管理后台 - 示例分类新增/修改 Request VO")
  10 +@Data
  11 +public class Demo02CategorySaveReqVO {
  12 +
  13 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10304")
  14 + private Long id;
  15 +
  16 + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
  17 + @NotEmpty(message = "名字不能为空")
  18 + private String name;
  19 +
  20 + @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6080")
  21 + @NotNull(message = "父级编号不能为空")
  22 + private Long parentId;
  23 +
  24 +}
0 \ No newline at end of file 25 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/Demo03StudentController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  7 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  8 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  9 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
  10 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentRespVO;
  11 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
  12 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
  13 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
  14 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
  15 +import cn.iocoder.yudao.module.infra.service.demo.demo03.Demo03StudentService;
  16 +import io.swagger.v3.oas.annotations.Operation;
  17 +import io.swagger.v3.oas.annotations.Parameter;
  18 +import io.swagger.v3.oas.annotations.tags.Tag;
  19 +import org.springframework.security.access.prepost.PreAuthorize;
  20 +import org.springframework.validation.annotation.Validated;
  21 +import org.springframework.web.bind.annotation.*;
  22 +
  23 +import javax.annotation.Resource;
  24 +import javax.servlet.http.HttpServletResponse;
  25 +import javax.validation.Valid;
  26 +import java.io.IOException;
  27 +import java.util.List;
  28 +
  29 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  30 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
  31 +
  32 +@Tag(name = "管理后台 - 学生")
  33 +@RestController
  34 +@RequestMapping("/infra/demo03-student")
  35 +@Validated
  36 +public class Demo03StudentController {
  37 +
  38 + @Resource
  39 + private Demo03StudentService demo03StudentService;
  40 +
  41 + @PostMapping("/create")
  42 + @Operation(summary = "创建学生")
  43 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
  44 + public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO createReqVO) {
  45 + return success(demo03StudentService.createDemo03Student(createReqVO));
  46 + }
  47 +
  48 + @PutMapping("/update")
  49 + @Operation(summary = "更新学生")
  50 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
  51 + public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentSaveReqVO updateReqVO) {
  52 + demo03StudentService.updateDemo03Student(updateReqVO);
  53 + return success(true);
  54 + }
  55 +
  56 + @DeleteMapping("/delete")
  57 + @Operation(summary = "删除学生")
  58 + @Parameter(name = "id", description = "编号", required = true)
  59 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
  60 + public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) {
  61 + demo03StudentService.deleteDemo03Student(id);
  62 + return success(true);
  63 + }
  64 +
  65 + @GetMapping("/get")
  66 + @Operation(summary = "获得学生")
  67 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  68 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
  69 + public CommonResult<Demo03StudentRespVO> getDemo03Student(@RequestParam("id") Long id) {
  70 + Demo03StudentDO demo03Student = demo03StudentService.getDemo03Student(id);
  71 + return success(BeanUtils.toBean(demo03Student, Demo03StudentRespVO.class));
  72 + }
  73 +
  74 + @GetMapping("/page")
  75 + @Operation(summary = "获得学生分页")
  76 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
  77 + public CommonResult<PageResult<Demo03StudentRespVO>> getDemo03StudentPage(@Valid Demo03StudentPageReqVO pageReqVO) {
  78 + PageResult<Demo03StudentDO> pageResult = demo03StudentService.getDemo03StudentPage(pageReqVO);
  79 + return success(BeanUtils.toBean(pageResult, Demo03StudentRespVO.class));
  80 + }
  81 +
  82 + @GetMapping("/export-excel")
  83 + @Operation(summary = "导出学生 Excel")
  84 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
  85 + @OperateLog(type = EXPORT)
  86 + public void exportDemo03StudentExcel(@Valid Demo03StudentPageReqVO pageReqVO,
  87 + HttpServletResponse response) throws IOException {
  88 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  89 + List<Demo03StudentDO> list = demo03StudentService.getDemo03StudentPage(pageReqVO).getList();
  90 + // 导出 Excel
  91 + ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentRespVO.class,
  92 + BeanUtils.toBean(list, Demo03StudentRespVO.class));
  93 + }
  94 +
  95 + // ==================== 子表(学生课程) ====================
  96 +
  97 + @GetMapping("/demo03-course/page")
  98 + @Operation(summary = "获得学生课程分页")
  99 + @Parameter(name = "studentId", description = "学生编号")
  100 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
  101 + public CommonResult<PageResult<Demo03CourseDO>> getDemo03CoursePage(PageParam pageReqVO,
  102 + @RequestParam("studentId") Long studentId) {
  103 + return success(demo03StudentService.getDemo03CoursePage(pageReqVO, studentId));
  104 + }
  105 +
  106 + @PostMapping("/demo03-course/create")
  107 + @Operation(summary = "创建学生课程")
  108 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
  109 + public CommonResult<Long> createDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) {
  110 + return success(demo03StudentService.createDemo03Course(demo03Course));
  111 + }
  112 +
  113 + @PutMapping("/demo03-course/update")
  114 + @Operation(summary = "更新学生课程")
  115 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
  116 + public CommonResult<Boolean> updateDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) {
  117 + demo03StudentService.updateDemo03Course(demo03Course);
  118 + return success(true);
  119 + }
  120 +
  121 + @DeleteMapping("/demo03-course/delete")
  122 + @Parameter(name = "id", description = "编号", required = true)
  123 + @Operation(summary = "删除学生课程")
  124 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
  125 + public CommonResult<Boolean> deleteDemo03Course(@RequestParam("id") Long id) {
  126 + demo03StudentService.deleteDemo03Course(id);
  127 + return success(true);
  128 + }
  129 +
  130 + @GetMapping("/demo03-course/get")
  131 + @Operation(summary = "获得学生课程")
  132 + @Parameter(name = "id", description = "编号", required = true)
  133 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
  134 + public CommonResult<Demo03CourseDO> getDemo03Course(@RequestParam("id") Long id) {
  135 + return success(demo03StudentService.getDemo03Course(id));
  136 + }
  137 +
  138 + @GetMapping("/demo03-course/list-by-student-id")
  139 + @Operation(summary = "获得学生课程列表")
  140 + @Parameter(name = "studentId", description = "学生编号")
  141 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
  142 + public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) {
  143 + return success(demo03StudentService.getDemo03CourseListByStudentId(studentId));
  144 + }
  145 +
  146 + // ==================== 子表(学生班级) ====================
  147 +
  148 + @GetMapping("/demo03-grade/page")
  149 + @Operation(summary = "获得学生班级分页")
  150 + @Parameter(name = "studentId", description = "学生编号")
  151 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
  152 + public CommonResult<PageResult<Demo03GradeDO>> getDemo03GradePage(PageParam pageReqVO,
  153 + @RequestParam("studentId") Long studentId) {
  154 + return success(demo03StudentService.getDemo03GradePage(pageReqVO, studentId));
  155 + }
  156 +
  157 + @PostMapping("/demo03-grade/create")
  158 + @Operation(summary = "创建学生班级")
  159 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
  160 + public CommonResult<Long> createDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) {
  161 + return success(demo03StudentService.createDemo03Grade(demo03Grade));
  162 + }
  163 +
  164 + @PutMapping("/demo03-grade/update")
  165 + @Operation(summary = "更新学生班级")
  166 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
  167 + public CommonResult<Boolean> updateDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) {
  168 + demo03StudentService.updateDemo03Grade(demo03Grade);
  169 + return success(true);
  170 + }
  171 +
  172 + @DeleteMapping("/demo03-grade/delete")
  173 + @Parameter(name = "id", description = "编号", required = true)
  174 + @Operation(summary = "删除学生班级")
  175 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
  176 + public CommonResult<Boolean> deleteDemo03Grade(@RequestParam("id") Long id) {
  177 + demo03StudentService.deleteDemo03Grade(id);
  178 + return success(true);
  179 + }
  180 +
  181 + @GetMapping("/demo03-grade/get")
  182 + @Operation(summary = "获得学生班级")
  183 + @Parameter(name = "id", description = "编号", required = true)
  184 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
  185 + public CommonResult<Demo03GradeDO> getDemo03Grade(@RequestParam("id") Long id) {
  186 + return success(demo03StudentService.getDemo03Grade(id));
  187 + }
  188 +
  189 + @GetMapping("/demo03-grade/get-by-student-id")
  190 + @Operation(summary = "获得学生班级")
  191 + @Parameter(name = "studentId", description = "学生编号")
  192 + @PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
  193 + public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) {
  194 + return success(demo03StudentService.getDemo03GradeByStudentId(studentId));
  195 + }
  196 +
  197 +}
0 \ No newline at end of file 198 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/package-info.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03;
0 \ No newline at end of file 2 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/vo/Demo03StudentPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
  2 +
  3 +import lombok.*;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  6 +import org.springframework.format.annotation.DateTimeFormat;
  7 +import java.time.LocalDateTime;
  8 +
  9 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  10 +
  11 +@Schema(description = "管理后台 - 学生分页 Request VO")
  12 +@Data
  13 +@EqualsAndHashCode(callSuper = true)
  14 +@ToString(callSuper = true)
  15 +public class Demo03StudentPageReqVO extends PageParam {
  16 +
  17 + @Schema(description = "名字", example = "芋艿")
  18 + private String name;
  19 +
  20 + @Schema(description = "性别")
  21 + private Integer sex;
  22 +
  23 + @Schema(description = "简介", example = "随便")
  24 + private String description;
  25 +
  26 + @Schema(description = "创建时间")
  27 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  28 + private LocalDateTime[] createTime;
  29 +
  30 +}
0 \ No newline at end of file 31 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/vo/Demo03StudentRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +
  6 +import java.time.LocalDateTime;
  7 +import com.alibaba.excel.annotation.*;
  8 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  9 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  10 +
  11 +@Schema(description = "管理后台 - 学生 Response VO")
  12 +@Data
  13 +@ExcelIgnoreUnannotated
  14 +public class Demo03StudentRespVO {
  15 +
  16 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
  17 + @ExcelProperty("编号")
  18 + private Long id;
  19 +
  20 + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
  21 + @ExcelProperty("名字")
  22 + private String name;
  23 +
  24 + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
  25 + @ExcelProperty(value = "性别", converter = DictConvert.class)
  26 + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
  27 + private Integer sex;
  28 +
  29 + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
  30 + @ExcelProperty("出生日期")
  31 + private LocalDateTime birthday;
  32 +
  33 + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
  34 + @ExcelProperty("简介")
  35 + private String description;
  36 +
  37 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  38 + @ExcelProperty("创建时间")
  39 + private LocalDateTime createTime;
  40 +
  41 +}
0 \ No newline at end of file 42 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo03/vo/Demo03StudentSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import javax.validation.constraints.*;
  7 +import java.time.LocalDateTime;
  8 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
  9 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
  10 +
  11 +@Schema(description = "管理后台 - 学生新增/修改 Request VO")
  12 +@Data
  13 +public class Demo03StudentSaveReqVO {
  14 +
  15 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
  16 + private Long id;
  17 +
  18 + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
  19 + @NotEmpty(message = "名字不能为空")
  20 + private String name;
  21 +
  22 + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
  23 + @NotNull(message = "性别不能为空")
  24 + private Integer sex;
  25 +
  26 + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED)
  27 + @NotNull(message = "出生日期不能为空")
  28 + private LocalDateTime birthday;
  29 +
  30 + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
  31 + @NotEmpty(message = "简介不能为空")
  32 + private String description;
  33 +
  34 +
  35 + private List<Demo03CourseDO> demo03Courses;
  36 +
  37 + private Demo03GradeDO demo03Grade;
  38 +
  39 +}
0 \ No newline at end of file 40 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/package-info.java 0 → 100644
  1 +/**
  2 + * 代码生成示例
  3 + *
  4 + * 1. demo01:单表(增删改查)
  5 + * 2. demo02:单表(树形结构)
  6 + * 3. demo03:主子表(标准模式)+ 主子表(ERP 模式)+ 主子表(内嵌模式)
  7 + */
  8 +package cn.iocoder.yudao.module.infra.controller.admin.demo;
0 \ No newline at end of file 9 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.http deleted
1 -### 请求 /infra/test-demo/get 接口 => 成功  
2 -GET {{baseUrl}}/infra/test-demo/get?id=106  
3 -Authorization: Bearer {{token}}  
4 -tenant-id: {{adminTenentId}}  
5 -  
6 -### 请求 /infra/test-demo/update 接口 => 成功  
7 -PUT {{baseUrl}}/infra/test-demo/update  
8 -Authorization: Bearer {{token}}  
9 -tenant-id: {{adminTenentId}}  
10 -Content-Type: application/json  
11 -  
12 -  
13 -{  
14 - "id": 106,  
15 - "name": "测试",  
16 - "status": "0",  
17 - "type": 1,  
18 - "category": 1  
19 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/TestDemoController.java deleted
1 -package cn.iocoder.yudao.module.infra.controller.admin.test;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.CommonResult;  
4 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
5 -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;  
6 -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;  
7 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.*;  
8 -import cn.iocoder.yudao.module.infra.convert.test.TestDemoConvert;  
9 -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO;  
10 -import cn.iocoder.yudao.module.infra.service.test.TestDemoService;  
11 -import io.swagger.v3.oas.annotations.tags.Tag;  
12 -import io.swagger.v3.oas.annotations.Parameter;  
13 -import io.swagger.v3.oas.annotations.Operation;  
14 -import org.springframework.security.access.prepost.PreAuthorize;  
15 -import org.springframework.validation.annotation.Validated;  
16 -import org.springframework.web.bind.annotation.*;  
17 -  
18 -import javax.annotation.Resource;  
19 -import javax.servlet.http.HttpServletResponse;  
20 -import javax.validation.Valid;  
21 -import java.io.IOException;  
22 -import java.util.Collection;  
23 -import java.util.List;  
24 -  
25 -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;  
26 -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;  
27 -  
28 -@Tag(name = "管理后台 - 字典类型")  
29 -@RestController  
30 -@RequestMapping("/infra/test-demo")  
31 -@Validated  
32 -public class TestDemoController {  
33 -  
34 - @Resource  
35 - private TestDemoService testDemoService;  
36 -  
37 - @PostMapping("/create")  
38 - @Operation(summary = "创建字典类型")  
39 - @PreAuthorize("@ss.hasPermission('infra:test-demo:create')")  
40 - public CommonResult<Long> createTestDemo(@Valid @RequestBody TestDemoCreateReqVO createReqVO) {  
41 - return success(testDemoService.createTestDemo(createReqVO));  
42 - }  
43 -  
44 - @PutMapping("/update")  
45 - @Operation(summary = "更新字典类型")  
46 - @PreAuthorize("@ss.hasPermission('infra:test-demo:update')")  
47 - public CommonResult<Boolean> updateTestDemo(@Valid @RequestBody TestDemoUpdateReqVO updateReqVO) {  
48 - testDemoService.updateTestDemo(updateReqVO);  
49 - return success(true);  
50 - }  
51 -  
52 - @DeleteMapping("/delete")  
53 - @Operation(summary = "删除字典类型")  
54 - @Parameter(name = "id", description = "编号", required = true)  
55 - @PreAuthorize("@ss.hasPermission('infra:test-demo:delete')")  
56 - public CommonResult<Boolean> deleteTestDemo(@RequestParam("id") Long id) {  
57 - testDemoService.deleteTestDemo(id);  
58 - return success(true);  
59 - }  
60 -  
61 - @GetMapping("/get")  
62 - @Operation(summary = "获得字典类型")  
63 - @Parameter(name = "id", description = "编号", required = true, example = "1024")  
64 - @PreAuthorize("@ss.hasPermission('infra:test-demo:query')")  
65 - public CommonResult<TestDemoRespVO> getTestDemo(@RequestParam("id") Long id) {  
66 - TestDemoDO testDemo = testDemoService.getTestDemo(id);  
67 - return success(TestDemoConvert.INSTANCE.convert(testDemo));  
68 - }  
69 -  
70 - @GetMapping("/list")  
71 - @Operation(summary = "获得字典类型列表")  
72 - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")  
73 - @PreAuthorize("@ss.hasPermission('infra:test-demo:query')")  
74 - public CommonResult<List<TestDemoRespVO>> getTestDemoList(@RequestParam("ids") Collection<Long> ids) {  
75 - List<TestDemoDO> list = testDemoService.getTestDemoList(ids);  
76 - return success(TestDemoConvert.INSTANCE.convertList(list));  
77 - }  
78 -  
79 - @GetMapping("/page")  
80 - @Operation(summary = "获得字典类型分页")  
81 - @PreAuthorize("@ss.hasPermission('infra:test-demo:query')") public CommonResult<PageResult<TestDemoRespVO>> getTestDemoPage(@Valid TestDemoPageReqVO pageVO) {  
82 - PageResult<TestDemoDO> pageResult = testDemoService.getTestDemoPage(pageVO);  
83 - return success(TestDemoConvert.INSTANCE.convertPage(pageResult));  
84 - }  
85 -  
86 - @GetMapping("/export-excel")  
87 - @Operation(summary = "导出字典类型 Excel")  
88 - @PreAuthorize("@ss.hasPermission('infra:test-demo:export')") @OperateLog(type = EXPORT)  
89 - public void exportTestDemoExcel(@Valid TestDemoExportReqVO exportReqVO,  
90 - HttpServletResponse response) throws IOException {  
91 - List<TestDemoDO> list = testDemoService.getTestDemoList(exportReqVO);  
92 - // 导出 Excel  
93 - List<TestDemoExcelVO> datas = TestDemoConvert.INSTANCE.convertList02(list);  
94 - ExcelUtils.write(response, "字典类型.xls", "数据", TestDemoExcelVO.class, datas);  
95 - }  
96 -  
97 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoBaseVO.java deleted
1 -package cn.iocoder.yudao.module.infra.controller.admin.test.vo;  
2 -import io.swagger.v3.oas.annotations.media.Schema;  
3 -import lombok.*;  
4 -import javax.validation.constraints.*;  
5 -  
6 -/**  
7 -* 字典类型 Base VO,提供给添加、修改、详细的子 VO 使用  
8 -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成  
9 -*/  
10 -@Data  
11 -public class TestDemoBaseVO {  
12 -  
13 - @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED)  
14 - @NotNull(message = "名字不能为空")  
15 - private String name;  
16 -  
17 - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)  
18 - @NotNull(message = "状态不能为空")  
19 - private Integer status;  
20 -  
21 - @Schema(description = "类型", requiredMode = Schema.RequiredMode.REQUIRED)  
22 - @NotNull(message = "类型不能为空")  
23 - private Integer type;  
24 -  
25 - @Schema(description = "分类", requiredMode = Schema.RequiredMode.REQUIRED)  
26 - @NotNull(message = "分类不能为空")  
27 - private Integer category;  
28 -  
29 - @Schema(description = "备注")  
30 - private String remark;  
31 -  
32 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoCreateReqVO.java deleted
1 -package cn.iocoder.yudao.module.infra.controller.admin.test.vo;  
2 -import io.swagger.v3.oas.annotations.media.Schema;  
3 -import lombok.*;  
4 -  
5 -@Schema(description = "管理后台 - 字典类型创建 Request VO")  
6 -@Data  
7 -@EqualsAndHashCode(callSuper = true)  
8 -@ToString(callSuper = true)  
9 -public class TestDemoCreateReqVO extends TestDemoBaseVO {  
10 -  
11 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExcelVO.java deleted
1 -package cn.iocoder.yudao.module.infra.controller.admin.test.vo;  
2 -  
3 -import lombok.*;  
4 -  
5 -import java.time.LocalDateTime;  
6 -  
7 -import com.alibaba.excel.annotation.ExcelProperty;  
8 -  
9 -/**  
10 - * 字典类型 Excel VO  
11 - *  
12 - * @author 芋道源码  
13 - */  
14 -@Data  
15 -public class TestDemoExcelVO {  
16 -  
17 - @ExcelProperty("编号")  
18 - private Long id;  
19 -  
20 - @ExcelProperty("名字")  
21 - private String name;  
22 -  
23 - @ExcelProperty("状态")  
24 - private Integer status;  
25 -  
26 - @ExcelProperty("类型")  
27 - private Integer type;  
28 -  
29 - @ExcelProperty("分类")  
30 - private Integer category;  
31 -  
32 - @ExcelProperty("备注")  
33 - private String remark;  
34 -  
35 - @ExcelProperty("创建时间")  
36 - private LocalDateTime createTime;  
37 -  
38 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoRespVO.java deleted
1 -package cn.iocoder.yudao.module.infra.controller.admin.test.vo;  
2 -import io.swagger.v3.oas.annotations.media.Schema;  
3 -import lombok.*;  
4 -  
5 -import java.time.LocalDateTime;  
6 -  
7 -@Schema(description = "管理后台 - 字典类型 Response VO")  
8 -@Data  
9 -@EqualsAndHashCode(callSuper = true)  
10 -@ToString(callSuper = true)  
11 -public class TestDemoRespVO extends TestDemoBaseVO {  
12 -  
13 - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED)  
14 - private Long id;  
15 -  
16 - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)  
17 - private LocalDateTime createTime;  
18 -  
19 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoUpdateReqVO.java deleted
1 -package cn.iocoder.yudao.module.infra.controller.admin.test.vo;  
2 -import io.swagger.v3.oas.annotations.media.Schema;  
3 -import lombok.*;  
4 -import javax.validation.constraints.*;  
5 -  
6 -@Schema(description = "管理后台 - 字典类型更新 Request VO")  
7 -@Data  
8 -@EqualsAndHashCode(callSuper = true)  
9 -@ToString(callSuper = true)  
10 -public class TestDemoUpdateReqVO extends TestDemoBaseVO {  
11 -  
12 - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED)  
13 - @NotNull(message = "编号不能为空")  
14 - private Long id;  
15 -  
16 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/codegen/CodegenConvert.java
@@ -56,7 +56,7 @@ public interface CodegenConvert { @@ -56,7 +56,7 @@ public interface CodegenConvert {
56 56
57 // ========== CodegenTableDO 相关 ========== 57 // ========== CodegenTableDO 相关 ==========
58 58
59 -// List<CodegenTableRespVO> convertList02(List<CodegenTableDO> list); 59 + List<CodegenTableRespVO> convertList05(List<CodegenTableDO> list);
60 60
61 CodegenTableRespVO convert(CodegenTableDO bean); 61 CodegenTableRespVO convert(CodegenTableDO bean);
62 62
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/test/TestDemoConvert.java deleted
1 -package cn.iocoder.yudao.module.infra.convert.test;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
4 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoCreateReqVO;  
5 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoExcelVO;  
6 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoRespVO;  
7 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoUpdateReqVO;  
8 -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO;  
9 -import org.mapstruct.Mapper;  
10 -import org.mapstruct.factory.Mappers;  
11 -  
12 -import java.util.List;  
13 -  
14 -/**  
15 - * 字典类型 Convert  
16 - *  
17 - * @author 芋道源码  
18 - */  
19 -@Mapper  
20 -public interface TestDemoConvert {  
21 -  
22 - TestDemoConvert INSTANCE = Mappers.getMapper(TestDemoConvert.class);  
23 -  
24 - TestDemoDO convert(TestDemoCreateReqVO bean);  
25 -  
26 - TestDemoDO convert(TestDemoUpdateReqVO bean);  
27 -  
28 - TestDemoRespVO convert(TestDemoDO bean);  
29 -  
30 - List<TestDemoRespVO> convertList(List<TestDemoDO> list);  
31 -  
32 - PageResult<TestDemoRespVO> convertPage(PageResult<TestDemoDO> page);  
33 -  
34 - List<TestDemoExcelVO> convertList02(List<TestDemoDO> list);  
35 -  
36 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenTableDO.java
@@ -116,4 +116,43 @@ public class CodegenTableDO extends BaseDO { @@ -116,4 +116,43 @@ public class CodegenTableDO extends BaseDO {
116 */ 116 */
117 private Long parentMenuId; 117 private Long parentMenuId;
118 118
  119 + // ========== 主子表相关字段 ==========
  120 +
  121 + /**
  122 + * 主表的编号
  123 + *
  124 + * 关联 {@link CodegenTableDO#getId()}
  125 + */
  126 + private Long masterTableId;
  127 + /**
  128 + * 【自己】子表关联主表的字段编号
  129 + *
  130 + * 关联 {@link CodegenColumnDO#getId()}
  131 + */
  132 + private Long subJoinColumnId;
  133 + /**
  134 + * 主表与子表是否一对多
  135 + *
  136 + * true:一对多
  137 + * false:一对一
  138 + */
  139 + private Boolean subJoinMany;
  140 +
  141 + // ========== 树表相关字段 ==========
  142 +
  143 + /**
  144 + * 树表的父字段编号
  145 + *
  146 + * 关联 {@link CodegenColumnDO#getId()}
  147 + */
  148 + private Long treeParentColumnId;
  149 + /**
  150 + * 树表的名字字段编号
  151 + *
  152 + * 名字的用途:新增或修改时,select 框展示的字段
  153 + *
  154 + * 关联 {@link CodegenColumnDO#getId()}
  155 + */
  156 + private Long treeNameColumnId;
  157 +
119 } 158 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/test/TestDemoDO.java renamed to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo01/Demo01ContactDO.java 100755 → 100644
1 -package cn.iocoder.yudao.module.infra.dal.dataobject.test; 1 +package cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01;
2 2
3 -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;  
4 -import com.baomidou.mybatisplus.annotation.KeySequence;  
5 -import com.baomidou.mybatisplus.annotation.TableId;  
6 -import com.baomidou.mybatisplus.annotation.TableName;  
7 import lombok.*; 3 import lombok.*;
  4 +import java.util.*;
  5 +import java.time.LocalDateTime;
  6 +import java.time.LocalDateTime;
  7 +import java.time.LocalDateTime;
  8 +import com.baomidou.mybatisplus.annotation.*;
  9 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
8 10
9 /** 11 /**
10 - * 字典类型 DO 12 + * 示例联系人 DO
11 * 13 *
12 * @author 芋道源码 14 * @author 芋道源码
13 */ 15 */
14 -@TableName("infra_test_demo")  
15 -@KeySequence("infra_test_demo_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 16 +@TableName("infra_demo01_contact")
  17 +@KeySequence("infra_demo01_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
16 @Data 18 @Data
17 @EqualsAndHashCode(callSuper = true) 19 @EqualsAndHashCode(callSuper = true)
18 @ToString(callSuper = true) 20 @ToString(callSuper = true)
19 @Builder 21 @Builder
20 @NoArgsConstructor 22 @NoArgsConstructor
21 @AllArgsConstructor 23 @AllArgsConstructor
22 -public class TestDemoDO extends BaseDO { 24 +public class Demo01ContactDO extends BaseDO {
23 25
24 /** 26 /**
25 * 编号 27 * 编号
@@ -31,20 +33,22 @@ public class TestDemoDO extends BaseDO { @@ -31,20 +33,22 @@ public class TestDemoDO extends BaseDO {
31 */ 33 */
32 private String name; 34 private String name;
33 /** 35 /**
34 - * 状态 36 + * 性别
  37 + *
  38 + * 枚举 {@link TODO system_user_sex 对应的类}
35 */ 39 */
36 - private Integer status; 40 + private Integer sex;
37 /** 41 /**
38 - * 类型 42 + * 出生年
39 */ 43 */
40 - private Integer type; 44 + private LocalDateTime birthday;
41 /** 45 /**
42 - * 分类 46 + * 简介
43 */ 47 */
44 - private Integer category; 48 + private String description;
45 /** 49 /**
46 - * 备注 50 + * 头像
47 */ 51 */
48 - private String remark; 52 + private String avatar;
49 53
50 -} 54 -}
  55 +}
51 \ No newline at end of file 56 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo02/Demo02CategoryDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import java.time.LocalDateTime;
  6 +import java.time.LocalDateTime;
  7 +import com.baomidou.mybatisplus.annotation.*;
  8 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  9 +
  10 +/**
  11 + * 示例分类 DO
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@TableName("infra_demo02_category")
  16 +@KeySequence("infra_demo02_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
  23 +public class Demo02CategoryDO extends BaseDO {
  24 +
  25 + public static final Long PARENT_ID_ROOT = 0L;
  26 +
  27 + /**
  28 + * 编号
  29 + */
  30 + @TableId
  31 + private Long id;
  32 + /**
  33 + * 名字
  34 + */
  35 + private String name;
  36 + /**
  37 + * 父级编号
  38 + */
  39 + private Long parentId;
  40 +
  41 +}
0 \ No newline at end of file 42 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo03/Demo03CourseDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import java.time.LocalDateTime;
  6 +import java.time.LocalDateTime;
  7 +import com.baomidou.mybatisplus.annotation.*;
  8 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  9 +
  10 +/**
  11 + * 学生课程 DO
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@TableName("infra_demo03_course")
  16 +@KeySequence("infra_demo03_course_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
  23 +public class Demo03CourseDO extends BaseDO {
  24 +
  25 + /**
  26 + * 编号
  27 + */
  28 + @TableId
  29 + private Long id;
  30 + /**
  31 + * 学生编号
  32 + */
  33 + private Long studentId;
  34 + /**
  35 + * 名字
  36 + */
  37 + private String name;
  38 + /**
  39 + * 分数
  40 + */
  41 + private Integer score;
  42 +
  43 +}
0 \ No newline at end of file 44 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo03/Demo03GradeDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import java.time.LocalDateTime;
  6 +import java.time.LocalDateTime;
  7 +import com.baomidou.mybatisplus.annotation.*;
  8 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  9 +
  10 +/**
  11 + * 学生班级 DO
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@TableName("infra_demo03_grade")
  16 +@KeySequence("infra_demo03_grade_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
  23 +public class Demo03GradeDO extends BaseDO {
  24 +
  25 + /**
  26 + * 编号
  27 + */
  28 + @TableId
  29 + private Long id;
  30 + /**
  31 + * 学生编号
  32 + */
  33 + private Long studentId;
  34 + /**
  35 + * 名字
  36 + */
  37 + private String name;
  38 + /**
  39 + * 班主任
  40 + */
  41 + private String teacher;
  42 +
  43 +}
0 \ No newline at end of file 44 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo03/Demo03StudentDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import java.time.LocalDateTime;
  6 +import java.time.LocalDateTime;
  7 +import java.time.LocalDateTime;
  8 +import com.baomidou.mybatisplus.annotation.*;
  9 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  10 +
  11 +/**
  12 + * 学生 DO
  13 + *
  14 + * @author 芋道源码
  15 + */
  16 +@TableName("infra_demo03_student")
  17 +@KeySequence("infra_demo03_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  18 +@Data
  19 +@EqualsAndHashCode(callSuper = true)
  20 +@ToString(callSuper = true)
  21 +@Builder
  22 +@NoArgsConstructor
  23 +@AllArgsConstructor
  24 +public class Demo03StudentDO extends BaseDO {
  25 +
  26 + /**
  27 + * 编号
  28 + */
  29 + @TableId
  30 + private Long id;
  31 + /**
  32 + * 名字
  33 + */
  34 + private String name;
  35 + /**
  36 + * 性别
  37 + *
  38 + * 枚举 {@link TODO system_user_sex 对应的类}
  39 + */
  40 + private Integer sex;
  41 + /**
  42 + * 出生日期
  43 + */
  44 + private LocalDateTime birthday;
  45 + /**
  46 + * 简介
  47 + */
  48 + private String description;
  49 +
  50 +}
0 \ No newline at end of file 51 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/codegen/CodegenTableMapper.java
@@ -29,4 +29,9 @@ public interface CodegenTableMapper extends BaseMapperX&lt;CodegenTableDO&gt; { @@ -29,4 +29,9 @@ public interface CodegenTableMapper extends BaseMapperX&lt;CodegenTableDO&gt; {
29 return selectList(CodegenTableDO::getDataSourceConfigId, dataSourceConfigId); 29 return selectList(CodegenTableDO::getDataSourceConfigId, dataSourceConfigId);
30 } 30 }
31 31
  32 + default List<CodegenTableDO> selectListByTemplateTypeAndMasterTableId(Integer templateType, Long masterTableId) {
  33 + return selectList(CodegenTableDO::getTemplateType, templateType,
  34 + CodegenTableDO::getMasterTableId, masterTableId);
  35 + }
  36 +
32 } 37 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo01/Demo01ContactMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo01;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  6 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
  7 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +/**
  11 + * 示例联系人 Mapper
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@Mapper
  16 +public interface Demo01ContactMapper extends BaseMapperX<Demo01ContactDO> {
  17 +
  18 + default PageResult<Demo01ContactDO> selectPage(Demo01ContactPageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<Demo01ContactDO>()
  20 + .likeIfPresent(Demo01ContactDO::getName, reqVO.getName())
  21 + .eqIfPresent(Demo01ContactDO::getSex, reqVO.getSex())
  22 + .betweenIfPresent(Demo01ContactDO::getCreateTime, reqVO.getCreateTime())
  23 + .orderByDesc(Demo01ContactDO::getId));
  24 + }
  25 +
  26 +}
0 \ No newline at end of file 27 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo02/Demo02CategoryMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo02;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  7 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
  8 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
  9 +import org.apache.ibatis.annotations.Mapper;
  10 +
  11 +/**
  12 + * 示例分类 Mapper
  13 + *
  14 + * @author 芋道源码
  15 + */
  16 +@Mapper
  17 +public interface Demo02CategoryMapper extends BaseMapperX<Demo02CategoryDO> {
  18 +
  19 + default List<Demo02CategoryDO> selectList(Demo02CategoryListReqVO reqVO) {
  20 + return selectList(new LambdaQueryWrapperX<Demo02CategoryDO>()
  21 + .likeIfPresent(Demo02CategoryDO::getName, reqVO.getName())
  22 + .eqIfPresent(Demo02CategoryDO::getParentId, reqVO.getParentId())
  23 + .betweenIfPresent(Demo02CategoryDO::getCreateTime, reqVO.getCreateTime())
  24 + .orderByDesc(Demo02CategoryDO::getId));
  25 + }
  26 +
  27 + default Demo02CategoryDO selectByParentIdAndName(Long parentId, String name) {
  28 + return selectOne(Demo02CategoryDO::getParentId, parentId, Demo02CategoryDO::getName, name);
  29 + }
  30 +
  31 + default Long selectCountByParentId(Long parentId) {
  32 + return selectCount(Demo02CategoryDO::getParentId, parentId);
  33 + }
  34 +
  35 +}
0 \ No newline at end of file 36 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/Demo03CourseMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  6 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  7 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * 学生课程 Mapper
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +@Mapper
  18 +public interface Demo03CourseMapper extends BaseMapperX<Demo03CourseDO> {
  19 +
  20 + default PageResult<Demo03CourseDO> selectPage(PageParam reqVO, Long studentId) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<Demo03CourseDO>()
  22 + .eq(Demo03CourseDO::getStudentId, studentId)
  23 + .orderByDesc(Demo03CourseDO::getId));
  24 + }
  25 +
  26 + default List<Demo03CourseDO> selectListByStudentId(Long studentId) {
  27 + return selectList(Demo03CourseDO::getStudentId, studentId);
  28 + }
  29 +
  30 + default int deleteByStudentId(Long studentId) {
  31 + return delete(Demo03CourseDO::getStudentId, studentId);
  32 + }
  33 +
  34 +}
0 \ No newline at end of file 35 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/Demo03GradeMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  6 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  7 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +/**
  11 + * 学生班级 Mapper
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@Mapper
  16 +public interface Demo03GradeMapper extends BaseMapperX<Demo03GradeDO> {
  17 +
  18 + default PageResult<Demo03GradeDO> selectPage(PageParam reqVO, Long studentId) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<Demo03GradeDO>()
  20 + .eq(Demo03GradeDO::getStudentId, studentId)
  21 + .orderByDesc(Demo03GradeDO::getId));
  22 + }
  23 +
  24 + default Demo03GradeDO selectByStudentId(Long studentId) {
  25 + return selectOne(Demo03GradeDO::getStudentId, studentId);
  26 + }
  27 +
  28 + default int deleteByStudentId(Long studentId) {
  29 + return delete(Demo03GradeDO::getStudentId, studentId);
  30 + }
  31 +
  32 +}
0 \ No newline at end of file 33 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo03/Demo03StudentMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  6 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
  7 +import org.apache.ibatis.annotations.Mapper;
  8 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.*;
  9 +
  10 +/**
  11 + * 学生 Mapper
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@Mapper
  16 +public interface Demo03StudentMapper extends BaseMapperX<Demo03StudentDO> {
  17 +
  18 + default PageResult<Demo03StudentDO> selectPage(Demo03StudentPageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>()
  20 + .likeIfPresent(Demo03StudentDO::getName, reqVO.getName())
  21 + .eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex())
  22 + .eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription())
  23 + .betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime())
  24 + .orderByDesc(Demo03StudentDO::getId));
  25 + }
  26 +
  27 +}
0 \ No newline at end of file 28 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/test/TestDemoMapper.java deleted
1 -package cn.iocoder.yudao.module.infra.dal.mysql.test;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
4 -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;  
5 -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;  
6 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoExportReqVO;  
7 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoPageReqVO;  
8 -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO;  
9 -import org.apache.ibatis.annotations.Mapper;  
10 -  
11 -import java.util.List;  
12 -  
13 -/**  
14 - * 字典类型 Mapper  
15 - *  
16 - * @author 芋道源码  
17 - */  
18 -@Mapper  
19 -public interface TestDemoMapper extends BaseMapperX<TestDemoDO> {  
20 -  
21 - default PageResult<TestDemoDO> selectPage(TestDemoPageReqVO reqVO) {  
22 - return selectPage(reqVO, new LambdaQueryWrapperX<TestDemoDO>()  
23 - .likeIfPresent(TestDemoDO::getName, reqVO.getName())  
24 - .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus())  
25 - .eqIfPresent(TestDemoDO::getType, reqVO.getType())  
26 - .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory())  
27 - .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark())  
28 - .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getCreateTime())  
29 - .orderByDesc(TestDemoDO::getId));  
30 - }  
31 -  
32 - default List<TestDemoDO> selectList(TestDemoExportReqVO reqVO) {  
33 - return selectList(new LambdaQueryWrapperX<TestDemoDO>()  
34 - .likeIfPresent(TestDemoDO::getName, reqVO.getName())  
35 - .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus())  
36 - .eqIfPresent(TestDemoDO::getType, reqVO.getType())  
37 - .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory())  
38 - .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark())  
39 - .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getCreateTime())  
40 - .orderByDesc(TestDemoDO::getId));  
41 - }  
42 -  
43 - List<TestDemoDO> selectList2();  
44 -  
45 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenColumnHtmlTypeEnum.java
@@ -16,8 +16,8 @@ public enum CodegenColumnHtmlTypeEnum { @@ -16,8 +16,8 @@ public enum CodegenColumnHtmlTypeEnum {
16 RADIO("radio"), // 单选框 16 RADIO("radio"), // 单选框
17 CHECKBOX("checkbox"), // 复选框 17 CHECKBOX("checkbox"), // 复选框
18 DATETIME("datetime"), // 日期控件 18 DATETIME("datetime"), // 日期控件
19 - UPLOAD_IMAGE("upload_image"), // 上传图片  
20 - UPLOAD_FILE("upload_file"), // 上传文件 19 + IMAGE_UPLOAD("imageUpload"), // 上传图片
  20 + FILE_UPLOAD("fileUpload"), // 上传文件
21 EDITOR("editor"), // 富文本控件 21 EDITOR("editor"), // 富文本控件
22 ; 22 ;
23 23
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenTemplateTypeEnum.java
1 package cn.iocoder.yudao.module.infra.enums.codegen; 1 package cn.iocoder.yudao.module.infra.enums.codegen;
2 2
  3 +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
3 import lombok.AllArgsConstructor; 4 import lombok.AllArgsConstructor;
4 import lombok.Getter; 5 import lombok.Getter;
5 6
  7 +import java.util.Objects;
  8 +
6 /** 9 /**
7 * 代码生成模板类型 10 * 代码生成模板类型
8 * 11 *
@@ -12,8 +15,13 @@ import lombok.Getter; @@ -12,8 +15,13 @@ import lombok.Getter;
12 @Getter 15 @Getter
13 public enum CodegenTemplateTypeEnum { 16 public enum CodegenTemplateTypeEnum {
14 17
15 - CRUD(1), // 单表(增删改查) 18 + ONE(1), // 单表(增删改查)
16 TREE(2), // 树表(增删改查) 19 TREE(2), // 树表(增删改查)
  20 +
  21 + MASTER_NORMAL(10), // 主子表 - 主表 - 普通模式
  22 + MASTER_ERP(11), // 主子表 - 主表 - ERP 模式
  23 + MASTER_INNER(12), // 主子表 - 主表 - 内嵌模式
  24 + SUB(15), // 主子表 - 子表
17 ; 25 ;
18 26
19 /** 27 /**
@@ -21,4 +29,25 @@ public enum CodegenTemplateTypeEnum { @@ -21,4 +29,25 @@ public enum CodegenTemplateTypeEnum {
21 */ 29 */
22 private final Integer type; 30 private final Integer type;
23 31
  32 + /**
  33 + * 是否为主表
  34 + *
  35 + * @param type 类型
  36 + * @return 是否主表
  37 + */
  38 + public static boolean isMaster(Integer type) {
  39 + return ObjectUtils.equalsAny(type,
  40 + MASTER_NORMAL.type, MASTER_ERP.type, MASTER_INNER.type);
  41 + }
  42 +
  43 + /**
  44 + * 是否为树表
  45 + *
  46 + * @param type 类型
  47 + * @return 是否树表
  48 + */
  49 + public static boolean isTree(Integer type) {
  50 + return Objects.equals(type, TREE.type);
  51 + }
  52 +
24 } 53 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenService.java
@@ -49,6 +49,14 @@ public interface CodegenService { @@ -49,6 +49,14 @@ public interface CodegenService {
49 void deleteCodegen(Long tableId); 49 void deleteCodegen(Long tableId);
50 50
51 /** 51 /**
  52 + * 获得表定义列表
  53 + *
  54 + * @param dataSourceConfigId 数据源配置的编号
  55 + * @return 表定义列表
  56 + */
  57 + List<CodegenTableDO> getCodegenTableList(Long dataSourceConfigId);
  58 +
  59 + /**
52 * 获得表定义分页 60 * 获得表定义分页
53 * 61 *
54 * @param pageReqVO 分页条件 62 * @param pageReqVO 分页条件
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java
@@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; @@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO;
14 import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenColumnMapper; 14 import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenColumnMapper;
15 import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenTableMapper; 15 import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenTableMapper;
16 import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum; 16 import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum;
  17 +import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum;
17 import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties; 18 import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
18 import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder; 19 import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenBuilder;
19 import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine; 20 import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;
@@ -25,10 +26,7 @@ import org.springframework.stereotype.Service; @@ -25,10 +26,7 @@ import org.springframework.stereotype.Service;
25 import org.springframework.transaction.annotation.Transactional; 26 import org.springframework.transaction.annotation.Transactional;
26 27
27 import javax.annotation.Resource; 28 import javax.annotation.Resource;
28 -import java.util.ArrayList;  
29 -import java.util.List;  
30 -import java.util.Map;  
31 -import java.util.Set; 29 +import java.util.*;
32 import java.util.function.BiPredicate; 30 import java.util.function.BiPredicate;
33 import java.util.stream.Collectors; 31 import java.util.stream.Collectors;
34 32
@@ -129,6 +127,16 @@ public class CodegenServiceImpl implements CodegenService { @@ -129,6 +127,16 @@ public class CodegenServiceImpl implements CodegenService {
129 if (codegenTableMapper.selectById(updateReqVO.getTable().getId()) == null) { 127 if (codegenTableMapper.selectById(updateReqVO.getTable().getId()) == null) {
130 throw exception(CODEGEN_TABLE_NOT_EXISTS); 128 throw exception(CODEGEN_TABLE_NOT_EXISTS);
131 } 129 }
  130 + // 校验主表字段存在
  131 + if (Objects.equals(updateReqVO.getTable().getTemplateType(), CodegenTemplateTypeEnum.SUB.getType())) {
  132 + if (codegenTableMapper.selectById(updateReqVO.getTable().getMasterTableId()) == null) {
  133 + throw exception(CODEGEN_MASTER_TABLE_NOT_EXISTS, updateReqVO.getTable().getMasterTableId());
  134 + }
  135 + if (CollUtil.findOne(updateReqVO.getColumns(), // 关联主表的字段不存在
  136 + column -> column.getId().equals(updateReqVO.getTable().getSubJoinColumnId())) == null) {
  137 + throw exception(CODEGEN_SUB_COLUMN_NOT_EXISTS, updateReqVO.getTable().getSubJoinColumnId());
  138 + }
  139 + }
132 140
133 // 更新 table 表定义 141 // 更新 table 表定义
134 CodegenTableDO updateTableObj = CodegenConvert.INSTANCE.convert(updateReqVO.getTable()); 142 CodegenTableDO updateTableObj = CodegenConvert.INSTANCE.convert(updateReqVO.getTable());
@@ -209,6 +217,11 @@ public class CodegenServiceImpl implements CodegenService { @@ -209,6 +217,11 @@ public class CodegenServiceImpl implements CodegenService {
209 } 217 }
210 218
211 @Override 219 @Override
  220 + public List<CodegenTableDO> getCodegenTableList(Long dataSourceConfigId) {
  221 + return codegenTableMapper.selectListByDataSourceConfigId(dataSourceConfigId);
  222 + }
  223 +
  224 + @Override
212 public PageResult<CodegenTableDO> getCodegenTablePage(CodegenTablePageReqVO pageReqVO) { 225 public PageResult<CodegenTableDO> getCodegenTablePage(CodegenTablePageReqVO pageReqVO) {
213 return codegenTableMapper.selectPage(pageReqVO); 226 return codegenTableMapper.selectPage(pageReqVO);
214 } 227 }
@@ -235,14 +248,34 @@ public class CodegenServiceImpl implements CodegenService { @@ -235,14 +248,34 @@ public class CodegenServiceImpl implements CodegenService {
235 throw exception(CODEGEN_COLUMN_NOT_EXISTS); 248 throw exception(CODEGEN_COLUMN_NOT_EXISTS);
236 } 249 }
237 250
  251 + // 如果是主子表,则加载对应的子表信息
  252 + List<CodegenTableDO> subTables = null;
  253 + List<List<CodegenColumnDO>> subColumnsList = null;
  254 + if (CodegenTemplateTypeEnum.isMaster(table.getTemplateType())) {
  255 + // 校验子表存在
  256 + subTables = codegenTableMapper.selectListByTemplateTypeAndMasterTableId(
  257 + CodegenTemplateTypeEnum.SUB.getType(), tableId);
  258 + if (CollUtil.isEmpty(subTables)) {
  259 + throw exception(CODEGEN_MASTER_GENERATION_FAIL_NO_SUB_TABLE);
  260 + }
  261 + // 校验子表的关联字段存在
  262 + subColumnsList = new ArrayList<>();
  263 + for (CodegenTableDO subTable : subTables) {
  264 + List<CodegenColumnDO> subColumns = codegenColumnMapper.selectListByTableId(subTable.getId());
  265 + if (CollUtil.findOne(subColumns, column -> column.getId().equals(subTable.getSubJoinColumnId())) == null) {
  266 + throw exception(CODEGEN_SUB_COLUMN_NOT_EXISTS, subTable.getId());
  267 + }
  268 + subColumnsList.add(subColumns);
  269 + }
  270 + }
  271 +
238 // 执行生成 272 // 执行生成
239 - return codegenEngine.execute(table, columns); 273 + return codegenEngine.execute(table, columns, subTables, subColumnsList);
240 } 274 }
241 275
242 @Override 276 @Override
243 public List<DatabaseTableRespVO> getDatabaseTableList(Long dataSourceConfigId, String name, String comment) { 277 public List<DatabaseTableRespVO> getDatabaseTableList(Long dataSourceConfigId, String name, String comment) {
244 List<TableInfo> tables = databaseTableService.getTableList(dataSourceConfigId, name, comment); 278 List<TableInfo> tables = databaseTableService.getTableList(dataSourceConfigId, name, comment);
245 - // 移除已经生成的表  
246 // 移除在 Codegen 中,已经存在的 279 // 移除在 Codegen 中,已经存在的
247 Set<String> existsTables = CollectionUtils.convertSet( 280 Set<String> existsTables = CollectionUtils.convertSet(
248 codegenTableMapper.selectListByDataSourceConfigId(dataSourceConfigId), CodegenTableDO::getTableName); 281 codegenTableMapper.selectListByDataSourceConfigId(dataSourceConfigId), CodegenTableDO::getTableName);
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilder.java
@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.generator.config.po.TableInfo; @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.generator.config.po.TableInfo;
15 import com.google.common.collect.Sets; 15 import com.google.common.collect.Sets;
16 import org.springframework.stereotype.Component; 16 import org.springframework.stereotype.Component;
17 17
  18 +import java.time.LocalDateTime;
18 import java.util.*; 19 import java.util.*;
19 20
20 import static cn.hutool.core.text.CharSequenceUtil.*; 21 import static cn.hutool.core.text.CharSequenceUtil.*;
@@ -49,8 +50,8 @@ public class CodegenBuilder { @@ -49,8 +50,8 @@ public class CodegenBuilder {
49 .put("status", CodegenColumnHtmlTypeEnum.RADIO) 50 .put("status", CodegenColumnHtmlTypeEnum.RADIO)
50 .put("sex", CodegenColumnHtmlTypeEnum.RADIO) 51 .put("sex", CodegenColumnHtmlTypeEnum.RADIO)
51 .put("type", CodegenColumnHtmlTypeEnum.SELECT) 52 .put("type", CodegenColumnHtmlTypeEnum.SELECT)
52 - .put("image", CodegenColumnHtmlTypeEnum.UPLOAD_IMAGE)  
53 - .put("file", CodegenColumnHtmlTypeEnum.UPLOAD_FILE) 53 + .put("image", CodegenColumnHtmlTypeEnum.IMAGE_UPLOAD)
  54 + .put("file", CodegenColumnHtmlTypeEnum.FILE_UPLOAD)
54 .put("content", CodegenColumnHtmlTypeEnum.EDITOR) 55 .put("content", CodegenColumnHtmlTypeEnum.EDITOR)
55 .put("description", CodegenColumnHtmlTypeEnum.EDITOR) 56 .put("description", CodegenColumnHtmlTypeEnum.EDITOR)
56 .put("demo", CodegenColumnHtmlTypeEnum.EDITOR) 57 .put("demo", CodegenColumnHtmlTypeEnum.EDITOR)
@@ -118,7 +119,7 @@ public class CodegenBuilder { @@ -118,7 +119,7 @@ public class CodegenBuilder {
118 table.setClassName(upperFirst(toCamelCase(subAfter(tableName, '_', false)))); 119 table.setClassName(upperFirst(toCamelCase(subAfter(tableName, '_', false))));
119 // 去除结尾的表,作为类描述 120 // 去除结尾的表,作为类描述
120 table.setClassComment(StrUtil.removeSuffixIgnoreCase(table.getTableComment(), "表")); 121 table.setClassComment(StrUtil.removeSuffixIgnoreCase(table.getTableComment(), "表"));
121 - table.setTemplateType(CodegenTemplateTypeEnum.CRUD.getType()); 122 + table.setTemplateType(CodegenTemplateTypeEnum.ONE.getType());
122 } 123 }
123 124
124 public List<CodegenColumnDO> buildColumns(Long tableId, List<TableField> tableFields) { 125 public List<CodegenColumnDO> buildColumns(Long tableId, List<TableField> tableFields) {
@@ -127,6 +128,10 @@ public class CodegenBuilder { @@ -127,6 +128,10 @@ public class CodegenBuilder {
127 for (CodegenColumnDO column : columns) { 128 for (CodegenColumnDO column : columns) {
128 column.setTableId(tableId); 129 column.setTableId(tableId);
129 column.setOrdinalPosition(index++); 130 column.setOrdinalPosition(index++);
  131 + // 特殊处理:Byte => Integer
  132 + if (Byte.class.getSimpleName().equals(column.getJavaType())) {
  133 + column.setJavaType(Integer.class.getSimpleName());
  134 + }
130 // 初始化 Column 列的默认字段 135 // 初始化 Column 列的默认字段
131 processColumnOperation(column); // 处理 CRUD 相关的字段的默认值 136 processColumnOperation(column); // 处理 CRUD 相关的字段的默认值
132 processColumnUI(column); // 处理 UI 相关的字段的默认值 137 processColumnUI(column); // 处理 UI 相关的字段的默认值
@@ -162,10 +167,13 @@ public class CodegenBuilder { @@ -162,10 +167,13 @@ public class CodegenBuilder {
162 .filter(entry -> StrUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey())) 167 .filter(entry -> StrUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey()))
163 .findFirst().ifPresent(entry -> column.setHtmlType(entry.getValue().getType())); 168 .findFirst().ifPresent(entry -> column.setHtmlType(entry.getValue().getType()));
164 // 如果是 Boolean 类型时,设置为 radio 类型. 169 // 如果是 Boolean 类型时,设置为 radio 类型.
165 - // 其它类型,因为字段名可以相对保障,所以不进行处理。例如说 date 对应 datetime 类型.  
166 if (Boolean.class.getSimpleName().equals(column.getJavaType())) { 170 if (Boolean.class.getSimpleName().equals(column.getJavaType())) {
167 column.setHtmlType(CodegenColumnHtmlTypeEnum.RADIO.getType()); 171 column.setHtmlType(CodegenColumnHtmlTypeEnum.RADIO.getType());
168 } 172 }
  173 + // 如果是 LocalDateTime 类型,则设置为 datetime 类型
  174 + if (LocalDateTime.class.getSimpleName().equals(column.getJavaType())) {
  175 + column.setHtmlType(CodegenColumnHtmlTypeEnum.DATETIME.getType());
  176 + }
169 // 兜底,设置默认为 input 类型 177 // 兜底,设置默认为 input 类型
170 if (column.getHtmlType() == null) { 178 if (column.getHtmlType() == null) {
171 column.setHtmlType(CodegenColumnHtmlTypeEnum.INPUT.getType()); 179 column.setHtmlType(CodegenColumnHtmlTypeEnum.INPUT.getType());
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java
1 package cn.iocoder.yudao.module.infra.service.codegen.inner; 1 package cn.iocoder.yudao.module.infra.service.codegen.inner;
2 2
  3 +import cn.hutool.core.collection.CollUtil;
3 import cn.hutool.core.map.MapUtil; 4 import cn.hutool.core.map.MapUtil;
  5 +import cn.hutool.core.util.ObjectUtil;
4 import cn.hutool.core.util.StrUtil; 6 import cn.hutool.core.util.StrUtil;
5 import cn.hutool.extra.template.TemplateConfig; 7 import cn.hutool.extra.template.TemplateConfig;
6 import cn.hutool.extra.template.TemplateEngine; 8 import cn.hutool.extra.template.TemplateEngine;
@@ -12,7 +14,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -12,7 +14,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
12 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; 14 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
13 import cn.iocoder.yudao.framework.common.util.date.DateUtils; 15 import cn.iocoder.yudao.framework.common.util.date.DateUtils;
14 import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; 16 import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
  17 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
15 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; 18 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
  19 +import cn.iocoder.yudao.framework.common.util.string.StrUtils;
16 import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; 20 import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
17 import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; 21 import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
18 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; 22 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
@@ -25,7 +29,9 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; @@ -25,7 +29,9 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO;
25 import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; 29 import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO;
26 import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum; 30 import cn.iocoder.yudao.module.infra.enums.codegen.CodegenFrontTypeEnum;
27 import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum; 31 import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum;
  32 +import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum;
28 import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties; 33 import cn.iocoder.yudao.module.infra.framework.codegen.config.CodegenProperties;
  34 +import com.google.common.annotations.VisibleForTesting;
29 import com.google.common.collect.ImmutableTable; 35 import com.google.common.collect.ImmutableTable;
30 import com.google.common.collect.Maps; 36 import com.google.common.collect.Maps;
31 import com.google.common.collect.Table; 37 import com.google.common.collect.Table;
@@ -33,10 +39,7 @@ import org.springframework.stereotype.Component; @@ -33,10 +39,7 @@ import org.springframework.stereotype.Component;
33 39
34 import javax.annotation.PostConstruct; 40 import javax.annotation.PostConstruct;
35 import javax.annotation.Resource; 41 import javax.annotation.Resource;
36 -import java.util.HashMap;  
37 -import java.util.LinkedHashMap;  
38 -import java.util.List;  
39 -import java.util.Map; 42 +import java.util.*;
40 43
41 import static cn.hutool.core.map.MapUtil.getStr; 44 import static cn.hutool.core.map.MapUtil.getStr;
42 import static cn.hutool.core.text.CharSequenceUtil.*; 45 import static cn.hutool.core.text.CharSequenceUtil.*;
@@ -60,20 +63,19 @@ public class CodegenEngine { @@ -60,20 +63,19 @@ public class CodegenEngine {
60 */ 63 */
61 private static final Map<String, String> SERVER_TEMPLATES = MapUtil.<String, String>builder(new LinkedHashMap<>()) // 有序 64 private static final Map<String, String> SERVER_TEMPLATES = MapUtil.<String, String>builder(new LinkedHashMap<>()) // 有序
62 // Java module-biz Main 65 // Java module-biz Main
63 - .put(javaTemplatePath("controller/vo/baseVO"), javaModuleImplVOFilePath("BaseVO"))  
64 - .put(javaTemplatePath("controller/vo/createReqVO"), javaModuleImplVOFilePath("CreateReqVO"))  
65 .put(javaTemplatePath("controller/vo/pageReqVO"), javaModuleImplVOFilePath("PageReqVO")) 66 .put(javaTemplatePath("controller/vo/pageReqVO"), javaModuleImplVOFilePath("PageReqVO"))
  67 + .put(javaTemplatePath("controller/vo/listReqVO"), javaModuleImplVOFilePath("ListReqVO"))
66 .put(javaTemplatePath("controller/vo/respVO"), javaModuleImplVOFilePath("RespVO")) 68 .put(javaTemplatePath("controller/vo/respVO"), javaModuleImplVOFilePath("RespVO"))
67 - .put(javaTemplatePath("controller/vo/updateReqVO"), javaModuleImplVOFilePath("UpdateReqVO"))  
68 - .put(javaTemplatePath("controller/vo/exportReqVO"), javaModuleImplVOFilePath("ExportReqVO"))  
69 - .put(javaTemplatePath("controller/vo/excelVO"), javaModuleImplVOFilePath("ExcelVO")) 69 + .put(javaTemplatePath("controller/vo/saveReqVO"), javaModuleImplVOFilePath("SaveReqVO"))
70 .put(javaTemplatePath("controller/controller"), javaModuleImplControllerFilePath()) 70 .put(javaTemplatePath("controller/controller"), javaModuleImplControllerFilePath())
71 - .put(javaTemplatePath("convert/convert"),  
72 - javaModuleImplMainFilePath("convert/${table.businessName}/${table.className}Convert"))  
73 .put(javaTemplatePath("dal/do"), 71 .put(javaTemplatePath("dal/do"),
74 javaModuleImplMainFilePath("dal/dataobject/${table.businessName}/${table.className}DO")) 72 javaModuleImplMainFilePath("dal/dataobject/${table.businessName}/${table.className}DO"))
  73 + .put(javaTemplatePath("dal/do_sub"), // 特殊:主子表专属逻辑
  74 + javaModuleImplMainFilePath("dal/dataobject/${table.businessName}/${subTable.className}DO"))
75 .put(javaTemplatePath("dal/mapper"), 75 .put(javaTemplatePath("dal/mapper"),
76 javaModuleImplMainFilePath("dal/mysql/${table.businessName}/${table.className}Mapper")) 76 javaModuleImplMainFilePath("dal/mysql/${table.businessName}/${table.className}Mapper"))
  77 + .put(javaTemplatePath("dal/mapper_sub"), // 特殊:主子表专属逻辑
  78 + javaModuleImplMainFilePath("dal/mysql/${table.businessName}/${subTable.className}Mapper"))
77 .put(javaTemplatePath("dal/mapper.xml"), mapperXmlFilePath()) 79 .put(javaTemplatePath("dal/mapper.xml"), mapperXmlFilePath())
78 .put(javaTemplatePath("service/serviceImpl"), 80 .put(javaTemplatePath("service/serviceImpl"),
79 javaModuleImplMainFilePath("service/${table.businessName}/${table.className}ServiceImpl")) 81 javaModuleImplMainFilePath("service/${table.businessName}/${table.className}ServiceImpl"))
@@ -99,34 +101,44 @@ public class CodegenEngine { @@ -99,34 +101,44 @@ public class CodegenEngine {
99 private static final Table<Integer, String, String> FRONT_TEMPLATES = ImmutableTable.<Integer, String, String>builder() 101 private static final Table<Integer, String, String> FRONT_TEMPLATES = ImmutableTable.<Integer, String, String>builder()
100 // Vue2 标准模版 102 // Vue2 标准模版
101 .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/index.vue"), 103 .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/index.vue"),
102 - vueFilePath("views/${table.moduleName}/${classNameVar}/index.vue")) 104 + vueFilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
103 .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("api/api.js"), 105 .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("api/api.js"),
104 vueFilePath("api/${table.moduleName}/${classNameVar}.js")) 106 vueFilePath("api/${table.moduleName}/${classNameVar}.js"))
105 // Vue3 标准模版 107 // Vue3 标准模版
106 .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/index.vue"), 108 .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/index.vue"),
107 - vue3FilePath("views/${table.moduleName}/${classNameVar}/index.vue")) 109 + vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
108 .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/form.vue"), 110 .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/form.vue"),
109 - vue3FilePath("views/${table.moduleName}/${classNameVar}/${simpleClassName}Form.vue")) 111 + vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
  112 + .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_normal.vue"), // 特殊:主子表专属逻辑
  113 + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
  114 + .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_inner.vue"), // 特殊:主子表专属逻辑
  115 + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
  116 + .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_erp.vue"), // 特殊:主子表专属逻辑
  117 + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue"))
  118 + .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_inner.vue"), // 特殊:主子表专属逻辑
  119 + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
  120 + .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_erp.vue"), // 特殊:主子表专属逻辑
  121 + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue"))
110 .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/api.ts"), 122 .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/api.ts"),
111 - vue3FilePath("api/${table.moduleName}/${classNameVar}/index.ts")) 123 + vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
112 // Vue3 Schema 模版 124 // Vue3 Schema 模版
113 .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/data.ts"), 125 .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/data.ts"),
114 - vue3FilePath("views/${table.moduleName}/${classNameVar}/${classNameVar}.data.ts")) 126 + vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
115 .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/index.vue"), 127 .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/index.vue"),
116 - vue3FilePath("views/${table.moduleName}/${classNameVar}/index.vue")) 128 + vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
117 .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/form.vue"), 129 .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/form.vue"),
118 - vue3FilePath("views/${table.moduleName}/${classNameVar}/${simpleClassName}Form.vue")) 130 + vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue"))
119 .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("api/api.ts"), 131 .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("api/api.ts"),
120 - vue3FilePath("api/${table.moduleName}/${classNameVar}/index.ts")) 132 + vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
121 // Vue3 vben 模版 133 // Vue3 vben 模版
122 .put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/data.ts"), 134 .put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/data.ts"),
123 - vue3FilePath("views/${table.moduleName}/${classNameVar}/${classNameVar}.data.ts")) 135 + vue3FilePath("views/${table.moduleName}/${table.businessName}/${classNameVar}.data.ts"))
124 .put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/index.vue"), 136 .put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/index.vue"),
125 - vue3FilePath("views/${table.moduleName}/${classNameVar}/index.vue")) 137 + vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
126 .put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/form.vue"), 138 .put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("views/form.vue"),
127 - vue3FilePath("views/${table.moduleName}/${classNameVar}/${simpleClassName}Modal.vue")) 139 + vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Modal.vue"))
128 .put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("api/api.ts"), 140 .put(CodegenFrontTypeEnum.VUE3_VBEN.getType(), vue3VbenTemplatePath("api/api.ts"),
129 - vue3FilePath("api/${table.moduleName}/${classNameVar}/index.ts")) 141 + vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
130 .build(); 142 .build();
131 143
132 @Resource 144 @Resource
@@ -149,7 +161,8 @@ public class CodegenEngine { @@ -149,7 +161,8 @@ public class CodegenEngine {
149 } 161 }
150 162
151 @PostConstruct 163 @PostConstruct
152 - private void initGlobalBindingMap() { 164 + @VisibleForTesting
  165 + void initGlobalBindingMap() {
153 // 全局配置 166 // 全局配置
154 globalBindingMap.put("basePackage", codegenProperties.getBasePackage()); 167 globalBindingMap.put("basePackage", codegenProperties.getBasePackage());
155 globalBindingMap.put("baseFrameworkPackage", codegenProperties.getBasePackage() 168 globalBindingMap.put("baseFrameworkPackage", codegenProperties.getBasePackage()
@@ -174,9 +187,122 @@ public class CodegenEngine { @@ -174,9 +187,122 @@ public class CodegenEngine {
174 globalBindingMap.put("DictConvertClassName", DictConvert.class.getName()); 187 globalBindingMap.put("DictConvertClassName", DictConvert.class.getName());
175 globalBindingMap.put("OperateLogClassName", OperateLog.class.getName()); 188 globalBindingMap.put("OperateLogClassName", OperateLog.class.getName());
176 globalBindingMap.put("OperateTypeEnumClassName", OperateTypeEnum.class.getName()); 189 globalBindingMap.put("OperateTypeEnumClassName", OperateTypeEnum.class.getName());
  190 + globalBindingMap.put("BeanUtils", BeanUtils.class.getName());
177 } 191 }
178 192
179 - public Map<String, String> execute(CodegenTableDO table, List<CodegenColumnDO> columns) { 193 + /**
  194 + * 生成代码
  195 + *
  196 + * @param table 表定义
  197 + * @param columns table 的字段定义数组
  198 + * @param subTables 子表数组,当且仅当主子表时使用
  199 + * @param subColumnsList subTables 的字段定义数组
  200 + * @return 生成的代码,key 是路径,value 是对应代码
  201 + */
  202 + public Map<String, String> execute(CodegenTableDO table, List<CodegenColumnDO> columns,
  203 + List<CodegenTableDO> subTables, List<List<CodegenColumnDO>> subColumnsList) {
  204 + // 1.1 初始化 bindMap 上下文
  205 + Map<String, Object> bindingMap = initBindingMap(table, columns, subTables, subColumnsList);
  206 + // 1.2 获得模版
  207 + Map<String, String> templates = getTemplates(table.getFrontType());
  208 +
  209 + // 2. 执行生成
  210 + Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(templates.size()); // 有序
  211 + templates.forEach((vmPath, filePath) -> {
  212 + // 2.1 特殊:主子表专属逻辑
  213 + if (isSubTemplate(vmPath)) {
  214 + generateSubCode(table, subTables, result, vmPath, filePath, bindingMap);
  215 + return;
  216 + // 2.2 特殊:树表专属逻辑
  217 + } else if (isPageReqVOTemplate(vmPath)) {
  218 + // 减少多余的类生成,例如说 PageVO.java 类
  219 + if (CodegenTemplateTypeEnum.isTree(table.getTemplateType())) {
  220 + return;
  221 + }
  222 + } else if (isListReqVOTemplate(vmPath)) {
  223 + // 减少多余的类生成,例如说 ListVO.java 类
  224 + if (!CodegenTemplateTypeEnum.isTree(table.getTemplateType())) {
  225 + return;
  226 + }
  227 + }
  228 + // 2.3 默认生成
  229 + generateCode(result, vmPath, filePath, bindingMap);
  230 + });
  231 + return result;
  232 + }
  233 +
  234 + private void generateCode(Map<String, String> result, String vmPath,
  235 + String filePath, Map<String, Object> bindingMap) {
  236 + filePath = formatFilePath(filePath, bindingMap);
  237 + String content = templateEngine.getTemplate(vmPath).render(bindingMap);
  238 + // 格式化代码
  239 + content = prettyCode(content);
  240 + result.put(filePath, content);
  241 + }
  242 +
  243 + private void generateSubCode(CodegenTableDO table, List<CodegenTableDO> subTables,
  244 + Map<String, String> result, String vmPath,
  245 + String filePath, Map<String, Object> bindingMap) {
  246 + // 没有子表,所以不生成
  247 + if (CollUtil.isEmpty(subTables)) {
  248 + return;
  249 + }
  250 + // 主子表的模式匹配。目的:过滤掉个性化的模版
  251 + if (vmPath.contains("_normal")
  252 + && ObjectUtil.notEqual(table.getTemplateType(), CodegenTemplateTypeEnum.MASTER_NORMAL.getType())) {
  253 + return;
  254 + }
  255 + if (vmPath.contains("_erp")
  256 + && ObjectUtil.notEqual(table.getTemplateType(), CodegenTemplateTypeEnum.MASTER_ERP.getType())) {
  257 + return;
  258 + }
  259 + if (vmPath.contains("_inner")
  260 + && ObjectUtil.notEqual(table.getTemplateType(), CodegenTemplateTypeEnum.MASTER_INNER.getType())) {
  261 + return;
  262 + }
  263 +
  264 + // 逐个生成
  265 + for (int i = 0; i < subTables.size(); i++) {
  266 + bindingMap.put("subIndex", i);
  267 + generateCode(result, vmPath, filePath, bindingMap);
  268 + }
  269 + bindingMap.remove("subIndex");
  270 + }
  271 +
  272 + /**
  273 + * 格式化生成后的代码
  274 + *
  275 + * 因为尽量让 vm 模版简单,所以统一的处理都在这个方法。
  276 + * 如果不处理,Vue 的 Pretty 格式校验可能会报错
  277 + *
  278 + * @param content 格式化前的代码
  279 + * @return 格式化后的代码
  280 + */
  281 + private String prettyCode(String content) {
  282 + // Vue 界面:去除字段后面多余的 , 逗号,解决前端的 Pretty 代码格式检查的报错
  283 + content = content.replaceAll(",\n}", "\n}").replaceAll(",\n }", "\n }");
  284 + // Vue 界面:去除多的 dateFormatter,只有一个的情况下,说明没使用到
  285 + if (StrUtil.count(content, "dateFormatter") == 1) {
  286 + content = StrUtils.removeLineContains(content, "dateFormatter");
  287 + }
  288 + // Vue 界面:去除多的 dict 相关,只有一个的情况下,说明没使用到
  289 + if (StrUtil.count(content, "getIntDictOptions") == 1) {
  290 + content = content.replace("getIntDictOptions, ", "");
  291 + }
  292 + if (StrUtil.count(content, "getStrDictOptions") == 1) {
  293 + content = content.replace("getStrDictOptions, ", "");
  294 + }
  295 + if (StrUtil.count(content, "getBoolDictOptions") == 1) {
  296 + content = content.replace("getBoolDictOptions, ", "");
  297 + }
  298 + if (StrUtil.count(content, "DICT_TYPE.") == 0) {
  299 + content = StrUtils.removeLineContains(content, "DICT_TYPE");
  300 + }
  301 + return content;
  302 + }
  303 +
  304 + private Map<String, Object> initBindingMap(CodegenTableDO table, List<CodegenColumnDO> columns,
  305 + List<CodegenTableDO> subTables, List<List<CodegenColumnDO>> subColumnsList) {
180 // 创建 bindingMap 306 // 创建 bindingMap
181 Map<String, Object> bindingMap = new HashMap<>(globalBindingMap); 307 Map<String, Object> bindingMap = new HashMap<>(globalBindingMap);
182 bindingMap.put("table", table); 308 bindingMap.put("table", table);
@@ -196,17 +322,54 @@ public class CodegenEngine { @@ -196,17 +322,54 @@ public class CodegenEngine {
196 // permission 前缀 322 // permission 前缀
197 bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase); 323 bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase);
198 324
199 - // 执行生成  
200 - Map<String, String> templates = getTemplates(table.getFrontType());  
201 - Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(templates.size()); // 有序  
202 - templates.forEach((vmPath, filePath) -> {  
203 - filePath = formatFilePath(filePath, bindingMap);  
204 - String content = templateEngine.getTemplate(vmPath).render(bindingMap);  
205 - // 去除字段后面多余的 , 逗号  
206 - content = content.replaceAll(",\n}", "\n}").replaceAll(",\n }", "\n }");  
207 - result.put(filePath, content);  
208 - });  
209 - return result; 325 + // 特殊:树表专属逻辑
  326 + if (CodegenTemplateTypeEnum.isTree(table.getTemplateType())) {
  327 + CodegenColumnDO treeParentColumn = CollUtil.findOne(columns,
  328 + column -> Objects.equals(column.getId(), table.getTreeParentColumnId()));
  329 + bindingMap.put("treeParentColumn", treeParentColumn);
  330 + bindingMap.put("treeParentColumn_javaField_underlineCase", toUnderlineCase(treeParentColumn.getJavaField()));
  331 + CodegenColumnDO treeNameColumn = CollUtil.findOne(columns,
  332 + column -> Objects.equals(column.getId(), table.getTreeNameColumnId()));
  333 + bindingMap.put("treeNameColumn", treeNameColumn);
  334 + bindingMap.put("treeNameColumn_javaField_underlineCase", toUnderlineCase(treeNameColumn.getJavaField()));
  335 + }
  336 +
  337 + // 特殊:主子表专属逻辑
  338 + if (CollUtil.isNotEmpty(subTables)) {
  339 + // 创建 bindingMap
  340 + bindingMap.put("subTables", subTables);
  341 + bindingMap.put("subColumnsList", subColumnsList);
  342 + List<CodegenColumnDO> subPrimaryColumns = new ArrayList<>();
  343 + List<CodegenColumnDO> subJoinColumns = new ArrayList<>();
  344 + List<String> subJoinColumnStrikeCases = new ArrayList<>();
  345 + List<String> subSimpleClassNames = new ArrayList<>();
  346 + List<String> subClassNameVars = new ArrayList<>();
  347 + List<String> simpleClassNameUnderlineCases = new ArrayList<>();
  348 + List<String> subSimpleClassNameStrikeCases = new ArrayList<>();
  349 + for (int i = 0; i < subTables.size(); i++) {
  350 + CodegenTableDO subTable = subTables.get(i);
  351 + List<CodegenColumnDO> subColumns = subColumnsList.get(i);
  352 + subPrimaryColumns.add(CollectionUtils.findFirst(subColumns, CodegenColumnDO::getPrimaryKey)); //
  353 + CodegenColumnDO subColumn = CollectionUtils.findFirst(subColumns, // 关联的字段
  354 + column -> Objects.equals(column.getId(), subTable.getSubJoinColumnId()));
  355 + subJoinColumns.add(subColumn);
  356 + subJoinColumnStrikeCases.add(toSymbolCase(subColumn.getJavaField(), '-')); // 将 DictType 转换成 dict-type
  357 + // className 相关
  358 + String subSimpleClassName = removePrefix(subTable.getClassName(), upperFirst(subTable.getModuleName()));
  359 + subSimpleClassNames.add(subSimpleClassName);
  360 + simpleClassNameUnderlineCases.add(toUnderlineCase(subSimpleClassName)); // 将 DictType 转换成 dict_type
  361 + subClassNameVars.add(lowerFirst(subSimpleClassName)); // 将 DictType 转换成 dictType,用于变量
  362 + subSimpleClassNameStrikeCases.add(toSymbolCase(subSimpleClassName, '-')); // 将 DictType 转换成 dict-type
  363 + }
  364 + bindingMap.put("subPrimaryColumns", subPrimaryColumns);
  365 + bindingMap.put("subJoinColumns", subJoinColumns);
  366 + bindingMap.put("subJoinColumn_strikeCases", subJoinColumnStrikeCases);
  367 + bindingMap.put("subSimpleClassNames", subSimpleClassNames);
  368 + bindingMap.put("simpleClassNameUnderlineCases", simpleClassNameUnderlineCases);
  369 + bindingMap.put("subClassNameVars", subClassNameVars);
  370 + bindingMap.put("subSimpleClassName_strikeCases", subSimpleClassNameStrikeCases);
  371 + }
  372 + return bindingMap;
210 } 373 }
211 374
212 private Map<String, String> getTemplates(Integer frontType) { 375 private Map<String, String> getTemplates(Integer frontType) {
@@ -216,6 +379,7 @@ public class CodegenEngine { @@ -216,6 +379,7 @@ public class CodegenEngine {
216 return templates; 379 return templates;
217 } 380 }
218 381
  382 + @SuppressWarnings("unchecked")
219 private String formatFilePath(String filePath, Map<String, Object> bindingMap) { 383 private String formatFilePath(String filePath, Map<String, Object> bindingMap) {
220 filePath = StrUtil.replace(filePath, "${basePackage}", 384 filePath = StrUtil.replace(filePath, "${basePackage}",
221 getStr(bindingMap, "basePackage").replaceAll("\\.", "/")); 385 getStr(bindingMap, "basePackage").replaceAll("\\.", "/"));
@@ -232,6 +396,16 @@ public class CodegenEngine { @@ -232,6 +396,16 @@ public class CodegenEngine {
232 filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName()); 396 filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName());
233 filePath = StrUtil.replace(filePath, "${table.businessName}", table.getBusinessName()); 397 filePath = StrUtil.replace(filePath, "${table.businessName}", table.getBusinessName());
234 filePath = StrUtil.replace(filePath, "${table.className}", table.getClassName()); 398 filePath = StrUtil.replace(filePath, "${table.className}", table.getClassName());
  399 + // 特殊:主子表专属逻辑
  400 + Integer subIndex = (Integer) bindingMap.get("subIndex");
  401 + if (subIndex != null) {
  402 + CodegenTableDO subTable = ((List<CodegenTableDO>) bindingMap.get("subTables")).get(subIndex);
  403 + filePath = StrUtil.replace(filePath, "${subTable.moduleName}", subTable.getModuleName());
  404 + filePath = StrUtil.replace(filePath, "${subTable.businessName}", subTable.getBusinessName());
  405 + filePath = StrUtil.replace(filePath, "${subTable.className}", subTable.getClassName());
  406 + filePath = StrUtil.replace(filePath, "${subSimpleClassName}",
  407 + ((List<String>) bindingMap.get("subSimpleClassNames")).get(subIndex));
  408 + }
235 return filePath; 409 return filePath;
236 } 410 }
237 411
@@ -298,4 +472,17 @@ public class CodegenEngine { @@ -298,4 +472,17 @@ public class CodegenEngine {
298 private static String vue3VbenTemplatePath(String path) { 472 private static String vue3VbenTemplatePath(String path) {
299 return "codegen/vue3_vben/" + path + ".vm"; 473 return "codegen/vue3_vben/" + path + ".vm";
300 } 474 }
  475 +
  476 + private static boolean isSubTemplate(String path) {
  477 + return path.contains("_sub");
  478 + }
  479 +
  480 + private static boolean isPageReqVOTemplate(String path) {
  481 + return path.contains("pageReqVO");
  482 + }
  483 +
  484 + private static boolean isListReqVOTemplate(String path) {
  485 + return path.contains("listReqVO");
  486 + }
  487 +
301 } 488 }
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo.demo01;
  2 +
  3 +import javax.validation.*;
  4 +
  5 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
  6 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
  7 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
  8 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  9 +
  10 +/**
  11 + * 示例联系人 Service 接口
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +public interface Demo01ContactService {
  16 +
  17 + /**
  18 + * 创建示例联系人
  19 + *
  20 + * @param createReqVO 创建信息
  21 + * @return 编号
  22 + */
  23 + Long createDemo01Contact(@Valid Demo01ContactSaveReqVO createReqVO);
  24 +
  25 + /**
  26 + * 更新示例联系人
  27 + *
  28 + * @param updateReqVO 更新信息
  29 + */
  30 + void updateDemo01Contact(@Valid Demo01ContactSaveReqVO updateReqVO);
  31 +
  32 + /**
  33 + * 删除示例联系人
  34 + *
  35 + * @param id 编号
  36 + */
  37 + void deleteDemo01Contact(Long id);
  38 +
  39 + /**
  40 + * 获得示例联系人
  41 + *
  42 + * @param id 编号
  43 + * @return 示例联系人
  44 + */
  45 + Demo01ContactDO getDemo01Contact(Long id);
  46 +
  47 + /**
  48 + * 获得示例联系人分页
  49 + *
  50 + * @param pageReqVO 分页查询
  51 + * @return 示例联系人分页
  52 + */
  53 + PageResult<Demo01ContactDO> getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO);
  54 +
  55 +}
0 \ No newline at end of file 56 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo.demo01;
  2 +
  3 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
  4 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
  5 +import org.springframework.stereotype.Service;
  6 +import javax.annotation.Resource;
  7 +import org.springframework.validation.annotation.Validated;
  8 +
  9 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
  10 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  11 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  12 +
  13 +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo01.Demo01ContactMapper;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  16 +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
  17 +
  18 +/**
  19 + * 示例联系人 Service 实现类
  20 + *
  21 + * @author 芋道源码
  22 + */
  23 +@Service
  24 +@Validated
  25 +public class Demo01ContactServiceImpl implements Demo01ContactService {
  26 +
  27 + @Resource
  28 + private Demo01ContactMapper demo01ContactMapper;
  29 +
  30 + @Override
  31 + public Long createDemo01Contact(Demo01ContactSaveReqVO createReqVO) {
  32 + // 插入
  33 + Demo01ContactDO demo01Contact = BeanUtils.toBean(createReqVO, Demo01ContactDO.class);
  34 + demo01ContactMapper.insert(demo01Contact);
  35 + // 返回
  36 + return demo01Contact.getId();
  37 + }
  38 +
  39 + @Override
  40 + public void updateDemo01Contact(Demo01ContactSaveReqVO updateReqVO) {
  41 + // 校验存在
  42 + validateDemo01ContactExists(updateReqVO.getId());
  43 + // 更新
  44 + Demo01ContactDO updateObj = BeanUtils.toBean(updateReqVO, Demo01ContactDO.class);
  45 + demo01ContactMapper.updateById(updateObj);
  46 + }
  47 +
  48 + @Override
  49 + public void deleteDemo01Contact(Long id) {
  50 + // 校验存在
  51 + validateDemo01ContactExists(id);
  52 + // 删除
  53 + demo01ContactMapper.deleteById(id);
  54 + }
  55 +
  56 + private void validateDemo01ContactExists(Long id) {
  57 + if (demo01ContactMapper.selectById(id) == null) {
  58 + throw exception(DEMO01_CONTACT_NOT_EXISTS);
  59 + }
  60 + }
  61 +
  62 + @Override
  63 + public Demo01ContactDO getDemo01Contact(Long id) {
  64 + return demo01ContactMapper.selectById(id);
  65 + }
  66 +
  67 + @Override
  68 + public PageResult<Demo01ContactDO> getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO) {
  69 + return demo01ContactMapper.selectPage(pageReqVO);
  70 + }
  71 +
  72 +}
0 \ No newline at end of file 73 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo02/Demo02CategoryService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo.demo02;
  2 +
  3 +import java.util.*;
  4 +import javax.validation.*;
  5 +
  6 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
  7 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
  8 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
  9 +
  10 +/**
  11 + * 示例分类 Service 接口
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +public interface Demo02CategoryService {
  16 +
  17 + /**
  18 + * 创建示例分类
  19 + *
  20 + * @param createReqVO 创建信息
  21 + * @return 编号
  22 + */
  23 + Long createDemo02Category(@Valid Demo02CategorySaveReqVO createReqVO);
  24 +
  25 + /**
  26 + * 更新示例分类
  27 + *
  28 + * @param updateReqVO 更新信息
  29 + */
  30 + void updateDemo02Category(@Valid Demo02CategorySaveReqVO updateReqVO);
  31 +
  32 + /**
  33 + * 删除示例分类
  34 + *
  35 + * @param id 编号
  36 + */
  37 + void deleteDemo02Category(Long id);
  38 +
  39 + /**
  40 + * 获得示例分类
  41 + *
  42 + * @param id 编号
  43 + * @return 示例分类
  44 + */
  45 + Demo02CategoryDO getDemo02Category(Long id);
  46 +
  47 + /**
  48 + * 获得示例分类列表
  49 + *
  50 + * @param listReqVO 查询条件
  51 + * @return 示例分类列表
  52 + */
  53 + List<Demo02CategoryDO> getDemo02CategoryList(Demo02CategoryListReqVO listReqVO);
  54 +
  55 +}
0 \ No newline at end of file 56 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo02/Demo02CategoryServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo.demo02;
  2 +
  3 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  4 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
  5 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
  6 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
  7 +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo02.Demo02CategoryMapper;
  8 +import org.springframework.stereotype.Service;
  9 +import org.springframework.validation.annotation.Validated;
  10 +
  11 +import javax.annotation.Resource;
  12 +import java.util.List;
  13 +import java.util.Objects;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  16 +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
  17 +
  18 +/**
  19 + * 示例分类 Service 实现类
  20 + *
  21 + * @author 芋道源码
  22 + */
  23 +@Service
  24 +@Validated
  25 +public class Demo02CategoryServiceImpl implements Demo02CategoryService {
  26 +
  27 + @Resource
  28 + private Demo02CategoryMapper demo02CategoryMapper;
  29 +
  30 + @Override
  31 + public Long createDemo02Category(Demo02CategorySaveReqVO createReqVO) {
  32 + // 校验父级编号的有效性
  33 + validateParentDemo02Category(null, createReqVO.getParentId());
  34 + // 校验名字的唯一性
  35 + validateDemo02CategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
  36 +
  37 + // 插入
  38 + Demo02CategoryDO demo02Category = BeanUtils.toBean(createReqVO, Demo02CategoryDO.class);
  39 + demo02CategoryMapper.insert(demo02Category);
  40 + // 返回
  41 + return demo02Category.getId();
  42 + }
  43 +
  44 + @Override
  45 + public void updateDemo02Category(Demo02CategorySaveReqVO updateReqVO) {
  46 + // 校验存在
  47 + validateDemo02CategoryExists(updateReqVO.getId());
  48 + // 校验父级编号的有效性
  49 + validateParentDemo02Category(updateReqVO.getId(), updateReqVO.getParentId());
  50 + // 校验名字的唯一性
  51 + validateDemo02CategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
  52 +
  53 + // 更新
  54 + Demo02CategoryDO updateObj = BeanUtils.toBean(updateReqVO, Demo02CategoryDO.class);
  55 + demo02CategoryMapper.updateById(updateObj);
  56 + }
  57 +
  58 + @Override
  59 + public void deleteDemo02Category(Long id) {
  60 + // 校验存在
  61 + validateDemo02CategoryExists(id);
  62 + // 校验是否有子示例分类
  63 + if (demo02CategoryMapper.selectCountByParentId(id) > 0) {
  64 + throw exception(DEMO02_CATEGORY_EXITS_CHILDREN);
  65 + }
  66 + // 删除
  67 + demo02CategoryMapper.deleteById(id);
  68 + }
  69 +
  70 + private void validateDemo02CategoryExists(Long id) {
  71 + if (demo02CategoryMapper.selectById(id) == null) {
  72 + throw exception(DEMO02_CATEGORY_NOT_EXISTS);
  73 + }
  74 + }
  75 +
  76 + private void validateParentDemo02Category(Long id, Long parentId) {
  77 + if (parentId == null || Demo02CategoryDO.PARENT_ID_ROOT.equals(parentId)) {
  78 + return;
  79 + }
  80 + // 1. 不能设置自己为父示例分类
  81 + if (Objects.equals(id, parentId)) {
  82 + throw exception(DEMO02_CATEGORY_PARENT_ERROR);
  83 + }
  84 + // 2. 父示例分类不存在
  85 + Demo02CategoryDO parentDemo02Category = demo02CategoryMapper.selectById(parentId);
  86 + if (parentDemo02Category == null) {
  87 + throw exception(DEMO02_CATEGORY_PARENT_NOT_EXITS);
  88 + }
  89 + // 3. 递归校验父示例分类,如果父示例分类是自己的子示例分类,则报错,避免形成环路
  90 + if (id == null) { // id 为空,说明新增,不需要考虑环路
  91 + return;
  92 + }
  93 + for (int i = 0; i < Short.MAX_VALUE; i++) {
  94 + // 3.1 校验环路
  95 + parentId = parentDemo02Category.getParentId();
  96 + if (Objects.equals(id, parentId)) {
  97 + throw exception(DEMO02_CATEGORY_PARENT_IS_CHILD);
  98 + }
  99 + // 3.2 继续递归下一级父示例分类
  100 + if (parentId == null || Demo02CategoryDO.PARENT_ID_ROOT.equals(parentId)) {
  101 + break;
  102 + }
  103 + parentDemo02Category = demo02CategoryMapper.selectById(parentId);
  104 + if (parentDemo02Category == null) {
  105 + break;
  106 + }
  107 + }
  108 + }
  109 +
  110 + private void validateDemo02CategoryNameUnique(Long id, Long parentId, String name) {
  111 + Demo02CategoryDO demo02Category = demo02CategoryMapper.selectByParentIdAndName(parentId, name);
  112 + if (demo02Category == null) {
  113 + return;
  114 + }
  115 + // 如果 id 为空,说明不用比较是否为相同 id 的示例分类
  116 + if (id == null) {
  117 + throw exception(DEMO02_CATEGORY_NAME_DUPLICATE);
  118 + }
  119 + if (!Objects.equals(demo02Category.getId(), id)) {
  120 + throw exception(DEMO02_CATEGORY_NAME_DUPLICATE);
  121 + }
  122 + }
  123 +
  124 + @Override
  125 + public Demo02CategoryDO getDemo02Category(Long id) {
  126 + return demo02CategoryMapper.selectById(id);
  127 + }
  128 +
  129 + @Override
  130 + public List<Demo02CategoryDO> getDemo02CategoryList(Demo02CategoryListReqVO listReqVO) {
  131 + return demo02CategoryMapper.selectList(listReqVO);
  132 + }
  133 +
  134 +}
0 \ No newline at end of file 135 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/Demo03StudentService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo.demo03;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
  6 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
  7 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
  8 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
  9 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
  10 +
  11 +import javax.validation.Valid;
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * 学生 Service 接口
  16 + *
  17 + * @author 芋道源码
  18 + */
  19 +public interface Demo03StudentService {
  20 +
  21 + /**
  22 + * 创建学生
  23 + *
  24 + * @param createReqVO 创建信息
  25 + * @return 编号
  26 + */
  27 + Long createDemo03Student(@Valid Demo03StudentSaveReqVO createReqVO);
  28 +
  29 + /**
  30 + * 更新学生
  31 + *
  32 + * @param updateReqVO 更新信息
  33 + */
  34 + void updateDemo03Student(@Valid Demo03StudentSaveReqVO updateReqVO);
  35 +
  36 + /**
  37 + * 删除学生
  38 + *
  39 + * @param id 编号
  40 + */
  41 + void deleteDemo03Student(Long id);
  42 +
  43 + /**
  44 + * 获得学生
  45 + *
  46 + * @param id 编号
  47 + * @return 学生
  48 + */
  49 + Demo03StudentDO getDemo03Student(Long id);
  50 +
  51 + /**
  52 + * 获得学生分页
  53 + *
  54 + * @param pageReqVO 分页查询
  55 + * @return 学生分页
  56 + */
  57 + PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO);
  58 +
  59 +
  60 + // ==================== 子表(学生课程) ====================
  61 +
  62 + /**
  63 + * 获得学生课程列表
  64 + *
  65 + * @param studentId 学生编号
  66 + * @return 学生课程列表
  67 + */
  68 + List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId);
  69 +
  70 + /**
  71 + * 获得学生课程分页
  72 + *
  73 + * @param pageReqVO 分页查询
  74 + * @param studentId 学生编号
  75 + * @return 学生课程分页
  76 + */
  77 + PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId);
  78 +
  79 + /**
  80 + * 创建学生课程
  81 + *
  82 + * @param demo03Course 创建信息
  83 + * @return 编号
  84 + */
  85 + Long createDemo03Course(@Valid Demo03CourseDO demo03Course);
  86 +
  87 + /**
  88 + * 更新学生课程
  89 + *
  90 + * @param demo03Course 更新信息
  91 + */
  92 + void updateDemo03Course(@Valid Demo03CourseDO demo03Course);
  93 +
  94 + /**
  95 + * 删除学生课程
  96 + *
  97 + * @param id 编号
  98 + */
  99 + void deleteDemo03Course(Long id);
  100 +
  101 + /**
  102 + * 获得学生课程
  103 + *
  104 + * @param id 编号
  105 + * @return 学生课程
  106 + */
  107 + Demo03CourseDO getDemo03Course(Long id);
  108 +
  109 + // ==================== 子表(学生班级) ====================
  110 +
  111 + /**
  112 + * 获得学生班级
  113 + *
  114 + * @param studentId 学生编号
  115 + * @return 学生班级
  116 + */
  117 + Demo03GradeDO getDemo03GradeByStudentId(Long studentId);
  118 +
  119 + /**
  120 + * 获得学生班级分页
  121 + *
  122 + * @param pageReqVO 分页查询
  123 + * @param studentId 学生编号
  124 + * @return 学生班级分页
  125 + */
  126 + PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId);
  127 +
  128 + /**
  129 + * 创建学生班级
  130 + *
  131 + * @param demo03Grade 创建信息
  132 + * @return 编号
  133 + */
  134 + Long createDemo03Grade(@Valid Demo03GradeDO demo03Grade);
  135 +
  136 + /**
  137 + * 更新学生班级
  138 + *
  139 + * @param demo03Grade 更新信息
  140 + */
  141 + void updateDemo03Grade(@Valid Demo03GradeDO demo03Grade);
  142 +
  143 + /**
  144 + * 删除学生班级
  145 + *
  146 + * @param id 编号
  147 + */
  148 + void deleteDemo03Grade(Long id);
  149 +
  150 + /**
  151 + * 获得学生班级
  152 + *
  153 + * @param id 编号
  154 + * @return 学生班级
  155 + */
  156 + Demo03GradeDO getDemo03Grade(Long id);
  157 +
  158 +}
0 \ No newline at end of file 159 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo03/Demo03StudentServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo.demo03;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentPageReqVO;
  7 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo03.vo.Demo03StudentSaveReqVO;
  8 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
  9 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
  10 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
  11 +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03CourseMapper;
  12 +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03GradeMapper;
  13 +import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo03.Demo03StudentMapper;
  14 +import org.springframework.stereotype.Service;
  15 +import org.springframework.transaction.annotation.Transactional;
  16 +import org.springframework.validation.annotation.Validated;
  17 +
  18 +import javax.annotation.Resource;
  19 +import java.util.List;
  20 +
  21 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  22 +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
  23 +
  24 +/**
  25 + * 学生 Service 实现类
  26 + *
  27 + * @author 芋道源码
  28 + */
  29 +@Service
  30 +@Validated
  31 +public class Demo03StudentServiceImpl implements Demo03StudentService {
  32 +
  33 + @Resource
  34 + private Demo03StudentMapper demo03StudentMapper;
  35 + @Resource
  36 + private Demo03CourseMapper demo03CourseMapper;
  37 + @Resource
  38 + private Demo03GradeMapper demo03GradeMapper;
  39 +
  40 + @Override
  41 + @Transactional(rollbackFor = Exception.class)
  42 + public Long createDemo03Student(Demo03StudentSaveReqVO createReqVO) {
  43 + // 插入
  44 + Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
  45 + demo03StudentMapper.insert(demo03Student);
  46 +
  47 + // 插入子表
  48 + createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses());
  49 + createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade());
  50 + // 返回
  51 + return demo03Student.getId();
  52 + }
  53 +
  54 + @Override
  55 + @Transactional(rollbackFor = Exception.class)
  56 + public void updateDemo03Student(Demo03StudentSaveReqVO updateReqVO) {
  57 + // 校验存在
  58 + validateDemo03StudentExists(updateReqVO.getId());
  59 + // 更新
  60 + Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
  61 + demo03StudentMapper.updateById(updateObj);
  62 +
  63 + // 更新子表
  64 + updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses());
  65 + updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade());
  66 + }
  67 +
  68 + @Override
  69 + @Transactional(rollbackFor = Exception.class)
  70 + public void deleteDemo03Student(Long id) {
  71 + // 校验存在
  72 + validateDemo03StudentExists(id);
  73 + // 删除
  74 + demo03StudentMapper.deleteById(id);
  75 +
  76 + // 删除子表
  77 + deleteDemo03CourseByStudentId(id);
  78 + deleteDemo03GradeByStudentId(id);
  79 + }
  80 +
  81 + private void validateDemo03StudentExists(Long id) {
  82 + if (demo03StudentMapper.selectById(id) == null) {
  83 + throw exception(DEMO03_STUDENT_NOT_EXISTS);
  84 + }
  85 + }
  86 +
  87 + @Override
  88 + public Demo03StudentDO getDemo03Student(Long id) {
  89 + return demo03StudentMapper.selectById(id);
  90 + }
  91 +
  92 + @Override
  93 + public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentPageReqVO pageReqVO) {
  94 + return demo03StudentMapper.selectPage(pageReqVO);
  95 + }
  96 +
  97 + // ==================== 子表(学生课程) ====================
  98 +
  99 + @Override
  100 + public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) {
  101 + return demo03CourseMapper.selectListByStudentId(studentId);
  102 + }
  103 +
  104 + private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
  105 + if (list != null) {
  106 + list.forEach(o -> o.setStudentId(studentId));
  107 + }
  108 + demo03CourseMapper.insertBatch(list);
  109 + }
  110 +
  111 + private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
  112 + deleteDemo03CourseByStudentId(studentId);
  113 + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
  114 + createDemo03CourseList(studentId, list);
  115 + }
  116 +
  117 + private void deleteDemo03CourseByStudentId(Long studentId) {
  118 + demo03CourseMapper.deleteByStudentId(studentId);
  119 + }
  120 +
  121 + @Override
  122 + public PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId) {
  123 + return demo03CourseMapper.selectPage(pageReqVO, studentId);
  124 + }
  125 +
  126 + @Override
  127 + public Long createDemo03Course(Demo03CourseDO demo03Course) {
  128 + demo03CourseMapper.insert(demo03Course);
  129 + return demo03Course.getId();
  130 + }
  131 +
  132 + @Override
  133 + public void updateDemo03Course(Demo03CourseDO demo03Course) {
  134 + demo03CourseMapper.updateById(demo03Course);
  135 + }
  136 +
  137 + @Override
  138 + public void deleteDemo03Course(Long id) {
  139 + demo03CourseMapper.deleteById(id);
  140 + }
  141 +
  142 + @Override
  143 + public Demo03CourseDO getDemo03Course(Long id) {
  144 + return demo03CourseMapper.selectById(id);
  145 + }
  146 +
  147 + // ==================== 子表(学生班级) ====================
  148 +
  149 + @Override
  150 + public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) {
  151 + return demo03GradeMapper.selectByStudentId(studentId);
  152 + }
  153 +
  154 + private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
  155 + if (demo03Grade == null) {
  156 + return;
  157 + }
  158 + demo03Grade.setStudentId(studentId);
  159 + demo03GradeMapper.insert(demo03Grade);
  160 + }
  161 +
  162 + private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
  163 + if (demo03Grade == null) {
  164 + return;
  165 + }
  166 + demo03Grade.setStudentId(studentId);
  167 + demo03Grade.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新
  168 + demo03GradeMapper.insertOrUpdate(demo03Grade);
  169 + }
  170 +
  171 + private void deleteDemo03GradeByStudentId(Long studentId) {
  172 + demo03GradeMapper.deleteByStudentId(studentId);
  173 + }
  174 +
  175 + @Override
  176 + public PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId) {
  177 + return demo03GradeMapper.selectPage(pageReqVO, studentId);
  178 + }
  179 +
  180 + @Override
  181 + public Long createDemo03Grade(Demo03GradeDO demo03Grade) {
  182 + // 校验是否已经存在
  183 + if (demo03GradeMapper.selectByStudentId(demo03Grade.getStudentId()) != null) {
  184 + throw exception(DEMO03_GRADE_EXISTS);
  185 + }
  186 + demo03GradeMapper.insert(demo03Grade);
  187 + return demo03Grade.getId();
  188 + }
  189 +
  190 + @Override
  191 + public void updateDemo03Grade(Demo03GradeDO demo03Grade) {
  192 + // 校验存在
  193 + validateDemo03GradeExists(demo03Grade.getId());
  194 + // 更新
  195 + demo03GradeMapper.updateById(demo03Grade);
  196 + }
  197 +
  198 + @Override
  199 + public void deleteDemo03Grade(Long id) {
  200 + // 校验存在
  201 + validateDemo03GradeExists(id);
  202 + // 删除
  203 + demo03GradeMapper.deleteById(id);
  204 + }
  205 +
  206 + @Override
  207 + public Demo03GradeDO getDemo03Grade(Long id) {
  208 + return demo03GradeMapper.selectById(id);
  209 + }
  210 +
  211 + private void validateDemo03GradeExists(Long id) {
  212 + if (demo03GradeMapper.selectById(id) == null) {
  213 + throw exception(DEMO03_GRADE_NOT_EXISTS);
  214 + }
  215 + }
  216 +
  217 +}
0 \ No newline at end of file 218 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImpl.java deleted
1 -package cn.iocoder.yudao.module.infra.service.test;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
4 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoCreateReqVO;  
5 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoExportReqVO;  
6 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoPageReqVO;  
7 -import cn.iocoder.yudao.module.infra.controller.admin.test.vo.TestDemoUpdateReqVO;  
8 -import cn.iocoder.yudao.module.infra.convert.test.TestDemoConvert;  
9 -import cn.iocoder.yudao.module.infra.dal.dataobject.test.TestDemoDO;  
10 -import cn.iocoder.yudao.module.infra.dal.mysql.test.TestDemoMapper;  
11 -import org.springframework.cache.annotation.CacheEvict;  
12 -import org.springframework.cache.annotation.Cacheable;  
13 -import org.springframework.stereotype.Service;  
14 -import org.springframework.validation.annotation.Validated;  
15 -  
16 -import javax.annotation.Resource;  
17 -import java.util.Collection;  
18 -import java.util.List;  
19 -  
20 -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;  
21 -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.TEST_DEMO_NOT_EXISTS;  
22 -  
23 -/**  
24 - * 字典类型 Service 实现类  
25 - *  
26 - * @author 芋道源码  
27 - */  
28 -@Service  
29 -@Validated  
30 -public class TestDemoServiceImpl implements TestDemoService {  
31 -  
32 - @Resource  
33 - private TestDemoMapper testDemoMapper;  
34 -  
35 - @Override  
36 - public Long createTestDemo(TestDemoCreateReqVO createReqVO) {  
37 - // 插入  
38 - TestDemoDO testDemo = TestDemoConvert.INSTANCE.convert(createReqVO);  
39 - testDemoMapper.insert(testDemo);  
40 - // 返回  
41 - return testDemo.getId();  
42 - }  
43 -  
44 - @Override  
45 - @CacheEvict(value = "test", key = "#updateReqVO.id")  
46 - public void updateTestDemo(TestDemoUpdateReqVO updateReqVO) {  
47 - // 校验存在  
48 - validateTestDemoExists(updateReqVO.getId());  
49 - // 更新  
50 - TestDemoDO updateObj = TestDemoConvert.INSTANCE.convert(updateReqVO);  
51 - testDemoMapper.updateById(updateObj);  
52 - }  
53 -  
54 - @Override  
55 - @CacheEvict(value = "test", key = "#id")  
56 - public void deleteTestDemo(Long id) {  
57 - // 校验存在  
58 - validateTestDemoExists(id);  
59 - // 删除  
60 - testDemoMapper.deleteById(id);  
61 - }  
62 -  
63 - private void validateTestDemoExists(Long id) {  
64 - if (testDemoMapper.selectById(id) == null) {  
65 - throw exception(TEST_DEMO_NOT_EXISTS);  
66 - }  
67 - }  
68 -  
69 - @Override  
70 - @Cacheable(cacheNames = "test", key = "#id")  
71 - public TestDemoDO getTestDemo(Long id) {  
72 - return testDemoMapper.selectById(id);  
73 - }  
74 -  
75 - @Override  
76 - public List<TestDemoDO> getTestDemoList(Collection<Long> ids) {  
77 - return testDemoMapper.selectBatchIds(ids);  
78 - }  
79 -  
80 - @Override  
81 - public PageResult<TestDemoDO> getTestDemoPage(TestDemoPageReqVO pageReqVO) {  
82 -// testDemoMapper.selectList2();  
83 - return testDemoMapper.selectPage(pageReqVO);  
84 - }  
85 -  
86 - @Override  
87 - public List<TestDemoDO> getTestDemoList(TestDemoExportReqVO exportReqVO) {  
88 - return testDemoMapper.selectList(exportReqVO);  
89 - }  
90 -  
91 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm
@@ -15,8 +15,10 @@ import javax.servlet.http.*; @@ -15,8 +15,10 @@ import javax.servlet.http.*;
15 import java.util.*; 15 import java.util.*;
16 import java.io.IOException; 16 import java.io.IOException;
17 17
  18 +import ${PageParamClassName};
18 import ${PageResultClassName}; 19 import ${PageResultClassName};
19 import ${CommonResultClassName}; 20 import ${CommonResultClassName};
  21 +import ${BeanUtils};
20 import static ${CommonResultClassName}.success; 22 import static ${CommonResultClassName}.success;
21 23
22 import ${ExcelUtilsClassName}; 24 import ${ExcelUtilsClassName};
@@ -26,7 +28,10 @@ import static ${OperateTypeEnumClassName}.*; @@ -26,7 +28,10 @@ import static ${OperateTypeEnumClassName}.*;
26 28
27 import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; 29 import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*;
28 import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; 30 import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
29 -import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; 31 +## 特殊:主子表专属逻辑
  32 +#foreach ($subTable in $subTables)
  33 +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO;
  34 +#end
30 import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service; 35 import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service;
31 36
32 @Tag(name = "${sceneEnum.name} - ${table.classComment}") 37 @Tag(name = "${sceneEnum.name} - ${table.classComment}")
@@ -41,17 +46,19 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { @@ -41,17 +46,19 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
41 46
42 @PostMapping("/create") 47 @PostMapping("/create")
43 @Operation(summary = "创建${table.classComment}") 48 @Operation(summary = "创建${table.classComment}")
44 -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")#end  
45 -  
46 - public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}CreateReqVO createReqVO) { 49 +#if ($sceneEnum.scene == 1)
  50 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")
  51 +#end
  52 + public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO) {
47 return success(${classNameVar}Service.create${simpleClassName}(createReqVO)); 53 return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
48 } 54 }
49 55
50 @PutMapping("/update") 56 @PutMapping("/update")
51 @Operation(summary = "更新${table.classComment}") 57 @Operation(summary = "更新${table.classComment}")
52 -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")#end  
53 -  
54 - public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO) { 58 +#if ($sceneEnum.scene == 1)
  59 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")
  60 +#end
  61 + public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO) {
55 ${classNameVar}Service.update${simpleClassName}(updateReqVO); 62 ${classNameVar}Service.update${simpleClassName}(updateReqVO);
56 return success(true); 63 return success(true);
57 } 64 }
@@ -59,8 +66,9 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { @@ -59,8 +66,9 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
59 @DeleteMapping("/delete") 66 @DeleteMapping("/delete")
60 @Operation(summary = "删除${table.classComment}") 67 @Operation(summary = "删除${table.classComment}")
61 @Parameter(name = "id", description = "编号", required = true) 68 @Parameter(name = "id", description = "编号", required = true)
62 -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")#end  
63 - 69 +#if ($sceneEnum.scene == 1)
  70 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
  71 +#end
64 public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { 72 public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
65 ${classNameVar}Service.delete${simpleClassName}(id); 73 ${classNameVar}Service.delete${simpleClassName}(id);
66 return success(true); 74 return success(true);
@@ -69,43 +77,157 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { @@ -69,43 +77,157 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
69 @GetMapping("/get") 77 @GetMapping("/get")
70 @Operation(summary = "获得${table.classComment}") 78 @Operation(summary = "获得${table.classComment}")
71 @Parameter(name = "id", description = "编号", required = true, example = "1024") 79 @Parameter(name = "id", description = "编号", required = true, example = "1024")
72 -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end  
73 - 80 +#if ($sceneEnum.scene == 1)
  81 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
  82 +#end
74 public CommonResult<${sceneEnum.prefixClass}${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { 83 public CommonResult<${sceneEnum.prefixClass}${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
75 ${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id); 84 ${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
76 - return success(${table.className}Convert.INSTANCE.convert(${classNameVar}));  
77 - }  
78 -  
79 - @GetMapping("/list")  
80 - @Operation(summary = "获得${table.classComment}列表")  
81 - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")  
82 -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end  
83 -  
84 - public CommonResult<List<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) {  
85 - List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids);  
86 - return success(${table.className}Convert.INSTANCE.convertList(list)); 85 + return success(BeanUtils.toBean(${classNameVar}, ${sceneEnum.prefixClass}${table.className}RespVO.class));
87 } 86 }
88 87
  88 +#if ( $table.templateType != 2 )
89 @GetMapping("/page") 89 @GetMapping("/page")
90 @Operation(summary = "获得${table.classComment}分页") 90 @Operation(summary = "获得${table.classComment}分页")
91 -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end 91 +#if ($sceneEnum.scene == 1)
  92 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
  93 +#end
  94 + public CommonResult<PageResult<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}Page(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO) {
  95 + PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageReqVO);
  96 + return success(BeanUtils.toBean(pageResult, ${sceneEnum.prefixClass}${table.className}RespVO.class));
  97 + }
92 98
93 - public CommonResult<PageResult<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}Page(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageVO) {  
94 - PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO);  
95 - return success(${table.className}Convert.INSTANCE.convertPage(pageResult)); 99 +## 特殊:树表专属逻辑(树不需要分页接口)
  100 +#else
  101 + @GetMapping("/list")
  102 + @Operation(summary = "获得${table.classComment}列表")
  103 +#if ($sceneEnum.scene == 1)
  104 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
  105 +#end
  106 + public CommonResult<List<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}List(@Valid ${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO) {
  107 + List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(listReqVO);
  108 + return success(BeanUtils.toBean(list, ${sceneEnum.prefixClass}${table.className}RespVO.class));
96 } 109 }
97 110
  111 +#end
98 @GetMapping("/export-excel") 112 @GetMapping("/export-excel")
99 @Operation(summary = "导出${table.classComment} Excel") 113 @Operation(summary = "导出${table.classComment} Excel")
100 -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")#end  
101 - 114 +#if ($sceneEnum.scene == 1)
  115 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")
  116 +#end
102 @OperateLog(type = EXPORT) 117 @OperateLog(type = EXPORT)
103 - public void export${simpleClassName}Excel(@Valid ${sceneEnum.prefixClass}${table.className}ExportReqVO exportReqVO, 118 +#if ( $table.templateType != 2 )
  119 + public void export${simpleClassName}Excel(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO,
  120 + HttpServletResponse response) throws IOException {
  121 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  122 + List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}Page(pageReqVO).getList();
  123 + // 导出 Excel
  124 + ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${table.className}RespVO.class,
  125 + BeanUtils.toBean(list, ${table.className}RespVO.class));
  126 + }
  127 +## 特殊:树表专属逻辑(树不需要分页接口)
  128 +#else
  129 + public void export${simpleClassName}Excel(@Valid ${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO,
104 HttpServletResponse response) throws IOException { 130 HttpServletResponse response) throws IOException {
105 - List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO); 131 + List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(listReqVO);
106 // 导出 Excel 132 // 导出 Excel
107 - List<${sceneEnum.prefixClass}${table.className}ExcelVO> datas = ${table.className}Convert.INSTANCE.convertList02(list);  
108 - ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${sceneEnum.prefixClass}${table.className}ExcelVO.class, datas); 133 + ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${table.className}RespVO.class,
  134 + BeanUtils.toBean(list, ${table.className}RespVO.class));
  135 + }
  136 +#end
  137 +
  138 +## 特殊:主子表专属逻辑
  139 +#foreach ($subTable in $subTables)
  140 +#set ($index = $foreach.count - 1)
  141 +#set ($subSimpleClassName = $subSimpleClassNames.get($index))
  142 +#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段
  143 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
  144 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  145 +#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
  146 +#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
  147 +#set ($subClassNameVar = $subClassNameVars.get($index))
  148 + // ==================== 子表($subTable.classComment) ====================
  149 +
  150 +## 情况一:MASTER_ERP 时,需要分查询页子表
  151 +#if ( $table.templateType == 11 )
  152 + @GetMapping("/${subSimpleClassName_strikeCase}/page")
  153 + @Operation(summary = "获得${subTable.classComment}分页")
  154 + @Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}")
  155 +#if ($sceneEnum.scene == 1)
  156 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
  157 +#end
  158 + public CommonResult<PageResult<${subTable.className}DO>> get${subSimpleClassName}Page(PageParam pageReqVO,
  159 + @RequestParam("${subJoinColumn.javaField}") ${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  160 + return success(${classNameVar}Service.get${subSimpleClassName}Page(pageReqVO, ${subJoinColumn.javaField}));
  161 + }
  162 +
  163 +## 情况二:非 MASTER_ERP 时,需要列表查询子表
  164 +#else
  165 + #if ( $subTable.subJoinMany )
  166 + @GetMapping("/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}")
  167 + @Operation(summary = "获得${subTable.classComment}列表")
  168 + @Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}")
  169 +#if ($sceneEnum.scene == 1)
  170 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
  171 +#end
  172 + public CommonResult<List<${subTable.className}DO>> get${subSimpleClassName}ListBy${SubJoinColumnName}(@RequestParam("${subJoinColumn.javaField}") ${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  173 + return success(${classNameVar}Service.get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaField}));
  174 + }
  175 +
  176 + #else
  177 + @GetMapping("/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}")
  178 + @Operation(summary = "获得${subTable.classComment}")
  179 + @Parameter(name = "${subJoinColumn.javaField}", description = "${subJoinColumn.columnComment}")
  180 +#if ($sceneEnum.scene == 1)
  181 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
  182 +#end
  183 + public CommonResult<${subTable.className}DO> get${subSimpleClassName}By${SubJoinColumnName}(@RequestParam("${subJoinColumn.javaField}") ${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  184 + return success(${classNameVar}Service.get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaField}));
  185 + }
  186 +
  187 + #end
  188 +#end
  189 +## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作
  190 +#if ( $table.templateType == 11 )
  191 + @PostMapping("/${subSimpleClassName_strikeCase}/create")
  192 + @Operation(summary = "创建${subTable.classComment}")
  193 +#if ($sceneEnum.scene == 1)
  194 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")
  195 +#end
  196 + public CommonResult<${subPrimaryColumn.javaType}> create${subSimpleClassName}(@Valid @RequestBody ${subTable.className}DO ${subClassNameVar}) {
  197 + return success(${classNameVar}Service.create${subSimpleClassName}(${subClassNameVar}));
  198 + }
  199 +
  200 + @PutMapping("/${subSimpleClassName_strikeCase}/update")
  201 + @Operation(summary = "更新${subTable.classComment}")
  202 +#if ($sceneEnum.scene == 1)
  203 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")
  204 +#end
  205 + public CommonResult<Boolean> update${subSimpleClassName}(@Valid @RequestBody ${subTable.className}DO ${subClassNameVar}) {
  206 + ${classNameVar}Service.update${subSimpleClassName}(${subClassNameVar});
  207 + return success(true);
  208 + }
  209 +
  210 + @DeleteMapping("/${subSimpleClassName_strikeCase}/delete")
  211 + @Parameter(name = "id", description = "编号", required = true)
  212 + @Operation(summary = "删除${subTable.classComment}")
  213 +#if ($sceneEnum.scene == 1)
  214 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
  215 +#end
  216 + public CommonResult<Boolean> delete${subSimpleClassName}(@RequestParam("id") ${subPrimaryColumn.javaType} id) {
  217 + ${classNameVar}Service.delete${subSimpleClassName}(id);
  218 + return success(true);
109 } 219 }
110 220
111 -} 221 + @GetMapping("/${subSimpleClassName_strikeCase}/get")
  222 + @Operation(summary = "获得${subTable.classComment}")
  223 + @Parameter(name = "id", description = "编号", required = true)
  224 +#if ($sceneEnum.scene == 1)
  225 + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
  226 +#end
  227 + public CommonResult<${subTable.className}DO> get${subSimpleClassName}(@RequestParam("id") ${subPrimaryColumn.javaType} id) {
  228 + return success(${classNameVar}Service.get${subSimpleClassName}(id));
  229 + }
  230 +
  231 +#end
  232 +#end
  233 +}
112 \ No newline at end of file 234 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/_column.vm deleted
1 -## 提供给 baseVO、createVO、updateVO 生成字段  
2 - @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end)  
3 -#if (!${column.nullable})## 判断 @NotEmpty 和 @NotNull 注解  
4 -#if (${field.fieldType} == 'String')  
5 - @NotEmpty(message = "${column.columnComment}不能为空")  
6 -#else  
7 - @NotNull(message = "${column.columnComment}不能为空")  
8 -#end  
9 -#end  
10 -#if (${column.javaType} == "LocalDateTime")## 时间类型  
11 - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)  
12 -#end  
13 - private ${column.javaType} ${column.javaField};  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm deleted
1 -package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.*;  
5 -import java.util.*;  
6 -#foreach ($column in $columns)  
7 -#if (${column.javaType} == "BigDecimal")  
8 -import java.math.BigDecimal;  
9 -#end  
10 -#if (${column.javaType} == "LocalDateTime")  
11 -import java.time.LocalDateTime;  
12 -#end  
13 -#end  
14 -import javax.validation.constraints.*;  
15 -## 处理 Date 字段的引入  
16 -#foreach ($column in $columns)  
17 -#if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult}  
18 - && ${column.javaType} == "LocalDateTime")## 时间类型  
19 -import org.springframework.format.annotation.DateTimeFormat;  
20 -  
21 -import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
22 -#break  
23 -#end  
24 -#end  
25 -  
26 -/**  
27 - * ${table.classComment} Base VO,提供给添加、修改、详细的子 VO 使用  
28 - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成  
29 - */  
30 -@Data  
31 -public class ${sceneEnum.prefixClass}${table.className}BaseVO {  
32 -  
33 -#foreach ($column in $columns)  
34 -#if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult})##通用操作  
35 - #parse("codegen/java/controller/vo/_column.vm")  
36 -  
37 -#end  
38 -#end  
39 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/createReqVO.vm deleted
1 -package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;  
2 -  
3 -import lombok.*;  
4 -import java.util.*;  
5 -import io.swagger.v3.oas.annotations.media.Schema;  
6 -import javax.validation.constraints.*;  
7 -## 处理 Date 字段的引入  
8 -#foreach ($column in $columns)  
9 -#if (${column.createOperation} && (!${column.updateOperation} || !${column.listOperationResult})  
10 - && ${column.javaType} == "LocalDateTime")## 时间类型  
11 -import org.springframework.format.annotation.DateTimeFormat;  
12 -import java.time.LocalDateTime;  
13 -import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
14 -#break  
15 -#end  
16 -#end  
17 -  
18 -@Schema(description = "${sceneEnum.name} - ${table.classComment}创建 Request VO")  
19 -@Data  
20 -@EqualsAndHashCode(callSuper = true)  
21 -@ToString(callSuper = true)  
22 -public class ${sceneEnum.prefixClass}${table.className}CreateReqVO extends ${sceneEnum.prefixClass}${table.className}BaseVO {  
23 -  
24 -#foreach ($column in $columns)  
25 -#if (${column.createOperation} && (!${column.updateOperation} || !${column.listOperationResult}))##不是通用字段  
26 - #parse("codegen/java/controller/vo/_column.vm")  
27 -  
28 -#end  
29 -#end  
30 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm deleted
1 -package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.*;  
5 -import java.util.*;  
6 -#foreach ($column in $columns)  
7 -#if (${column.javaType} == "BigDecimal")  
8 -import java.math.BigDecimal;  
9 -#end  
10 -#if (${column.javaType} == "LocalDateTime")  
11 -import java.time.LocalDateTime;  
12 -#end  
13 -#end  
14 -  
15 -import com.alibaba.excel.annotation.ExcelProperty;  
16 -#foreach ($column in $columns)  
17 -#if ("$!column.dictType" != "")## 有设置数据字典  
18 -import ${DictFormatClassName};  
19 -import ${DictConvertClassName};  
20 -  
21 -#break  
22 -#end  
23 -#end  
24 -  
25 -/**  
26 - * ${table.classComment} Excel VO  
27 - *  
28 - * @author ${table.author}  
29 - */  
30 -@Data  
31 -public class ${sceneEnum.prefixClass}${table.className}ExcelVO {  
32 -  
33 -#foreach ($column in $columns)  
34 - #if (${column.listOperationResult})##返回字段  
35 - #if ("$!column.dictType" != "")##处理枚举值  
36 - @ExcelProperty(value = "${column.columnComment}", converter = DictConvert.class)  
37 - @DictFormat("${column.dictType}") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中  
38 - #else  
39 - @ExcelProperty("${column.columnComment}")  
40 - #end  
41 - private ${column.javaType} ${column.javaField};  
42 -  
43 - #end  
44 -#end  
45 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm renamed to yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm
@@ -4,9 +4,15 @@ import lombok.*; @@ -4,9 +4,15 @@ import lombok.*;
4 import java.util.*; 4 import java.util.*;
5 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
6 import ${PageParamClassName}; 6 import ${PageParamClassName};
7 -## 处理 Date 字段的引入  
8 #foreach ($column in $columns) 7 #foreach ($column in $columns)
9 -#if (${column.listOperation} && ${column.javaType} == "LocalDateTime")## 时间类型 8 +#if (${column.javaType} == "BigDecimal")
  9 +import java.math.BigDecimal;
  10 +#break
  11 +#end
  12 +#end
  13 +## 处理 LocalDateTime 字段的引入
  14 +#foreach ($column in $columns)
  15 +#if (${column.listOperation} && ${column.javaType} == "LocalDateTime")
10 import java.time.LocalDateTime; 16 import java.time.LocalDateTime;
11 import org.springframework.format.annotation.DateTimeFormat; 17 import org.springframework.format.annotation.DateTimeFormat;
12 18
@@ -20,9 +26,9 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -20,9 +26,9 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
20 private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; 26 private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
21 #end 27 #end
22 28
23 -@Schema(description = "${sceneEnum.name} - ${table.classComment} Excel 导出 Request VO,参数和 ${table.className}PageReqVO 是一致的") 29 +@Schema(description = "${sceneEnum.name} - ${table.classComment}列表 Request VO")
24 @Data 30 @Data
25 -public class ${sceneEnum.prefixClass}${table.className}ExportReqVO { 31 +public class ${sceneEnum.prefixClass}${table.className}ListReqVO {
26 32
27 #foreach ($column in $columns) 33 #foreach ($column in $columns)
28 #if (${column.listOperation})##查询操作 34 #if (${column.listOperation})##查询操作
@@ -36,4 +42,4 @@ public class ${sceneEnum.prefixClass}${table.className}ExportReqVO { @@ -36,4 +42,4 @@ public class ${sceneEnum.prefixClass}${table.className}ExportReqVO {
36 42
37 #end 43 #end
38 #end 44 #end
39 -} 45 -}
  46 +}
40 \ No newline at end of file 47 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
@@ -4,9 +4,15 @@ import lombok.*; @@ -4,9 +4,15 @@ import lombok.*;
4 import java.util.*; 4 import java.util.*;
5 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
6 import ${PageParamClassName}; 6 import ${PageParamClassName};
7 -## 处理 Date 字段的引入  
8 #foreach ($column in $columns) 7 #foreach ($column in $columns)
9 -#if (${column.listOperation} && ${column.javaType} == "LocalDateTime")## 时间类型 8 +#if (${column.javaType} == "BigDecimal")
  9 +import java.math.BigDecimal;
  10 +#break
  11 +#end
  12 +#end
  13 +## 处理 LocalDateTime 字段的引入
  14 +#foreach ($column in $columns)
  15 +#if (${column.listOperationCondition} && ${column.javaType} == "LocalDateTime")
10 import org.springframework.format.annotation.DateTimeFormat; 16 import org.springframework.format.annotation.DateTimeFormat;
11 import java.time.LocalDateTime; 17 import java.time.LocalDateTime;
12 18
@@ -38,4 +44,4 @@ public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PagePar @@ -38,4 +44,4 @@ public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PagePar
38 44
39 #end 45 #end
40 #end 46 #end
41 -} 47 -}
  48 +}
42 \ No newline at end of file 49 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm
@@ -2,24 +2,53 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac @@ -2,24 +2,53 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.*; 4 import lombok.*;
  5 +import java.util.*;
  6 +## 处理 BigDecimal 字段的引入
  7 +import java.util.*;
5 #foreach ($column in $columns) 8 #foreach ($column in $columns)
6 -#if (${column.javaType} == "LocalDateTime") 9 +#if (${column.javaType} == "BigDecimal")
  10 +import java.math.BigDecimal;
  11 +#break
  12 +#end
  13 +#end
  14 +## 处理 LocalDateTime 字段的引入
  15 +#foreach ($column in $columns)
  16 +#if (${column.listOperationResult} && ${column.javaType} == "LocalDateTime")
  17 +import org.springframework.format.annotation.DateTimeFormat;
7 import java.time.LocalDateTime; 18 import java.time.LocalDateTime;
8 #break 19 #break
9 #end 20 #end
10 #end 21 #end
  22 +## 处理 Excel 导出
  23 +import com.alibaba.excel.annotation.*;
  24 +#foreach ($column in $columns)
  25 +#if ("$!column.dictType" != "")## 有设置数据字典
  26 +import ${DictFormatClassName};
  27 +import ${DictConvertClassName};
  28 +#break
  29 +#end
  30 +#end
11 31
12 @Schema(description = "${sceneEnum.name} - ${table.classComment} Response VO") 32 @Schema(description = "${sceneEnum.name} - ${table.classComment} Response VO")
13 @Data 33 @Data
14 -@EqualsAndHashCode(callSuper = true)  
15 -@ToString(callSuper = true)  
16 -public class ${sceneEnum.prefixClass}${table.className}RespVO extends ${sceneEnum.prefixClass}${table.className}BaseVO { 34 +@ExcelIgnoreUnannotated
  35 +public class ${sceneEnum.prefixClass}${table.className}RespVO {
17 36
  37 +## 逐个处理字段
18 #foreach ($column in $columns) 38 #foreach ($column in $columns)
19 -#if (${column.listOperationResult} && (!${column.createOperation} || !${column.updateOperation}))##不是通用字段 39 +#if (${column.listOperationResult})
  40 +## 1. 处理 Swagger 注解
20 @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end) 41 @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end)
  42 +## 2. 处理 Excel 导出
  43 +#if ("$!column.dictType" != "")##处理枚举值
  44 + @ExcelProperty(value = "${column.columnComment}", converter = DictConvert.class)
  45 + @DictFormat("${column.dictType}") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
  46 +#else
  47 + @ExcelProperty("${column.columnComment}")
  48 +#end
  49 +## 3. 处理字段定义
21 private ${column.javaType} ${column.javaField}; 50 private ${column.javaType} ${column.javaField};
22 51
23 #end 52 #end
24 #end 53 #end
25 -} 54 -}
  55 +}
26 \ No newline at end of file 56 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm 0 → 100644
  1 +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import javax.validation.constraints.*;
  7 +## 处理 BigDecimal 字段的引入
  8 +import java.util.*;
  9 +#foreach ($column in $columns)
  10 +#if (${column.javaType} == "BigDecimal")
  11 +import java.math.BigDecimal;
  12 +#break
  13 +#end
  14 +#end
  15 +## 处理 LocalDateTime 字段的引入
  16 +#foreach ($column in $columns)
  17 +#if ((${column.createOperation} || ${column.updateOperation}) && ${column.javaType} == "LocalDateTime")
  18 +import org.springframework.format.annotation.DateTimeFormat;
  19 +import java.time.LocalDateTime;
  20 +#break
  21 +#end
  22 +#end
  23 +## 特殊:主子表专属逻辑
  24 +#foreach ($subTable in $subTables)
  25 +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO;
  26 +#end
  27 +
  28 +@Schema(description = "${sceneEnum.name} - ${table.classComment}新增/修改 Request VO")
  29 +@Data
  30 +public class ${sceneEnum.prefixClass}${table.className}SaveReqVO {
  31 +
  32 +## 逐个处理字段
  33 +#foreach ($column in $columns)
  34 +#if (${column.createOperation} || ${column.updateOperation})
  35 +## 1. 处理 Swagger 注解
  36 + @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end)
  37 +## 2. 处理 Validator 参数校验
  38 +#if (!${column.nullable} && !${column.primaryKey})
  39 +#if (${column.javaType} == 'String')
  40 + @NotEmpty(message = "${column.columnComment}不能为空")
  41 +#else
  42 + @NotNull(message = "${column.columnComment}不能为空")
  43 +#end
  44 +#end
  45 +## 3. 处理字段定义
  46 + private ${column.javaType} ${column.javaField};
  47 +
  48 +#end
  49 +#end
  50 +## 特殊:主子表专属逻辑(非 ERP 模式)
  51 +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11 )
  52 +#foreach ($subTable in $subTables)
  53 +#set ($index = $foreach.count - 1)
  54 + #if ( $subTable.subJoinMany)
  55 + @Schema(description = "${subTable.classComment}列表")
  56 + private List<${subTable.className}DO> ${subClassNameVars.get($index)}s;
  57 +
  58 + #else
  59 + @Schema(description = "${subTable.classComment}")
  60 + private ${subTable.className}DO ${subClassNameVars.get($index)};
  61 +
  62 + #end
  63 +#end
  64 +#end
  65 +}
0 \ No newline at end of file 66 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/updateReqVO.vm deleted
1 -package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.*;  
5 -import java.util.*;  
6 -import javax.validation.constraints.*;  
7 -## 处理 Date 字段的引入  
8 -#foreach ($column in $columns)  
9 -#if (${column.updateOperation} && (!${column.createOperation} || !${column.listOperationResult})  
10 - && ${column.javaType} == "LocalDateTime")## 时间类型  
11 -import org.springframework.format.annotation.DateTimeFormat;  
12 -import java.time.LocalDateTime;  
13 -import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;  
14 -#break  
15 -#end  
16 -#end  
17 -  
18 -@Schema(description = "${sceneEnum.name} - ${table.classComment}更新 Request VO")  
19 -@Data  
20 -@EqualsAndHashCode(callSuper = true)  
21 -@ToString(callSuper = true)  
22 -public class ${sceneEnum.prefixClass}${table.className}UpdateReqVO extends ${sceneEnum.prefixClass}${table.className}BaseVO {  
23 -  
24 -#foreach ($column in $columns)  
25 -#if (${column.updateOperation} && (!${column.createOperation} || !${column.listOperationResult}))##不是通用字段  
26 - #parse("codegen/java/controller/vo/_column.vm")  
27 -  
28 -#end  
29 -#end  
30 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/convert/convert.vm deleted
1 -package ${basePackage}.module.${table.moduleName}.convert.${table.businessName};  
2 -  
3 -import java.util.*;  
4 -  
5 -import ${PageResultClassName};  
6 -  
7 -import org.mapstruct.Mapper;  
8 -import org.mapstruct.factory.Mappers;  
9 -import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*;  
10 -import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;  
11 -  
12 -/**  
13 - * ${table.classComment} Convert  
14 - *  
15 - * @author ${table.author}  
16 - */  
17 -@Mapper  
18 -public interface ${table.className}Convert {  
19 -  
20 - ${table.className}Convert INSTANCE = Mappers.getMapper(${table.className}Convert.class);  
21 -  
22 - ${table.className}DO convert(${sceneEnum.prefixClass}${table.className}CreateReqVO bean);  
23 -  
24 - ${table.className}DO convert(${sceneEnum.prefixClass}${table.className}UpdateReqVO bean);  
25 -  
26 - ${sceneEnum.prefixClass}${table.className}RespVO convert(${table.className}DO bean);  
27 -  
28 - List<${sceneEnum.prefixClass}${table.className}RespVO> convertList(List<${table.className}DO> list);  
29 -  
30 - PageResult<${sceneEnum.prefixClass}${table.className}RespVO> convertPage(PageResult<${table.className}DO> page);  
31 -  
32 - List<${sceneEnum.prefixClass}${table.className}ExcelVO> convertList02(List<${table.className}DO> list);  
33 -  
34 -}  
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm
@@ -28,6 +28,11 @@ import ${BaseDOClassName}; @@ -28,6 +28,11 @@ import ${BaseDOClassName};
28 @AllArgsConstructor 28 @AllArgsConstructor
29 public class ${table.className}DO extends BaseDO { 29 public class ${table.className}DO extends BaseDO {
30 30
  31 +## 特殊:树表专属逻辑
  32 +#if ( $table.templateType == 2 )
  33 + public static final Long ${treeParentColumn_javaField_underlineCase.toUpperCase()}_ROOT = 0L;
  34 +
  35 +#end
31 #foreach ($column in $columns) 36 #foreach ($column in $columns)
32 #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 37 #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段
33 /** 38 /**
@@ -44,4 +49,4 @@ public class ${table.className}DO extends BaseDO { @@ -44,4 +49,4 @@ public class ${table.className}DO extends BaseDO {
44 #end 49 #end
45 #end 50 #end
46 51
47 -} 52 -}
  53 +}
48 \ No newline at end of file 54 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do_sub.vm 0 → 100644
  1 +#set ($subTable = $subTables.get($subIndex))##当前表
  2 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
  3 +package ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName};
  4 +
  5 +import lombok.*;
  6 +import java.util.*;
  7 +#foreach ($column in $subColumns)
  8 +#if (${column.javaType} == "BigDecimal")
  9 +import java.math.BigDecimal;
  10 +#end
  11 +#if (${column.javaType} == "LocalDateTime")
  12 +import java.time.LocalDateTime;
  13 +#end
  14 +#end
  15 +import com.baomidou.mybatisplus.annotation.*;
  16 +import ${BaseDOClassName};
  17 +
  18 +/**
  19 + * ${subTable.classComment} DO
  20 + *
  21 + * @author ${subTable.author}
  22 + */
  23 +@TableName("${subTable.tableName.toLowerCase()}")
  24 +@KeySequence("${subTable.tableName.toLowerCase()}_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  25 +@Data
  26 +@EqualsAndHashCode(callSuper = true)
  27 +@ToString(callSuper = true)
  28 +@Builder
  29 +@NoArgsConstructor
  30 +@AllArgsConstructor
  31 +public class ${subTable.className}DO extends BaseDO {
  32 +
  33 +#foreach ($column in $subColumns)
  34 +#if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段
  35 + /**
  36 + * ${column.columnComment}
  37 + #if ("$!column.dictType" != "")##处理枚举值
  38 + *
  39 + * 枚举 {@link TODO ${column.dictType} 对应的类}
  40 + #end
  41 + */
  42 + #if (${column.primaryKey})##处理主键
  43 + @TableId#if (${column.javaType} == 'String')(type = IdType.INPUT)#end
  44 + #end
  45 + private ${column.javaType} ${column.javaField};
  46 +#end
  47 +#end
  48 +
  49 +}
0 \ No newline at end of file 50 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/mapper.vm
@@ -49,18 +49,34 @@ import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePack @@ -49,18 +49,34 @@ import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePack
49 @Mapper 49 @Mapper
50 public interface ${table.className}Mapper extends BaseMapperX<${table.className}DO> { 50 public interface ${table.className}Mapper extends BaseMapperX<${table.className}DO> {
51 51
  52 +## 特殊:树表专属逻辑(树不需要分页接口)
  53 +#if ( $table.templateType != 2 )
52 default PageResult<${table.className}DO> selectPage(${sceneEnum.prefixClass}${table.className}PageReqVO reqVO) { 54 default PageResult<${table.className}DO> selectPage(${sceneEnum.prefixClass}${table.className}PageReqVO reqVO) {
53 return selectPage(reqVO, new LambdaQueryWrapperX<${table.className}DO>() 55 return selectPage(reqVO, new LambdaQueryWrapperX<${table.className}DO>()
54 #listCondition() 56 #listCondition()
55 .orderByDesc(${table.className}DO::getId));## 大多数情况下,id 倒序 57 .orderByDesc(${table.className}DO::getId));## 大多数情况下,id 倒序
56 58
57 } 59 }
58 -  
59 - default List<${table.className}DO> selectList(${sceneEnum.prefixClass}${table.className}ExportReqVO reqVO) { 60 +#else
  61 + default List<${table.className}DO> selectList(${sceneEnum.prefixClass}${table.className}ListReqVO reqVO) {
60 return selectList(new LambdaQueryWrapperX<${table.className}DO>() 62 return selectList(new LambdaQueryWrapperX<${table.className}DO>()
61 #listCondition() 63 #listCondition()
62 .orderByDesc(${table.className}DO::getId));## 大多数情况下,id 倒序 64 .orderByDesc(${table.className}DO::getId));## 大多数情况下,id 倒序
63 65
64 } 66 }
  67 +#end
  68 +
  69 +## 特殊:树表专属逻辑
  70 +#if ( $table.templateType == 2 )
  71 +#set ($TreeParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写
  72 +#set ($TreeNameJavaField = $treeNameColumn.javaField.substring(0,1).toUpperCase() + ${treeNameColumn.javaField.substring(1)})##首字母大写
  73 + default ${table.className}DO selectBy${TreeParentJavaField}And${TreeNameJavaField}(Long ${treeParentColumn.javaField}, String ${treeNameColumn.javaField}) {
  74 + return selectOne(${table.className}DO::get${TreeParentJavaField}, ${treeParentColumn.javaField}, ${table.className}DO::get${TreeNameJavaField}, ${treeNameColumn.javaField});
  75 + }
  76 +
  77 + default Long selectCountBy${TreeParentJavaField}(${treeParentColumn.javaType} ${treeParentColumn.javaField}) {
  78 + return selectCount(${table.className}DO::get${TreeParentJavaField}, ${treeParentColumn.javaField});
  79 + }
65 80
66 -} 81 +#end
  82 +}
67 \ No newline at end of file 83 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/mapper.xml.vm
@@ -9,4 +9,4 @@ @@ -9,4 +9,4 @@
9 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ 9 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
10 --> 10 -->
11 11
12 -</mapper> 12 -</mapper>
  13 +</mapper>
13 \ No newline at end of file 14 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/mapper_sub.vm 0 → 100644
  1 +#set ($subTable = $subTables.get($subIndex))##当前表
  2 +#set ($subColumns = $subJoinColumnsList.get($subIndex))##当前字段数组
  3 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
  4 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  5 +package ${basePackage}.module.${subTable.moduleName}.dal.mysql.${subTable.businessName};
  6 +
  7 +import java.util.*;
  8 +
  9 +import ${PageResultClassName};
  10 +import ${PageParamClassName};
  11 +import ${QueryWrapperClassName};
  12 +import ${BaseMapperClassName};
  13 +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO;
  14 +import org.apache.ibatis.annotations.Mapper;
  15 +
  16 +/**
  17 + * ${subTable.classComment} Mapper
  18 + *
  19 + * @author ${subTable.author}
  20 + */
  21 +@Mapper
  22 +public interface ${subTable.className}Mapper extends BaseMapperX<${subTable.className}DO> {
  23 +
  24 +## 情况一:MASTER_ERP 时,需要分查询页子表
  25 +#if ( $table.templateType == 11 )
  26 + default PageResult<${subTable.className}DO> selectPage(PageParam reqVO, ${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  27 + return selectPage(reqVO, new LambdaQueryWrapperX<${subTable.className}DO>()
  28 + .eq(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField})
  29 + .orderByDesc(${subTable.className}DO::getId));## 大多数情况下,id 倒序
  30 +
  31 + }
  32 +
  33 +## 情况二:非 MASTER_ERP 时,需要列表查询子表
  34 +#else
  35 + #if ( $subTable.subJoinMany)
  36 + default List<${subTable.className}DO> selectListBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  37 + return selectList(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField});
  38 + }
  39 +
  40 + #else
  41 + default ${subTable.className}DO selectBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  42 + return selectOne(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField});
  43 + }
  44 +
  45 + #end
  46 + #end
  47 + default int deleteBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  48 + return delete(${subTable.className}DO::get${SubJoinColumnName}, ${subJoinColumn.javaField});
  49 + }
  50 +
  51 +}
0 \ No newline at end of file 52 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/enums/errorcode.vm
1 // TODO 待办:请将下面的错误码复制到 yudao-module-${table.moduleName}-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! 1 // TODO 待办:请将下面的错误码复制到 yudao-module-${table.moduleName}-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!!
2 // ========== ${table.classComment} TODO 补充编号 ========== 2 // ========== ${table.classComment} TODO 补充编号 ==========
3 ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在"); 3 ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在");
  4 +## 特殊:树表专属逻辑
  5 +#if ( $table.templateType == 2 )
  6 +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子${table.classComment},无法删除");
  7 +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级${table.classComment}不存在");
  8 +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父${table.classComment}");
  9 +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该${treeNameColumn.columnComment}的${table.classComment}");
  10 +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子${table.className}为父${table.className}");
  11 +#end
  12 +## 特殊:主子表专属逻辑
  13 +#if ( $table.templateType == 11 )## 特殊:ERP 情况
  14 +#foreach ($subTable in $subTables)
  15 +#set ($index = $foreach.count - 1)
  16 +#set ($simpleClassNameUnderlineCase = $simpleClassNameUnderlineCases.get($index))
  17 +ErrorCode ${simpleClassNameUnderlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${subTable.classComment}不存在");
  18 +#if ( !$subTable.subJoinMany )
  19 +ErrorCode ${simpleClassNameUnderlineCase.toUpperCase()}_EXISTS = new ErrorCode(TODO 补充编号, "${subTable.classComment}已存在");
  20 +#end
  21 +#end
  22 +#end
4 \ No newline at end of file 23 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/service.vm
@@ -4,7 +4,12 @@ import java.util.*; @@ -4,7 +4,12 @@ import java.util.*;
4 import javax.validation.*; 4 import javax.validation.*;
5 import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; 5 import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*;
6 import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; 6 import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
  7 +## 特殊:主子表专属逻辑
  8 +#foreach ($subTable in $subTables)
  9 +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO;
  10 +#end
7 import ${PageResultClassName}; 11 import ${PageResultClassName};
  12 +import ${PageParamClassName};
8 13
9 /** 14 /**
10 * ${table.classComment} Service 接口 15 * ${table.classComment} Service 接口
@@ -19,14 +24,14 @@ public interface ${table.className}Service { @@ -19,14 +24,14 @@ public interface ${table.className}Service {
19 * @param createReqVO 创建信息 24 * @param createReqVO 创建信息
20 * @return 编号 25 * @return 编号
21 */ 26 */
22 - ${primaryColumn.javaType} create${simpleClassName}(@Valid ${sceneEnum.prefixClass}${table.className}CreateReqVO createReqVO); 27 + ${primaryColumn.javaType} create${simpleClassName}(@Valid ${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO);
23 28
24 /** 29 /**
25 * 更新${table.classComment} 30 * 更新${table.classComment}
26 * 31 *
27 * @param updateReqVO 更新信息 32 * @param updateReqVO 更新信息
28 */ 33 */
29 - void update${simpleClassName}(@Valid ${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO); 34 + void update${simpleClassName}(@Valid ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO);
30 35
31 /** 36 /**
32 * 删除${table.classComment} 37 * 删除${table.classComment}
@@ -43,28 +48,100 @@ public interface ${table.className}Service { @@ -43,28 +48,100 @@ public interface ${table.className}Service {
43 */ 48 */
44 ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id); 49 ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id);
45 50
  51 +## 特殊:树表专属逻辑(树不需要分页接口)
  52 +#if ( $table.templateType != 2 )
  53 + /**
  54 + * 获得${table.classComment}分页
  55 + *
  56 + * @param pageReqVO 分页查询
  57 + * @return ${table.classComment}分页
  58 + */
  59 + PageResult<${table.className}DO> get${simpleClassName}Page(${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO);
  60 +#else
46 /** 61 /**
47 * 获得${table.classComment}列表 62 * 获得${table.classComment}列表
48 * 63 *
49 - * @param ids 编号 64 + * @param listReqVO 查询条件
50 * @return ${table.classComment}列表 65 * @return ${table.classComment}列表
51 */ 66 */
52 - List<${table.className}DO> get${simpleClassName}List(Collection<${primaryColumn.javaType}> ids); 67 + List<${table.className}DO> get${simpleClassName}List(${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO);
  68 +#end
  69 +
  70 +## 特殊:主子表专属逻辑
  71 +#foreach ($subTable in $subTables)
  72 +#set ($index = $foreach.count - 1)
  73 +#set ($subSimpleClassName = $subSimpleClassNames.get($index))
  74 +#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段
  75 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
  76 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  77 +#set ($subClassNameVar = $subClassNameVars.get($index))
  78 + // ==================== 子表($subTable.classComment) ====================
53 79
  80 +## 情况一:MASTER_ERP 时,需要分查询页子表
  81 +#if ( $table.templateType == 11 )
54 /** 82 /**
55 - * 获得${table.classComment}分页 83 + * 获得${subTable.classComment}分页
56 * 84 *
57 * @param pageReqVO 分页查询 85 * @param pageReqVO 分页查询
58 - * @return ${table.classComment}分页 86 + * @param ${subJoinColumn.javaField} ${subJoinColumn.columnComment}
  87 + * @return ${subTable.classComment}分页
59 */ 88 */
60 - PageResult<${table.className}DO> get${simpleClassName}Page(${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO); 89 + PageResult<${subTable.className}DO> get${subSimpleClassName}Page(PageParam pageReqVO, ${subJoinColumn.javaType} ${subJoinColumn.javaField});
61 90
  91 +## 情况二:非 MASTER_ERP 时,需要列表查询子表
  92 +#else
  93 + #if ( $subTable.subJoinMany )
62 /** 94 /**
63 - * 获得${table.classComment}列表, 用于 Excel 导出 95 + * 获得${subTable.classComment}列表
64 * 96 *
65 - * @param exportReqVO 查询条件  
66 - * @return ${table.classComment}列表 97 + * @param ${subJoinColumn.javaField} ${subJoinColumn.columnComment}
  98 + * @return ${subTable.classComment}列表
  99 + */
  100 + List<${subTable.className}DO> get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField});
  101 +
  102 + #else
  103 + /**
  104 + * 获得${subTable.classComment}
  105 + *
  106 + * @param ${subJoinColumn.javaField} ${subJoinColumn.columnComment}
  107 + * @return ${subTable.classComment}
67 */ 108 */
68 - List<${table.className}DO> get${simpleClassName}List(${sceneEnum.prefixClass}${table.className}ExportReqVO exportReqVO); 109 + ${subTable.className}DO get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField});
  110 +
  111 + #end
  112 +#end
  113 +## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作
  114 +#if ( $table.templateType == 11 )
  115 + /**
  116 + * 创建${subTable.classComment}
  117 + *
  118 + * @param ${subClassNameVar} 创建信息
  119 + * @return 编号
  120 + */
  121 + ${subPrimaryColumn.javaType} create${subSimpleClassName}(@Valid ${subTable.className}DO ${subClassNameVar});
  122 +
  123 + /**
  124 + * 更新${subTable.classComment}
  125 + *
  126 + * @param ${subClassNameVar} 更新信息
  127 + */
  128 + void update${subSimpleClassName}(@Valid ${subTable.className}DO ${subClassNameVar});
  129 +
  130 + /**
  131 + * 删除${subTable.classComment}
  132 + *
  133 + * @param id 编号
  134 + */
  135 + void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id);
  136 +
  137 + /**
  138 + * 获得${subTable.classComment}
  139 + *
  140 + * @param id 编号
  141 + * @return ${subTable.classComment}
  142 + */
  143 + ${subTable.className}DO get${subSimpleClassName}(${subPrimaryColumn.javaType} id);
69 144
70 -} 145 +#end
  146 +#end
  147 +}
71 \ No newline at end of file 148 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm
@@ -3,21 +3,29 @@ package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; @@ -3,21 +3,29 @@ package ${basePackage}.module.${table.moduleName}.service.${table.businessName};
3 import org.springframework.stereotype.Service; 3 import org.springframework.stereotype.Service;
4 import javax.annotation.Resource; 4 import javax.annotation.Resource;
5 import org.springframework.validation.annotation.Validated; 5 import org.springframework.validation.annotation.Validated;
  6 +import org.springframework.transaction.annotation.Transactional;
6 7
7 import java.util.*; 8 import java.util.*;
8 import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; 9 import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*;
9 import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; 10 import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
  11 +## 特殊:主子表专属逻辑
  12 +#foreach ($subTable in $subTables)
  13 +import ${basePackage}.module.${subTable.moduleName}.dal.dataobject.${subTable.businessName}.${subTable.className}DO;
  14 +#end
10 import ${PageResultClassName}; 15 import ${PageResultClassName};
  16 +import ${PageParamClassName};
  17 +import ${BeanUtils};
11 18
12 -import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;  
13 import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; 19 import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper;
  20 +## 特殊:主子表专属逻辑
  21 +#foreach ($subTable in $subTables)
  22 +#set ($index = $foreach.count - 1)
  23 +import ${basePackage}.module.${subTable.moduleName}.dal.mysql.${subTable.businessName}.${subTable.className}Mapper;
  24 +#end
14 25
15 import static ${ServiceExceptionUtilClassName}.exception; 26 import static ${ServiceExceptionUtilClassName}.exception;
16 import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*; 27 import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*;
17 28
18 -import cn.hutool.core.collection.CollUtil;  
19 -import cn.hutool.core.collection.ListUtil;  
20 -  
21 /** 29 /**
22 * ${table.classComment} Service 实现类 30 * ${table.classComment} Service 实现类
23 * 31 *
@@ -29,31 +37,121 @@ public class ${table.className}ServiceImpl implements ${table.className}Service @@ -29,31 +37,121 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
29 37
30 @Resource 38 @Resource
31 private ${table.className}Mapper ${classNameVar}Mapper; 39 private ${table.className}Mapper ${classNameVar}Mapper;
  40 +## 特殊:主子表专属逻辑
  41 +#foreach ($subTable in $subTables)
  42 +#set ($index = $foreach.count - 1)
  43 + @Resource
  44 + private ${subTable.className}Mapper ${subClassNameVars.get($index)}Mapper;
  45 +#end
32 46
33 @Override 47 @Override
34 - public ${primaryColumn.javaType} create${simpleClassName}(${sceneEnum.prefixClass}${table.className}CreateReqVO createReqVO) { 48 +## 特殊:主子表专属逻辑(非 ERP 模式)
  49 +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11 )
  50 + @Transactional(rollbackFor = Exception.class)
  51 +#end
  52 + public ${primaryColumn.javaType} create${simpleClassName}(${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO) {
  53 +## 特殊:树表专属逻辑
  54 +#if ( $table.templateType == 2 )
  55 +#set ($TreeParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写
  56 +#set ($TreeNameJavaField = $treeNameColumn.javaField.substring(0,1).toUpperCase() + ${treeNameColumn.javaField.substring(1)})##首字母大写
  57 + // 校验${treeParentColumn.columnComment}的有效性
  58 + validateParent${simpleClassName}(null, createReqVO.get${TreeParentJavaField}());
  59 + // 校验${treeNameColumn.columnComment}的唯一性
  60 + validate${simpleClassName}${TreeNameJavaField}Unique(null, createReqVO.get${TreeParentJavaField}(), createReqVO.get${TreeNameJavaField}());
  61 +
  62 +#end
35 // 插入 63 // 插入
36 - ${table.className}DO ${classNameVar} = ${table.className}Convert.INSTANCE.convert(createReqVO); 64 + ${table.className}DO ${classNameVar} = BeanUtils.toBean(createReqVO, ${table.className}DO.class);
37 ${classNameVar}Mapper.insert(${classNameVar}); 65 ${classNameVar}Mapper.insert(${classNameVar});
  66 +## 特殊:主子表专属逻辑(非 ERP 模式)
  67 +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11 )
  68 +
  69 + // 插入子表
  70 +#foreach ($subTable in $subTables)
  71 +#set ($index = $foreach.count - 1)
  72 +#set ($subSimpleClassName = $subSimpleClassNames.get($index))
  73 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
  74 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  75 + #if ( $subTable.subJoinMany)
  76 + create${subSimpleClassName}List(${classNameVar}.getId(), createReqVO.get${subSimpleClassNames.get($index)}s());
  77 + #else
  78 + create${subSimpleClassName}(${classNameVar}.getId(), createReqVO.get${subSimpleClassNames.get($index)}());
  79 + #end
  80 +#end
  81 +#end
38 // 返回 82 // 返回
39 return ${classNameVar}.getId(); 83 return ${classNameVar}.getId();
40 } 84 }
41 85
42 @Override 86 @Override
43 - public void update${simpleClassName}(${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO) { 87 +## 特殊:主子表专属逻辑(非 ERP 模式)
  88 +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11 )
  89 + @Transactional(rollbackFor = Exception.class)
  90 +#end
  91 + public void update${simpleClassName}(${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO) {
44 // 校验存在 92 // 校验存在
45 validate${simpleClassName}Exists(updateReqVO.getId()); 93 validate${simpleClassName}Exists(updateReqVO.getId());
  94 +## 特殊:树表专属逻辑
  95 +#if ( $table.templateType == 2 )
  96 +#set ($TreeParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写
  97 +#set ($TreeNameJavaField = $treeNameColumn.javaField.substring(0,1).toUpperCase() + ${treeNameColumn.javaField.substring(1)})##首字母大写
  98 + // 校验${treeParentColumn.columnComment}的有效性
  99 + validateParent${simpleClassName}(updateReqVO.getId(), updateReqVO.get${TreeParentJavaField}());
  100 + // 校验${treeNameColumn.columnComment}的唯一性
  101 + validate${simpleClassName}${TreeNameJavaField}Unique(updateReqVO.getId(), updateReqVO.get${TreeParentJavaField}(), updateReqVO.get${TreeNameJavaField}());
  102 +
  103 +#end
46 // 更新 104 // 更新
47 - ${table.className}DO updateObj = ${table.className}Convert.INSTANCE.convert(updateReqVO); 105 + ${table.className}DO updateObj = BeanUtils.toBean(updateReqVO, ${table.className}DO.class);
48 ${classNameVar}Mapper.updateById(updateObj); 106 ${classNameVar}Mapper.updateById(updateObj);
  107 +## 特殊:主子表专属逻辑(非 ERP 模式)
  108 +#if ( $subTables && $subTables.size() > 0 && $table.templateType != 11)
  109 +
  110 + // 更新子表
  111 +#foreach ($subTable in $subTables)
  112 +#set ($index = $foreach.count - 1)
  113 +#set ($subSimpleClassName = $subSimpleClassNames.get($index))
  114 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
  115 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  116 + #if ( $subTable.subJoinMany)
  117 + update${subSimpleClassName}List(updateReqVO.getId(), updateReqVO.get${subSimpleClassNames.get($index)}s());
  118 + #else
  119 + update${subSimpleClassName}(updateReqVO.getId(), updateReqVO.get${subSimpleClassNames.get($index)}());
  120 + #end
  121 +#end
  122 +#end
49 } 123 }
50 124
51 @Override 125 @Override
  126 +## 特殊:主子表专属逻辑
  127 +#if ( $subTables && $subTables.size() > 0)
  128 + @Transactional(rollbackFor = Exception.class)
  129 +#end
52 public void delete${simpleClassName}(${primaryColumn.javaType} id) { 130 public void delete${simpleClassName}(${primaryColumn.javaType} id) {
53 // 校验存在 131 // 校验存在
54 validate${simpleClassName}Exists(id); 132 validate${simpleClassName}Exists(id);
  133 +## 特殊:树表专属逻辑
  134 +#if ( $table.templateType == 2 )
  135 +#set ($ParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写
  136 + // 校验是否有子${table.classComment}
  137 + if (${classNameVar}Mapper.selectCountBy${ParentJavaField}(id) > 0) {
  138 + throw exception(${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN);
  139 + }
  140 +#end
55 // 删除 141 // 删除
56 ${classNameVar}Mapper.deleteById(id); 142 ${classNameVar}Mapper.deleteById(id);
  143 +## 特殊:主子表专属逻辑
  144 +#if ( $subTables && $subTables.size() > 0)
  145 +
  146 + // 删除子表
  147 +#foreach ($subTable in $subTables)
  148 +#set ($index = $foreach.count - 1)
  149 +#set ($subSimpleClassName = $subSimpleClassNames.get($index))
  150 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
  151 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  152 + delete${subSimpleClassName}By${SubJoinColumnName}(id);
  153 +#end
  154 +#end
57 } 155 }
58 156
59 private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) { 157 private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) {
@@ -62,27 +160,191 @@ public class ${table.className}ServiceImpl implements ${table.className}Service @@ -62,27 +160,191 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
62 } 160 }
63 } 161 }
64 162
  163 +## 特殊:树表专属逻辑
  164 +#if ( $table.templateType == 2 )
  165 +#set ($TreeParentJavaField = $treeParentColumn.javaField.substring(0,1).toUpperCase() + ${treeParentColumn.javaField.substring(1)})##首字母大写
  166 +#set ($TreeNameJavaField = $treeNameColumn.javaField.substring(0,1).toUpperCase() + ${treeNameColumn.javaField.substring(1)})##首字母大写
  167 + private void validateParent${simpleClassName}(Long id, Long ${treeParentColumn.javaField}) {
  168 + if (${treeParentColumn.javaField} == null || ${simpleClassName}DO.${treeParentColumn_javaField_underlineCase.toUpperCase()}_ROOT.equals(${treeParentColumn.javaField})) {
  169 + return;
  170 + }
  171 + // 1. 不能设置自己为父${table.classComment}
  172 + if (Objects.equals(id, ${treeParentColumn.javaField})) {
  173 + throw exception(${simpleClassName_underlineCase.toUpperCase()}_PARENT_ERROR);
  174 + }
  175 + // 2. 父${table.classComment}不存在
  176 + ${simpleClassName}DO parent${simpleClassName} = ${classNameVar}Mapper.selectById(${treeParentColumn.javaField});
  177 + if (parent${simpleClassName} == null) {
  178 + throw exception(${simpleClassName_underlineCase.toUpperCase()}_PARENT_NOT_EXITS);
  179 + }
  180 + // 3. 递归校验父${table.classComment},如果父${table.classComment}是自己的子${table.classComment},则报错,避免形成环路
  181 + if (id == null) { // id 为空,说明新增,不需要考虑环路
  182 + return;
  183 + }
  184 + for (int i = 0; i < Short.MAX_VALUE; i++) {
  185 + // 3.1 校验环路
  186 + ${treeParentColumn.javaField} = parent${simpleClassName}.get${TreeParentJavaField}();
  187 + if (Objects.equals(id, ${treeParentColumn.javaField})) {
  188 + throw exception(${simpleClassName_underlineCase.toUpperCase()}_PARENT_IS_CHILD);
  189 + }
  190 + // 3.2 继续递归下一级父${table.classComment}
  191 + if (${treeParentColumn.javaField} == null || ${simpleClassName}DO.${treeParentColumn_javaField_underlineCase.toUpperCase()}_ROOT.equals(${treeParentColumn.javaField})) {
  192 + break;
  193 + }
  194 + parent${simpleClassName} = ${classNameVar}Mapper.selectById(${treeParentColumn.javaField});
  195 + if (parent${simpleClassName} == null) {
  196 + break;
  197 + }
  198 + }
  199 + }
  200 +
  201 + private void validate${simpleClassName}${TreeNameJavaField}Unique(Long id, Long ${treeParentColumn.javaField}, String ${treeNameColumn.javaField}) {
  202 + ${simpleClassName}DO ${classNameVar} = ${classNameVar}Mapper.selectBy${TreeParentJavaField}And${TreeNameJavaField}(${treeParentColumn.javaField}, ${treeNameColumn.javaField});
  203 + if (${classNameVar} == null) {
  204 + return;
  205 + }
  206 + // 如果 id 为空,说明不用比较是否为相同 id 的${table.classComment}
  207 + if (id == null) {
  208 + throw exception(${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE);
  209 + }
  210 + if (!Objects.equals(${classNameVar}.getId(), id)) {
  211 + throw exception(${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE);
  212 + }
  213 + }
  214 +
  215 +#end
65 @Override 216 @Override
66 public ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id) { 217 public ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id) {
67 return ${classNameVar}Mapper.selectById(id); 218 return ${classNameVar}Mapper.selectById(id);
68 } 219 }
69 220
  221 +## 特殊:树表专属逻辑(树不需要分页接口)
  222 +#if ( $table.templateType != 2 )
  223 + @Override
  224 + public PageResult<${table.className}DO> get${simpleClassName}Page(${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO) {
  225 + return ${classNameVar}Mapper.selectPage(pageReqVO);
  226 + }
  227 +#else
  228 + @Override
  229 + public List<${table.className}DO> get${simpleClassName}List(${sceneEnum.prefixClass}${table.className}ListReqVO listReqVO) {
  230 + return ${classNameVar}Mapper.selectList(listReqVO);
  231 + }
  232 +#end
  233 +
  234 +## 特殊:主子表专属逻辑
  235 +#foreach ($subTable in $subTables)
  236 +#set ($index = $foreach.count - 1)
  237 +#set ($subSimpleClassName = $subSimpleClassNames.get($index))
  238 +#set ($simpleClassNameUnderlineCase = $simpleClassNameUnderlineCases.get($index))
  239 +#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段
  240 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
  241 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  242 +#set ($subClassNameVar = $subClassNameVars.get($index))
  243 + // ==================== 子表($subTable.classComment) ====================
  244 +
  245 +## 情况一:MASTER_ERP 时,需要分查询页子表
  246 +#if ( $table.templateType == 11 )
  247 + @Override
  248 + public PageResult<${subTable.className}DO> get${subSimpleClassName}Page(PageParam pageReqVO, ${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  249 + return ${subClassNameVars.get($index)}Mapper.selectPage(pageReqVO, ${subJoinColumn.javaField});
  250 + }
  251 +
  252 +## 情况二:非 MASTER_ERP 时,需要列表查询子表
  253 +#else
  254 + #if ( $subTable.subJoinMany )
70 @Override 255 @Override
71 - public List<${table.className}DO> get${simpleClassName}List(Collection<${primaryColumn.javaType}> ids) {  
72 - if (CollUtil.isEmpty(ids)) {  
73 - return ListUtil.empty(); 256 + public List<${subTable.className}DO> get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  257 + return ${subClassNameVars.get($index)}Mapper.selectListBy${SubJoinColumnName}(${subJoinColumn.javaField});
  258 + }
  259 +
  260 + #else
  261 + @Override
  262 + public ${subTable.className}DO get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaType} ${subJoinColumn.javaField}) {
  263 + return ${subClassNameVars.get($index)}Mapper.selectBy${SubJoinColumnName}(${subJoinColumn.javaField});
  264 + }
  265 +
  266 + #end
  267 +#end
  268 +## 情况一:MASTER_ERP 时,支持单个的新增、修改、删除操作
  269 +#if ( $table.templateType == 11 )
  270 + @Override
  271 + public ${subPrimaryColumn.javaType} create${subSimpleClassName}(${subTable.className}DO ${subClassNameVar}) {
  272 +## 特殊:一对一时,需要保证只有一条,不能重复插入
  273 +#if ( !$subTable.subJoinMany)
  274 + // 校验是否已经存在
  275 + if (${subClassNameVars.get($index)}Mapper.selectBy${SubJoinColumnName}(${subClassNameVar}.get${SubJoinColumnName}()) != null) {
  276 + throw exception(${simpleClassNameUnderlineCase.toUpperCase()}_EXISTS);
74 } 277 }
75 - return ${classNameVar}Mapper.selectBatchIds(ids); 278 + // 插入
  279 +#end
  280 + ${subClassNameVars.get($index)}Mapper.insert(${subClassNameVar});
  281 + return ${subClassNameVar}.getId();
76 } 282 }
77 283
78 @Override 284 @Override
79 - public PageResult<${table.className}DO> get${simpleClassName}Page(${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO) {  
80 - return ${classNameVar}Mapper.selectPage(pageReqVO); 285 + public void update${subSimpleClassName}(${subTable.className}DO ${subClassNameVar}) {
  286 + // 校验存在
  287 + validate${subSimpleClassName}Exists(${subClassNameVar}.getId());
  288 + // 更新
  289 + ${subClassNameVars.get($index)}Mapper.updateById(${subClassNameVar});
  290 + }
  291 +
  292 + @Override
  293 + public void delete${subSimpleClassName}(${subPrimaryColumn.javaType} id) {
  294 + // 校验存在
  295 + validate${subSimpleClassName}Exists(id);
  296 + // 删除
  297 + ${subClassNameVars.get($index)}Mapper.deleteById(id);
81 } 298 }
82 299
83 @Override 300 @Override
84 - public List<${table.className}DO> get${simpleClassName}List(${sceneEnum.prefixClass}${table.className}ExportReqVO exportReqVO) {  
85 - return ${classNameVar}Mapper.selectList(exportReqVO); 301 + public ${subTable.className}DO get${subSimpleClassName}(${subPrimaryColumn.javaType} id) {
  302 + return ${subClassNameVars.get($index)}Mapper.selectById(id);
  303 + }
  304 +
  305 + private void validate${subSimpleClassName}Exists(${subPrimaryColumn.javaType} id) {
  306 + if (${subClassNameVar}Mapper.selectById(id) == null) {
  307 + throw exception(${simpleClassNameUnderlineCase.toUpperCase()}_NOT_EXISTS);
  308 + }
  309 + }
  310 +
  311 +## 情况二:非 MASTER_ERP 时,支持批量的新增、修改操作
  312 +#else
  313 + #if ( $subTable.subJoinMany)
  314 + private void create${subSimpleClassName}List(${primaryColumn.javaType} ${subJoinColumn.javaField}, List<${subTable.className}DO> list) {
  315 + list.forEach(o -> o.set$SubJoinColumnName(${subJoinColumn.javaField}));
  316 + ${subClassNameVars.get($index)}Mapper.insertBatch(list);
  317 + }
  318 +
  319 + private void update${subSimpleClassName}List(${primaryColumn.javaType} ${subJoinColumn.javaField}, List<${subTable.className}DO> list) {
  320 + delete${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaField});
  321 + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新
  322 + create${subSimpleClassName}List(${subJoinColumn.javaField}, list);
  323 + }
  324 +
  325 + #else
  326 + private void create${subSimpleClassName}(${primaryColumn.javaType} ${subJoinColumn.javaField}, ${subTable.className}DO ${subClassNameVar}) {
  327 + if (${subClassNameVar} == null) {
  328 + return;
  329 + }
  330 + ${subClassNameVar}.set$SubJoinColumnName(${subJoinColumn.javaField});
  331 + ${subClassNameVars.get($index)}Mapper.insert(${subClassNameVar});
  332 + }
  333 +
  334 + private void update${subSimpleClassName}(${primaryColumn.javaType} ${subJoinColumn.javaField}, ${subTable.className}DO ${subClassNameVar}) {
  335 + if (${subClassNameVar} == null) {
  336 + return;
  337 + }
  338 + ${subClassNameVar}.set$SubJoinColumnName(${subJoinColumn.javaField});
  339 + ${subClassNameVar}.setUpdater(null).setUpdateTime(null); // 解决更新情况下:updateTime 不更新
  340 + ${subClassNameVars.get($index)}Mapper.insertOrUpdate(${subClassNameVar});
  341 + }
  342 +
  343 + #end
  344 +#end
  345 + private void delete${subSimpleClassName}By${SubJoinColumnName}(${primaryColumn.javaType} ${subJoinColumn.javaField}) {
  346 + ${subClassNameVars.get($index)}Mapper.deleteBy${SubJoinColumnName}(${subJoinColumn.javaField});
86 } 347 }
87 348
88 -} 349 +#end
  350 +}
89 \ No newline at end of file 351 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm
@@ -77,15 +77,15 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest { @@ -77,15 +77,15 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest {
77 @Test 77 @Test
78 public void testCreate${simpleClassName}_success() { 78 public void testCreate${simpleClassName}_success() {
79 // 准备参数 79 // 准备参数
80 - ${sceneEnum.prefixClass}${table.className}CreateReqVO reqVO = randomPojo(${sceneEnum.prefixClass}${table.className}CreateReqVO.class); 80 + ${sceneEnum.prefixClass}${table.className}SaveReqVO createReqVO = randomPojo(${sceneEnum.prefixClass}${table.className}SaveReqVO.class).setId(null);
81 81
82 // 调用 82 // 调用
83 - ${primaryColumn.javaType} ${classNameVar}Id = ${classNameVar}Service.create${simpleClassName}(reqVO); 83 + ${primaryColumn.javaType} ${classNameVar}Id = ${classNameVar}Service.create${simpleClassName}(createReqVO);
84 // 断言 84 // 断言
85 assertNotNull(${classNameVar}Id); 85 assertNotNull(${classNameVar}Id);
86 // 校验记录的属性是否正确 86 // 校验记录的属性是否正确
87 ${table.className}DO ${classNameVar} = ${classNameVar}Mapper.selectById(${classNameVar}Id); 87 ${table.className}DO ${classNameVar} = ${classNameVar}Mapper.selectById(${classNameVar}Id);
88 - assertPojoEquals(reqVO, ${classNameVar}); 88 + assertPojoEquals(createReqVO, ${classNameVar}, "id");
89 } 89 }
90 90
91 @Test 91 @Test
@@ -94,24 +94,24 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest { @@ -94,24 +94,24 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest {
94 ${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class); 94 ${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class);
95 ${classNameVar}Mapper.insert(db${simpleClassName});// @Sql: 先插入出一条存在的数据 95 ${classNameVar}Mapper.insert(db${simpleClassName});// @Sql: 先插入出一条存在的数据
96 // 准备参数 96 // 准备参数
97 - ${sceneEnum.prefixClass}${table.className}UpdateReqVO reqVO = randomPojo(${sceneEnum.prefixClass}${table.className}UpdateReqVO.class, o -> { 97 + ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO = randomPojo(${sceneEnum.prefixClass}${table.className}SaveReqVO.class, o -> {
98 o.setId(db${simpleClassName}.getId()); // 设置更新的 ID 98 o.setId(db${simpleClassName}.getId()); // 设置更新的 ID
99 }); 99 });
100 100
101 // 调用 101 // 调用
102 - ${classNameVar}Service.update${simpleClassName}(reqVO); 102 + ${classNameVar}Service.update${simpleClassName}(updateReqVO);
103 // 校验是否更新正确 103 // 校验是否更新正确
104 - ${table.className}DO ${classNameVar} = ${classNameVar}Mapper.selectById(reqVO.getId()); // 获取最新的  
105 - assertPojoEquals(reqVO, ${classNameVar}); 104 + ${table.className}DO ${classNameVar} = ${classNameVar}Mapper.selectById(updateReqVO.getId()); // 获取最新的
  105 + assertPojoEquals(updateReqVO, ${classNameVar});
106 } 106 }
107 107
108 @Test 108 @Test
109 public void testUpdate${simpleClassName}_notExists() { 109 public void testUpdate${simpleClassName}_notExists() {
110 // 准备参数 110 // 准备参数
111 - ${sceneEnum.prefixClass}${table.className}UpdateReqVO reqVO = randomPojo(${sceneEnum.prefixClass}${table.className}UpdateReqVO.class); 111 + ${sceneEnum.prefixClass}${table.className}SaveReqVO updateReqVO = randomPojo(${sceneEnum.prefixClass}${table.className}SaveReqVO.class);
112 112
113 // 调用, 并断言异常 113 // 调用, 并断言异常
114 - assertServiceException(() -> ${classNameVar}Service.update${simpleClassName}(reqVO), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS); 114 + assertServiceException(() -> ${classNameVar}Service.update${simpleClassName}(updateReqVO), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
115 } 115 }
116 116
117 @Test 117 @Test
@@ -137,6 +137,8 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest { @@ -137,6 +137,8 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest {
137 assertServiceException(() -> ${classNameVar}Service.delete${simpleClassName}(id), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS); 137 assertServiceException(() -> ${classNameVar}Service.delete${simpleClassName}(id), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
138 } 138 }
139 139
  140 +## 特殊:树表专属逻辑(树不需要分页接口)
  141 +#if ( $table.templateType != 2 )
140 @Test 142 @Test
141 @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 143 @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
142 public void testGet${simpleClassName}Page() { 144 public void testGet${simpleClassName}Page() {
@@ -149,11 +151,11 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest { @@ -149,11 +151,11 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest {
149 assertEquals(1, pageResult.getList().size()); 151 assertEquals(1, pageResult.getList().size());
150 assertPojoEquals(db${simpleClassName}, pageResult.getList().get(0)); 152 assertPojoEquals(db${simpleClassName}, pageResult.getList().get(0));
151 } 153 }
152 - 154 +#else
153 @Test 155 @Test
154 @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 156 @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
155 public void testGet${simpleClassName}List() { 157 public void testGet${simpleClassName}List() {
156 - #getPageCondition("ExportReqVO") 158 + #getPageCondition("ListReqVO")
157 159
158 // 调用 160 // 调用
159 List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(reqVO); 161 List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(reqVO);
@@ -161,5 +163,6 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest { @@ -161,5 +163,6 @@ public class ${table.className}ServiceImplTest extends BaseDbUnitTest {
161 assertEquals(1, list.size()); 163 assertEquals(1, list.size());
162 assertPojoEquals(db${simpleClassName}, list.get(0)); 164 assertPojoEquals(db${simpleClassName}, list.get(0));
163 } 165 }
  166 +#end
164 167
165 -} 168 -}
  169 +}
166 \ No newline at end of file 170 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/sql/h2.vm
@@ -23,6 +23,8 @@ CREATE TABLE IF NOT EXISTS &quot;${table.tableName.toLowerCase()}&quot; ( @@ -23,6 +23,8 @@ CREATE TABLE IF NOT EXISTS &quot;${table.tableName.toLowerCase()}&quot; (
23 "${column.columnName}" ${dataType} DEFAULT '', 23 "${column.columnName}" ${dataType} DEFAULT '',
24 #elseif (${column.columnName} == 'deleted') 24 #elseif (${column.columnName} == 'deleted')
25 "deleted" bit NOT NULL DEFAULT FALSE, 25 "deleted" bit NOT NULL DEFAULT FALSE,
  26 + #elseif (${column.columnName} == 'tenantId')
  27 + "tenant_id" bigint NOT NULL DEFAULT 0,
26 #else 28 #else
27 "${column.columnName.toLowerCase()}" ${dataType}#if (${column.nullable} == false) NOT NULL#end, 29 "${column.columnName.toLowerCase()}" ${dataType}#if (${column.nullable} == false) NOT NULL#end,
28 #end 30 #end
@@ -32,4 +34,4 @@ CREATE TABLE IF NOT EXISTS &quot;${table.tableName.toLowerCase()}&quot; ( @@ -32,4 +34,4 @@ CREATE TABLE IF NOT EXISTS &quot;${table.tableName.toLowerCase()}&quot; (
32 ) COMMENT '${table.tableComment}'; 34 ) COMMENT '${table.tableComment}';
33 35
34 -- 将该删表 SQL 语句,添加到 yudao-module-${table.moduleName}-biz 模块的 test/resources/sql/clean.sql 文件里 36 -- 将该删表 SQL 语句,添加到 yudao-module-${table.moduleName}-biz 模块的 test/resources/sql/clean.sql 文件里
35 -DELETE FROM "${table.tableName}"; 37 -DELETE FROM "${table.tableName}";
  38 +DELETE FROM "${table.tableName}";
36 \ No newline at end of file 39 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/sql/sql.vm
@@ -5,7 +5,7 @@ INSERT INTO system_menu( @@ -5,7 +5,7 @@ INSERT INTO system_menu(
5 ) 5 )
6 VALUES ( 6 VALUES (
7 '${table.classComment}管理', '', 2, 0, ${table.parentMenuId}, 7 '${table.classComment}管理', '', 2, 0, ${table.parentMenuId},
8 - '${simpleClassName_strikeCase}', '', '${table.moduleName}/${classNameVar}/index', 0, '${table.className}' 8 + '${simpleClassName_strikeCase}', '', '${table.moduleName}/${table.businessName}/index', 0, '${table.className}'
9 ); 9 );
10 10
11 -- 按钮父菜单ID 11 -- 按钮父菜单ID
@@ -25,4 +25,4 @@ VALUES ( @@ -25,4 +25,4 @@ VALUES (
25 '${table.classComment}${functionName}', '${permissionPrefix}:${functionOps.get($index)}', 3, $foreach.count, @parentId, 25 '${table.classComment}${functionName}', '${permissionPrefix}:${functionOps.get($index)}', 3, $foreach.count, @parentId,
26 '', '', '', 0 26 '', '', '', 0
27 ); 27 );
28 -#end 28 -#end
  29 +#end
29 \ No newline at end of file 30 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm
@@ -15,10 +15,17 @@ export interface ${simpleClassName}VO { @@ -15,10 +15,17 @@ export interface ${simpleClassName}VO {
15 #end 15 #end
16 } 16 }
17 17
18 -// 查询${table.classComment}列表 18 +#if ( $table.templateType != 2 )
  19 +// 查询${table.classComment}分页
19 export const get${simpleClassName}Page = async (params) => { 20 export const get${simpleClassName}Page = async (params) => {
20 return await request.get({ url: `${baseURL}/page`, params }) 21 return await request.get({ url: `${baseURL}/page`, params })
21 } 22 }
  23 +#else
  24 +// 查询${table.classComment}列表
  25 +export const get${simpleClassName}List = async (params) => {
  26 + return await request.get({ url: `${baseURL}/list`, params })
  27 +}
  28 +#end
22 29
23 // 查询${table.classComment}详情 30 // 查询${table.classComment}详情
24 export const get${simpleClassName} = async (id: number) => { 31 export const get${simpleClassName} = async (id: number) => {
@@ -44,3 +51,61 @@ export const delete${simpleClassName} = async (id: number) =&gt; { @@ -44,3 +51,61 @@ export const delete${simpleClassName} = async (id: number) =&gt; {
44 export const export${simpleClassName} = async (params) => { 51 export const export${simpleClassName} = async (params) => {
45 return await request.download({ url: `${baseURL}/export-excel`, params }) 52 return await request.download({ url: `${baseURL}/export-excel`, params })
46 } 53 }
  54 +## 特殊:主子表专属逻辑
  55 +#foreach ($subTable in $subTables)
  56 +#set ($index = $foreach.count - 1)
  57 +#set ($subSimpleClassName = $subSimpleClassNames.get($index))
  58 +#set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段
  59 +#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
  60 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  61 +#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
  62 +#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
  63 +#set ($subClassNameVar = $subClassNameVars.get($index))
  64 +
  65 +// ==================== 子表($subTable.classComment) ====================
  66 +## 情况一:MASTER_ERP 时,需要分查询页子表
  67 +#if ( $table.templateType == 11 )
  68 +
  69 +// 获得${subTable.classComment}分页
  70 +export const get${subSimpleClassName}Page = async (params) => {
  71 + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/page`, params })
  72 +}
  73 +## 情况二:非 MASTER_ERP 时,需要列表查询子表
  74 +#else
  75 + #if ( $subTable.subJoinMany )
  76 +
  77 +// 获得${subTable.classComment}列表
  78 +export const get${subSimpleClassName}ListBy${SubJoinColumnName} = async (${subJoinColumn.javaField}) => {
  79 + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} })
  80 +}
  81 + #else
  82 +
  83 +// 获得${subTable.classComment}
  84 +export const get${subSimpleClassName}By${SubJoinColumnName} = async (${subJoinColumn.javaField}) => {
  85 + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField} })
  86 +}
  87 + #end
  88 +#end
  89 +## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作
  90 +#if ( $table.templateType == 11 )
  91 +// 新增${subTable.classComment}
  92 +export const create${subSimpleClassName} = async (data) => {
  93 + return await request.post({ url: `${baseURL}/${subSimpleClassName_strikeCase}/create`, data })
  94 +}
  95 +
  96 +// 修改${subTable.classComment}
  97 +export const update${subSimpleClassName} = async (data) => {
  98 + return await request.put({ url: `${baseURL}/${subSimpleClassName_strikeCase}/update`, data })
  99 +}
  100 +
  101 +// 删除${subTable.classComment}
  102 +export const delete${subSimpleClassName} = async (id: number) => {
  103 + return await request.delete({ url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id })
  104 +}
  105 +
  106 +// 获得${subTable.classComment}
  107 +export const get${subSimpleClassName} = async (id: number) => {
  108 + return await request.get({ url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id })
  109 +}
  110 +#end
  111 +#end
47 \ No newline at end of file 112 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/components/form_sub_erp.vue.vm 0 → 100644
  1 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
  2 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
  3 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
  4 +<template>
  5 + <Dialog :title="dialogTitle" v-model="dialogVisible">
  6 + <el-form
  7 + ref="formRef"
  8 + :model="formData"
  9 + :rules="formRules"
  10 + label-width="100px"
  11 + v-loading="formLoading"
  12 + >
  13 +#foreach($column in $subColumns)
  14 + #if ($column.createOperation || $column.updateOperation)
  15 + #set ($dictType = $column.dictType)
  16 + #set ($javaField = $column.javaField)
  17 + #set ($javaType = $column.javaType)
  18 + #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  19 + #set ($comment = $column.columnComment)
  20 + #set ($dictMethod = "getDictOptions")## 计算使用哪个 dict 字典方法
  21 + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
  22 + #set ($dictMethod = "getIntDictOptions")
  23 + #elseif ($javaType == "String")
  24 + #set ($dictMethod = "getStrDictOptions")
  25 + #elseif ($javaType == "Boolean")
  26 + #set ($dictMethod = "getBoolDictOptions")
  27 + #end
  28 + #if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
  29 + #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
  30 + <el-form-item label="${comment}" prop="${javaField}">
  31 + <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" />
  32 + </el-form-item>
  33 + #elseif($column.htmlType == "imageUpload")## 图片上传
  34 + <el-form-item label="${comment}" prop="${javaField}">
  35 + <UploadImg v-model="formData.${javaField}" />
  36 + </el-form-item>
  37 + #elseif($column.htmlType == "fileUpload")## 文件上传
  38 + <el-form-item label="${comment}" prop="${javaField}">
  39 + <UploadFile v-model="formData.${javaField}" />
  40 + </el-form-item>
  41 + #elseif($column.htmlType == "editor")## 文本编辑器
  42 + <el-form-item label="${comment}" prop="${javaField}">
  43 + <Editor v-model="formData.${javaField}" height="150px" />
  44 + </el-form-item>
  45 + #elseif($column.htmlType == "select")## 下拉框
  46 + <el-form-item label="${comment}" prop="${javaField}">
  47 + <el-select v-model="formData.${javaField}" placeholder="请选择${comment}">
  48 + #if ("" != $dictType)## 有数据字典
  49 + <el-option
  50 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  51 + :key="dict.value"
  52 + :label="dict.label"
  53 + :value="dict.value"
  54 + />
  55 + #else##没数据字典
  56 + <el-option label="请选择字典生成" value="" />
  57 + #end
  58 + </el-select>
  59 + </el-form-item>
  60 + #elseif($column.htmlType == "checkbox")## 多选框
  61 + <el-form-item label="${comment}" prop="${javaField}">
  62 + <el-checkbox-group v-model="formData.${javaField}">
  63 + #if ("" != $dictType)## 有数据字典
  64 + <el-checkbox
  65 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  66 + :key="dict.value"
  67 + :label="dict.value"
  68 + >
  69 + {{ dict.label }}
  70 + </el-checkbox>
  71 + #else##没数据字典
  72 + <el-checkbox>请选择字典生成</el-checkbox>
  73 + #end
  74 + </el-checkbox-group>
  75 + </el-form-item>
  76 + #elseif($column.htmlType == "radio")## 单选框
  77 + <el-form-item label="${comment}" prop="${javaField}">
  78 + <el-radio-group v-model="formData.${javaField}">
  79 + #if ("" != $dictType)## 有数据字典
  80 + <el-radio
  81 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  82 + :key="dict.value"
  83 + :label="dict.value"
  84 + >
  85 + {{ dict.label }}
  86 + </el-radio>
  87 + #else##没数据字典
  88 + <el-radio label="1">请选择字典生成</el-radio>
  89 + #end
  90 + </el-radio-group>
  91 + </el-form-item>
  92 + #elseif($column.htmlType == "datetime")## 时间框
  93 + <el-form-item label="${comment}" prop="${javaField}">
  94 + <el-date-picker
  95 + v-model="formData.${javaField}"
  96 + type="date"
  97 + value-format="x"
  98 + placeholder="选择${comment}"
  99 + />
  100 + </el-form-item>
  101 + #elseif($column.htmlType == "textarea")## 文本框
  102 + <el-form-item label="${comment}" prop="${javaField}">
  103 + <el-input v-model="formData.${javaField}" type="textarea" placeholder="请输入${comment}" />
  104 + </el-form-item>
  105 + #end
  106 + #end
  107 +#end
  108 + </el-form>
  109 + <template #footer>
  110 + <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
  111 + <el-button @click="dialogVisible = false">取 消</el-button>
  112 + </template>
  113 + </Dialog>
  114 +</template>
  115 +<script setup lang="ts">
  116 +import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
  117 +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
  118 +
  119 +const { t } = useI18n() // 国际化
  120 +const message = useMessage() // 消息弹窗
  121 +
  122 +const dialogVisible = ref(false) // 弹窗的是否展示
  123 +const dialogTitle = ref('') // 弹窗的标题
  124 +const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  125 +const formType = ref('') // 表单的类型:create - 新增;update - 修改
  126 +const formData = ref({
  127 +#foreach ($column in $subColumns)
  128 + #if ($column.createOperation || $column.updateOperation)
  129 + #if ($column.htmlType == "checkbox")
  130 + $column.javaField: [],
  131 + #else
  132 + $column.javaField: undefined,
  133 + #end
  134 + #end
  135 +#end
  136 +})
  137 +const formRules = reactive({
  138 +#foreach ($column in $subColumns)
  139 + #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
  140 + #set($comment=$column.columnComment)
  141 + $column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == 'select')'change'#else'blur'#end }],
  142 + #end
  143 +#end
  144 +})
  145 +const formRef = ref() // 表单 Ref
  146 +
  147 +/** 打开弹窗 */
  148 +const open = async (type: string, id?: number, ${subJoinColumn.javaField}: number) => {
  149 + dialogVisible.value = true
  150 + dialogTitle.value = t('action.' + type)
  151 + formType.value = type
  152 + resetForm()
  153 + formData.value.${subJoinColumn.javaField} = ${subJoinColumn.javaField}
  154 + // 修改时,设置数据
  155 + if (id) {
  156 + formLoading.value = true
  157 + try {
  158 + formData.value = await ${simpleClassName}Api.get${subSimpleClassName}(id)
  159 + } finally {
  160 + formLoading.value = false
  161 + }
  162 + }
  163 +}
  164 +defineExpose({ open }) // 提供 open 方法,用于打开弹窗
  165 +
  166 +/** 提交表单 */
  167 +const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
  168 +const submitForm = async () => {
  169 + // 校验表单
  170 + await formRef.value.validate()
  171 + // 提交请求
  172 + formLoading.value = true
  173 + try {
  174 + const data = formData.value
  175 + if (formType.value === 'create') {
  176 + await ${simpleClassName}Api.create${subSimpleClassName}(data)
  177 + message.success(t('common.createSuccess'))
  178 + } else {
  179 + await ${simpleClassName}Api.update${subSimpleClassName}(data)
  180 + message.success(t('common.updateSuccess'))
  181 + }
  182 + dialogVisible.value = false
  183 + // 发送操作成功的事件
  184 + emit('success')
  185 + } finally {
  186 + formLoading.value = false
  187 + }
  188 +}
  189 +
  190 +/** 重置表单 */
  191 +const resetForm = () => {
  192 + formData.value = {
  193 +#foreach ($column in $subColumns)
  194 + #if ($column.createOperation || $column.updateOperation)
  195 + #if ($column.htmlType == "checkbox")
  196 + $column.javaField: [],
  197 + #else
  198 + $column.javaField: undefined,
  199 + #end
  200 + #end
  201 +#end
  202 + }
  203 + formRef.value?.resetFields()
  204 +}
  205 +</script>
0 \ No newline at end of file 206 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/components/form_sub_inner.vue.vm 0 → 100644
  1 +## 主表的 normal 和 inner 使用相同的 form 表单
  2 +#parse("codegen/vue3/views/components/form_sub_normal.vue.vm")
0 \ No newline at end of file 3 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/components/form_sub_normal.vue.vm 0 → 100644
  1 +#set ($subTable = $subTables.get($subIndex))##当前表
  2 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
  3 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
  4 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
  5 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
  6 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  7 +<template>
  8 +#if ( $subTable.subJoinMany )## 情况一:一对多,table + form
  9 + <el-form
  10 + ref="formRef"
  11 + :model="formData"
  12 + :rules="formRules"
  13 + v-loading="formLoading"
  14 + label-width="0px"
  15 + :inline-message="true"
  16 + >
  17 + <el-table :data="formData" class="-mt-10px">
  18 + <el-table-column label="序号" type="index" width="100" />
  19 +#foreach($column in $subColumns)
  20 + #if ($column.createOperation || $column.updateOperation)
  21 + #set ($dictType = $column.dictType)
  22 + #set ($javaField = $column.javaField)
  23 + #set ($javaType = $column.javaType)
  24 + #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  25 + #set ($comment = $column.columnComment)
  26 + #set ($dictMethod = "getDictOptions")## 计算使用哪个 dict 字典方法
  27 + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
  28 + #set ($dictMethod = "getIntDictOptions")
  29 + #elseif ($javaType == "String")
  30 + #set ($dictMethod = "getStrDictOptions")
  31 + #elseif ($javaType == "Boolean")
  32 + #set ($dictMethod = "getBoolDictOptions")
  33 + #end
  34 + #if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
  35 + #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
  36 + <el-table-column label="${comment}" min-width="150">
  37 + <template #default="{ row, $index }">
  38 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  39 + <el-input v-model="row.${javaField}" placeholder="请输入${comment}" />
  40 + </el-form-item>
  41 + </template>
  42 + </el-table-column>
  43 + #elseif($column.htmlType == "imageUpload")## 图片上传
  44 + <el-table-column label="${comment}" min-width="200">
  45 + <template #default="{ row, $index }">
  46 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  47 + <UploadImg v-model="row.${javaField}" />
  48 + </el-form-item>
  49 + </template>
  50 + </el-table-column>
  51 + #elseif($column.htmlType == "fileUpload")## 文件上传
  52 + <el-table-column label="${comment}" min-width="200">
  53 + <template #default="{ row, $index }">
  54 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  55 + <UploadFile v-model="row.${javaField}" />
  56 + </el-form-item>
  57 + </template>
  58 + </el-table-column>
  59 + #elseif($column.htmlType == "editor")## 文本编辑器
  60 + <el-table-column label="${comment}" min-width="400">
  61 + <template #default="{ row, $index }">
  62 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  63 + <Editor v-model="row.${javaField}" height="150px" />
  64 + </el-form-item>
  65 + </template>
  66 + </el-table-column>
  67 + #elseif($column.htmlType == "select")## 下拉框
  68 + <el-table-column label="${comment}" min-width="150">
  69 + <template #default="{ row, $index }">
  70 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  71 + <el-select v-model="row.${javaField}" placeholder="请选择${comment}">
  72 + #if ("" != $dictType)## 有数据字典
  73 + <el-option
  74 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  75 + :key="dict.value"
  76 + :label="dict.label"
  77 + :value="dict.value"
  78 + />
  79 + #else##没数据字典
  80 + <el-option label="请选择字典生成" value="" />
  81 + #end
  82 + </el-select>
  83 + </el-form-item>
  84 + </template>
  85 + </el-table-column>
  86 + #elseif($column.htmlType == "checkbox")## 多选框
  87 + <el-table-column label="${comment}" min-width="150">
  88 + <template #default="{ row, $index }">
  89 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  90 + <el-checkbox-group v-model="row.${javaField}">
  91 + #if ("" != $dictType)## 有数据字典
  92 + <el-checkbox
  93 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  94 + :key="dict.value"
  95 + :label="dict.value"
  96 + >
  97 + {{ dict.label }}
  98 + </el-checkbox>
  99 + #else##没数据字典
  100 + <el-checkbox>请选择字典生成</el-checkbox>
  101 + #end
  102 + </el-checkbox-group>
  103 + </el-form-item>
  104 + </template>
  105 + </el-table-column>
  106 + #elseif($column.htmlType == "radio")## 单选框
  107 + <el-table-column label="${comment}" min-width="150">
  108 + <template #default="{ row, $index }">
  109 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  110 + <el-radio-group v-model="row.${javaField}">
  111 + #if ("" != $dictType)## 有数据字典
  112 + <el-radio
  113 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  114 + :key="dict.value"
  115 + :label="dict.value"
  116 + >
  117 + {{ dict.label }}
  118 + </el-radio>
  119 + #else##没数据字典
  120 + <el-radio label="1">请选择字典生成</el-radio>
  121 + #end
  122 + </el-radio-group>
  123 + </el-form-item>
  124 + </template>
  125 + </el-table-column>
  126 + #elseif($column.htmlType == "datetime")## 时间框
  127 + <el-table-column label="${comment}" min-width="150">
  128 + <template #default="{ row, $index }">
  129 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  130 + <el-date-picker
  131 + v-model="row.${javaField}"
  132 + type="date"
  133 + value-format="x"
  134 + placeholder="选择${comment}"
  135 + />
  136 + </el-form-item>
  137 + </template>
  138 + </el-table-column>
  139 + #elseif($column.htmlType == "textarea")## 文本框
  140 + <el-table-column label="${comment}" min-width="200">
  141 + <template #default="{ row, $index }">
  142 + <el-form-item :prop="`${$index}.${javaField}`" :rules="formRules.${javaField}" class="mb-0px!">
  143 + <el-input v-model="row.${javaField}" type="textarea" placeholder="请输入${comment}" />
  144 + </el-form-item>
  145 + </template>
  146 + </el-table-column>
  147 + #end
  148 + #end
  149 +#end
  150 + <el-table-column align="center" fixed="right" label="操作" width="60">
  151 + <template #default="{ $index }">
  152 + <el-button @click="handleDelete($index)" link>—</el-button>
  153 + </template>
  154 + </el-table-column>
  155 + </el-table>
  156 + </el-form>
  157 + <el-row justify="center" class="mt-3">
  158 + <el-button @click="handleAdd" round>+ 添加${subTable.classComment}</el-button>
  159 + </el-row>
  160 +#else## 情况二:一对一,form
  161 + <el-form
  162 + ref="formRef"
  163 + :model="formData"
  164 + :rules="formRules"
  165 + label-width="100px"
  166 + v-loading="formLoading"
  167 + >
  168 +#foreach($column in $subColumns)
  169 + #if ($column.createOperation || $column.updateOperation)
  170 + #set ($dictType = $column.dictType)
  171 + #set ($javaField = $column.javaField)
  172 + #set ($javaType = $column.javaType)
  173 + #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  174 + #set ($comment = $column.columnComment)
  175 + #set ($dictMethod = "getDictOptions")## 计算使用哪个 dict 字典方法
  176 + #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
  177 + #set ($dictMethod = "getIntDictOptions")
  178 + #elseif ($javaType == "String")
  179 + #set ($dictMethod = "getStrDictOptions")
  180 + #elseif ($javaType == "Boolean")
  181 + #set ($dictMethod = "getBoolDictOptions")
  182 + #end
  183 + #if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
  184 + #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
  185 + <el-form-item label="${comment}" prop="${javaField}">
  186 + <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" />
  187 + </el-form-item>
  188 + #elseif($column.htmlType == "imageUpload")## 图片上传
  189 + <el-form-item label="${comment}" prop="${javaField}">
  190 + <UploadImg v-model="formData.${javaField}" />
  191 + </el-form-item>
  192 + #elseif($column.htmlType == "fileUpload")## 文件上传
  193 + <el-form-item label="${comment}" prop="${javaField}">
  194 + <UploadFile v-model="formData.${javaField}" />
  195 + </el-form-item>
  196 + #elseif($column.htmlType == "editor")## 文本编辑器
  197 + <el-form-item label="${comment}" prop="${javaField}">
  198 + <Editor v-model="formData.${javaField}" height="150px" />
  199 + </el-form-item>
  200 + #elseif($column.htmlType == "select")## 下拉框
  201 + <el-form-item label="${comment}" prop="${javaField}">
  202 + <el-select v-model="formData.${javaField}" placeholder="请选择${comment}">
  203 + #if ("" != $dictType)## 有数据字典
  204 + <el-option
  205 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  206 + :key="dict.value"
  207 + :label="dict.label"
  208 + :value="dict.value"
  209 + />
  210 + #else##没数据字典
  211 + <el-option label="请选择字典生成" value="" />
  212 + #end
  213 + </el-select>
  214 + </el-form-item>
  215 + #elseif($column.htmlType == "checkbox")## 多选框
  216 + <el-form-item label="${comment}" prop="${javaField}">
  217 + <el-checkbox-group v-model="formData.${javaField}">
  218 + #if ("" != $dictType)## 有数据字典
  219 + <el-checkbox
  220 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  221 + :key="dict.value"
  222 + :label="dict.value"
  223 + >
  224 + {{ dict.label }}
  225 + </el-checkbox>
  226 + #else##没数据字典
  227 + <el-checkbox>请选择字典生成</el-checkbox>
  228 + #end
  229 + </el-checkbox-group>
  230 + </el-form-item>
  231 + #elseif($column.htmlType == "radio")## 单选框
  232 + <el-form-item label="${comment}" prop="${javaField}">
  233 + <el-radio-group v-model="formData.${javaField}">
  234 + #if ("" != $dictType)## 有数据字典
  235 + <el-radio
  236 + v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
  237 + :key="dict.value"
  238 + :label="dict.value"
  239 + >
  240 + {{ dict.label }}
  241 + </el-radio>
  242 + #else##没数据字典
  243 + <el-radio label="1">请选择字典生成</el-radio>
  244 + #end
  245 + </el-radio-group>
  246 + </el-form-item>
  247 + #elseif($column.htmlType == "datetime")## 时间框
  248 + <el-form-item label="${comment}" prop="${javaField}">
  249 + <el-date-picker
  250 + v-model="formData.${javaField}"
  251 + type="date"
  252 + value-format="x"
  253 + placeholder="选择${comment}"
  254 + />
  255 + </el-form-item>
  256 + #elseif($column.htmlType == "textarea")## 文本框
  257 + <el-form-item label="${comment}" prop="${javaField}">
  258 + <el-input v-model="formData.${javaField}" type="textarea" placeholder="请输入${comment}" />
  259 + </el-form-item>
  260 + #end
  261 + #end
  262 +#end
  263 + </el-form>
  264 +#end
  265 +</template>
  266 +<script setup lang="ts">
  267 +import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
  268 +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
  269 +
  270 +const props = defineProps<{
  271 + ${subJoinColumn.javaField}: undefined // ${subJoinColumn.columnComment}(主表的关联字段)
  272 +}>()
  273 +const formLoading = ref(false) // 表单的加载中
  274 +const formData = ref([])
  275 +const formRules = reactive({
  276 +#foreach ($column in $subColumns)
  277 + #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
  278 + #set($comment=$column.columnComment)
  279 + $column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == 'select')'change'#else'blur'#end }],
  280 + #end
  281 +#end
  282 +})
  283 +const formRef = ref() // 表单 Ref
  284 +
  285 +/** 监听主表的关联字段的变化,加载对应的子表数据 */
  286 +watch(
  287 + () => props.${subJoinColumn.javaField},
  288 + async (val) => {
  289 + // 1. 重置表单
  290 +#if ( $subTable.subJoinMany )
  291 + formData.value = []
  292 +#else
  293 + formData.value = {
  294 + #foreach ($column in $subColumns)
  295 + #if ($column.createOperation || $column.updateOperation)
  296 + #if ($column.htmlType == "checkbox")
  297 + $column.javaField: [],
  298 + #else
  299 + $column.javaField: undefined,
  300 + #end
  301 + #end
  302 + #end
  303 + }
  304 +#end
  305 + // 2. val 非空,则加载数据
  306 + if (!val) {
  307 + return;
  308 + }
  309 + try {
  310 + formLoading.value = true
  311 +#if ( $subTable.subJoinMany )
  312 + formData.value = await ${simpleClassName}Api.get${subSimpleClassName}ListBy${SubJoinColumnName}(val)
  313 +#else
  314 + const data = await ${simpleClassName}Api.get${subSimpleClassName}By${SubJoinColumnName}(val)
  315 + if (!data) {
  316 + return
  317 + }
  318 + formData.value = data
  319 +#end
  320 + } finally {
  321 + formLoading.value = false
  322 + }
  323 + },
  324 + { immediate: true }
  325 +)
  326 +#if ( $subTable.subJoinMany )
  327 +
  328 +/** 新增按钮操作 */
  329 +const handleAdd = () => {
  330 + const row = {
  331 +#foreach ($column in $subColumns)
  332 + #if ($column.createOperation || $column.updateOperation)
  333 + #if ($column.htmlType == "checkbox")
  334 + $column.javaField: [],
  335 + #else
  336 + $column.javaField: undefined,
  337 + #end
  338 + #end
  339 +#end
  340 + }
  341 + row.${subJoinColumn.javaField} = props.${subJoinColumn.javaField}
  342 + formData.value.push(row)
  343 +}
  344 +
  345 +/** 删除按钮操作 */
  346 +const handleDelete = (index) => {
  347 + formData.value.splice(index, 1)
  348 +}
  349 +#end
  350 +
  351 +/** 表单校验 */
  352 +const validate = () => {
  353 + return formRef.value.validate()
  354 +}
  355 +
  356 +/** 表单值 */
  357 +const getData = () => {
  358 + return formData.value
  359 +}
  360 +
  361 +defineExpose({ validate, getData })
  362 +</script>
0 \ No newline at end of file 363 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/components/list_sub_erp.vue.vm 0 → 100644
  1 +#set ($subTable = $subTables.get($subIndex))##当前表
  2 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
  3 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
  4 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
  5 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
  6 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
  7 +<template>
  8 + <!-- 列表 -->
  9 + <ContentWrap>
  10 +#if ($table.templateType == 11)
  11 + <el-button
  12 + type="primary"
  13 + plain
  14 + @click="openForm('create')"
  15 + v-hasPermi="['${permissionPrefix}:create']"
  16 + >
  17 + <Icon icon="ep:plus" class="mr-5px" /> 新增
  18 + </el-button>
  19 +#end
  20 + <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  21 + #foreach($column in $subColumns)
  22 + #if ($column.listOperationResult)
  23 + #set ($dictType=$column.dictType)
  24 + #set ($javaField = $column.javaField)
  25 + #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  26 + #set ($comment=$column.columnComment)
  27 + #if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
  28 + #elseif ($column.javaType == "LocalDateTime")## 时间类型
  29 + <el-table-column
  30 + label="${comment}"
  31 + align="center"
  32 + prop="${javaField}"
  33 + :formatter="dateFormatter"
  34 + width="180px"
  35 + />
  36 + #elseif($column.dictType && "" != $column.dictType)## 数据字典
  37 + <el-table-column label="${comment}" align="center" prop="${javaField}">
  38 + <template #default="scope">
  39 + <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" />
  40 + </template>
  41 + </el-table-column>
  42 + #else
  43 + <el-table-column label="${comment}" align="center" prop="${javaField}" />
  44 + #end
  45 + #end
  46 + #end
  47 + #if ($table.templateType == 11)
  48 + <el-table-column label="操作" align="center">
  49 + <template #default="scope">
  50 + <el-button
  51 + link
  52 + type="primary"
  53 + @click="openForm('update', scope.row.id)"
  54 + v-hasPermi="['${permissionPrefix}:update']"
  55 + >
  56 + 编辑
  57 + </el-button>
  58 + <el-button
  59 + link
  60 + type="danger"
  61 + @click="handleDelete(scope.row.id)"
  62 + v-hasPermi="['${permissionPrefix}:delete']"
  63 + >
  64 + 删除
  65 + </el-button>
  66 + </template>
  67 + </el-table-column>
  68 + #end
  69 + </el-table>
  70 + #if ($table.templateType == 11)
  71 + <!-- 分页 -->
  72 + <Pagination
  73 + :total="total"
  74 + v-model:page="queryParams.pageNo"
  75 + v-model:limit="queryParams.pageSize"
  76 + @pagination="getList"
  77 + />
  78 + #end
  79 + </ContentWrap>
  80 +#if ($table.templateType == 11)
  81 + <!-- 表单弹窗:添加/修改 -->
  82 + <${subSimpleClassName}Form ref="formRef" @success="getList" />
  83 +#end
  84 +</template>
  85 +<script setup lang="ts">
  86 +import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
  87 +import { dateFormatter } from '@/utils/formatTime'
  88 +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
  89 +#if ($table.templateType == 11)
  90 +import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue'
  91 +#end
  92 +
  93 +const { t } = useI18n() // 国际化
  94 +const message = useMessage() // 消息弹窗
  95 +
  96 +const props = defineProps<{
  97 + ${subJoinColumn.javaField}: undefined // ${subJoinColumn.columnComment}(主表的关联字段)
  98 +}>()
  99 +const loading = ref(false) // 列表的加载中
  100 +const list = ref([]) // 列表的数据
  101 +#if ($table.templateType == 11)
  102 +const total = ref(0) // 列表的总页数
  103 +const queryParams = reactive({
  104 + pageNo: 1,
  105 + pageSize: 10,
  106 + ${subJoinColumn.javaField}: undefined
  107 +})
  108 +
  109 +/** 监听主表的关联字段的变化,加载对应的子表数据 */
  110 +watch(
  111 + () => props.${subJoinColumn.javaField},
  112 + (val) => {
  113 + queryParams.${subJoinColumn.javaField} = val
  114 + handleQuery()
  115 + },
  116 + { immediate: false }
  117 +)
  118 +#end
  119 +
  120 +/** 查询列表 */
  121 +const getList = async () => {
  122 + loading.value = true
  123 + try {
  124 +#if ($table.templateType == 11)
  125 + const data = await ${simpleClassName}Api.get${subSimpleClassName}Page(queryParams)
  126 + list.value = data.list
  127 + total.value = data.total
  128 +#else
  129 + #if ( $subTable.subJoinMany )
  130 + list.value = await ${simpleClassName}Api.get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField})
  131 + #else
  132 + const data = await ${simpleClassName}Api.get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField})
  133 + if (!data) {
  134 + return
  135 + }
  136 + list.value.push(data)
  137 + #end
  138 +#end
  139 + } finally {
  140 + loading.value = false
  141 + }
  142 +}
  143 +
  144 +/** 搜索按钮操作 */
  145 +const handleQuery = () => {
  146 + queryParams.pageNo = 1
  147 + getList()
  148 +}
  149 +#if ($table.templateType == 11)
  150 +
  151 +/** 添加/修改操作 */
  152 +const formRef = ref()
  153 +const openForm = (type: string, id?: number) => {
  154 + if (!props.${subJoinColumn.javaField}) {
  155 + message.error('请选择一个${table.classComment}')
  156 + return
  157 + }
  158 + formRef.value.open(type, id, props.${subJoinColumn.javaField})
  159 +}
  160 +
  161 +/** 删除按钮操作 */
  162 +const handleDelete = async (id: number) => {
  163 + try {
  164 + // 删除的二次确认
  165 + await message.delConfirm()
  166 + // 发起删除
  167 + await ${simpleClassName}Api.delete${subSimpleClassName}(id)
  168 + message.success(t('common.delSuccess'))
  169 + // 刷新列表
  170 + await getList()
  171 + } catch {}
  172 +}
  173 +#end
  174 +#if ($table.templateType != 11)
  175 +
  176 +/** 初始化 **/
  177 +onMounted(() => {
  178 + getList()
  179 +})
  180 +#end
  181 +</script>
0 \ No newline at end of file 182 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/components/list_sub_inner.vue.vm 0 → 100644
  1 +## 子表的 erp 和 inner 使用相似的 list 列表,差异主要两点:
  2 +## 1)inner 使用 list 不分页,erp 使用 page 分页
  3 +## 2)erp 支持单个子表的新增、修改、删除,inner 不支持
  4 +#parse("codegen/vue3/views/components/list_sub_erp.vue.vm")
0 \ No newline at end of file 5 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm
@@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
7 label-width="100px" 7 label-width="100px"
8 v-loading="formLoading" 8 v-loading="formLoading"
9 > 9 >
10 -#set ($dictMethods = [])## 使用到的 dict 字典方法  
11 #foreach($column in $columns) 10 #foreach($column in $columns)
12 #if ($column.createOperation || $column.updateOperation) 11 #if ($column.createOperation || $column.updateOperation)
13 #set ($dictType = $column.dictType) 12 #set ($dictType = $column.dictType)
@@ -23,31 +22,41 @@ @@ -23,31 +22,41 @@
23 #elseif ($javaType == "Boolean") 22 #elseif ($javaType == "Boolean")
24 #set ($dictMethod = "getBoolDictOptions") 23 #set ($dictMethod = "getBoolDictOptions")
25 #end 24 #end
26 - #if ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里 25 + #if ( $table.templateType == 2 && $column.id == $treeParentColumn.id )
  26 + <el-form-item label="${comment}" prop="${javaField}">
  27 + <el-tree-select
  28 + v-model="formData.${javaField}"
  29 + :data="${classNameVar}Tree"
  30 + #if ($treeNameColumn.javaField == "name")
  31 + :props="defaultProps"
  32 + #else
  33 + :props="{...defaultProps, label: '$treeNameColumn.javaField'}"
  34 + #end
  35 + check-strictly
  36 + default-expand-all
  37 + placeholder="请选择${comment}"
  38 + />
  39 + </el-form-item>
  40 + #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
27 <el-form-item label="${comment}" prop="${javaField}"> 41 <el-form-item label="${comment}" prop="${javaField}">
28 <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" /> 42 <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" />
29 </el-form-item> 43 </el-form-item>
30 #elseif($column.htmlType == "imageUpload")## 图片上传 44 #elseif($column.htmlType == "imageUpload")## 图片上传
31 - #set ($hasImageUploadColumn = true)  
32 - <el-form-item label="${comment}"> 45 + <el-form-item label="${comment}" prop="${javaField}">
33 <UploadImg v-model="formData.${javaField}" /> 46 <UploadImg v-model="formData.${javaField}" />
34 </el-form-item> 47 </el-form-item>
35 #elseif($column.htmlType == "fileUpload")## 文件上传 48 #elseif($column.htmlType == "fileUpload")## 文件上传
36 - #set ($hasFileUploadColumn = true)  
37 - <el-form-item label="${comment}"> 49 + <el-form-item label="${comment}" prop="${javaField}">
38 <UploadFile v-model="formData.${javaField}" /> 50 <UploadFile v-model="formData.${javaField}" />
39 </el-form-item> 51 </el-form-item>
40 #elseif($column.htmlType == "editor")## 文本编辑器 52 #elseif($column.htmlType == "editor")## 文本编辑器
41 - <el-form-item label="${comment}"> 53 + <el-form-item label="${comment}" prop="${javaField}">
42 <Editor v-model="formData.${javaField}" height="150px" /> 54 <Editor v-model="formData.${javaField}" height="150px" />
43 </el-form-item> 55 </el-form-item>
44 #elseif($column.htmlType == "select")## 下拉框 56 #elseif($column.htmlType == "select")## 下拉框
45 <el-form-item label="${comment}" prop="${javaField}"> 57 <el-form-item label="${comment}" prop="${javaField}">
46 <el-select v-model="formData.${javaField}" placeholder="请选择${comment}"> 58 <el-select v-model="formData.${javaField}" placeholder="请选择${comment}">
47 #if ("" != $dictType)## 有数据字典 59 #if ("" != $dictType)## 有数据字典
48 - #if (!$dictMethods.contains($dictMethod))## 如果不存在,则添加到 dictMethods 数组中,后续好 import  
49 - #set($ignore = $dictMethods.add($dictMethod) )  
50 - #end  
51 <el-option 60 <el-option
52 v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())" 61 v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
53 :key="dict.value" 62 :key="dict.value"
@@ -63,9 +72,6 @@ @@ -63,9 +72,6 @@
63 <el-form-item label="${comment}" prop="${javaField}"> 72 <el-form-item label="${comment}" prop="${javaField}">
64 <el-checkbox-group v-model="formData.${javaField}"> 73 <el-checkbox-group v-model="formData.${javaField}">
65 #if ("" != $dictType)## 有数据字典 74 #if ("" != $dictType)## 有数据字典
66 - #if (!$dictMethods.contains($dictMethod))## 如果不存在,则添加到 dictMethods 数组中,后续好 import  
67 - #set($ignore = $dictMethods.add($dictMethod) )  
68 - #end  
69 <el-checkbox 75 <el-checkbox
70 v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())" 76 v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
71 :key="dict.value" 77 :key="dict.value"
@@ -82,9 +88,6 @@ @@ -82,9 +88,6 @@
82 <el-form-item label="${comment}" prop="${javaField}"> 88 <el-form-item label="${comment}" prop="${javaField}">
83 <el-radio-group v-model="formData.${javaField}"> 89 <el-radio-group v-model="formData.${javaField}">
84 #if ("" != $dictType)## 有数据字典 90 #if ("" != $dictType)## 有数据字典
85 - #if (!$dictMethods.contains($dictMethod))## 如果不存在,则添加到 dictMethods 数组中,后续好 import  
86 - #set($ignore = $dictMethods.add($dictMethod) )  
87 - #end  
88 <el-radio 91 <el-radio
89 v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())" 92 v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
90 :key="dict.value" 93 :key="dict.value"
@@ -114,6 +117,21 @@ @@ -114,6 +117,21 @@
114 #end 117 #end
115 #end 118 #end
116 </el-form> 119 </el-form>
  120 +## 特殊:主子表专属逻辑
  121 +#if ( $table.templateType == 10 || $table.templateType == 12 )
  122 + <!-- 子表的表单 -->
  123 + <el-tabs v-model="subTabsName">
  124 + #foreach ($subTable in $subTables)
  125 + #set ($index = $foreach.count - 1)
  126 + #set ($subClassNameVar = $subClassNameVars.get($index))
  127 + #set ($subSimpleClassName = $subSimpleClassNames.get($index))
  128 + #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
  129 + <el-tab-pane label="${subTable.classComment}" name="$subClassNameVar">
  130 + <${subSimpleClassName}Form ref="${subClassNameVar}FormRef" :${subJoinColumn_strikeCase}="formData.id" />
  131 + </el-tab-pane>
  132 + #end
  133 + </el-tabs>
  134 +#end
117 <template #footer> 135 <template #footer>
118 <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button> 136 <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
119 <el-button @click="dialogVisible = false">取 消</el-button> 137 <el-button @click="dialogVisible = false">取 消</el-button>
@@ -121,10 +139,18 @@ @@ -121,10 +139,18 @@
121 </Dialog> 139 </Dialog>
122 </template> 140 </template>
123 <script setup lang="ts"> 141 <script setup lang="ts">
124 -#if ($dictMethods.size() > 0)  
125 -import { DICT_TYPE#foreach ($dictMethod in $dictMethods), ${dictMethod}#end } from '@/utils/dict' 142 +import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
  143 +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
  144 +## 特殊:树表专属逻辑
  145 +#if ( $table.templateType == 2 )
  146 +import { defaultProps, handleTree } from '@/utils/tree'
  147 +#end
  148 +## 特殊:主子表专属逻辑
  149 +#if ( $table.templateType == 10 || $table.templateType == 12 )
  150 +#foreach ($subSimpleClassName in $subSimpleClassNames)
  151 +import ${subSimpleClassName}Form from './components/${subSimpleClassName}Form.vue'
  152 +#end
126 #end 153 #end
127 -import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}'  
128 154
129 const { t } = useI18n() // 国际化 155 const { t } = useI18n() // 国际化
130 const message = useMessage() // 消息弹窗 156 const message = useMessage() // 消息弹窗
@@ -134,37 +160,40 @@ const dialogTitle = ref(&#39;&#39;) // 弹窗的标题 @@ -134,37 +160,40 @@ const dialogTitle = ref(&#39;&#39;) // 弹窗的标题
134 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 160 const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
135 const formType = ref('') // 表单的类型:create - 新增;update - 修改 161 const formType = ref('') // 表单的类型:create - 新增;update - 修改
136 const formData = ref({ 162 const formData = ref({
137 -#set ($listOperationLastIndex = -1)## 求最后一个需要 , 的地方  
138 #foreach ($column in $columns) 163 #foreach ($column in $columns)
139 #if ($column.createOperation || $column.updateOperation) 164 #if ($column.createOperation || $column.updateOperation)
140 - #set ($listOperationLastIndex = $foreach.index)  
141 - #end  
142 -#end  
143 -#foreach ($column in $columns)  
144 - #if ($column.createOperation || $column.updateOperation)  
145 - #if ($column.htmlType == "checkbox")  
146 - $column.javaField: []#if($foreach.index < $listOperationLastIndex),#end  
147 - #else  
148 - $column.javaField: undefined#if($foreach.index < $listOperationLastIndex),#end  
149 - #end 165 + #if ($column.htmlType == "checkbox")
  166 + $column.javaField: [],
  167 + #else
  168 + $column.javaField: undefined,
  169 + #end
150 #end 170 #end
151 #end 171 #end
152 }) 172 })
153 const formRules = reactive({ 173 const formRules = reactive({
154 -#set ($listOperationLastIndex = -1)## 求最后一个需要 , 的地方  
155 -#foreach ($column in $columns)  
156 - #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键  
157 - #set ($listOperationLastIndex = $foreach.index)  
158 - #end  
159 -#end  
160 #foreach ($column in $columns) 174 #foreach ($column in $columns)
161 #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 175 #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
162 #set($comment=$column.columnComment) 176 #set($comment=$column.columnComment)
163 - $column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == 'select')'change'#else'blur'#end }]#if($foreach.index < $listOperationLastIndex),#end 177 + $column.javaField: [{ required: true, message: '${comment}不能为空', trigger: #if($column.htmlType == 'select')'change'#else'blur'#end }],
164 #end 178 #end
165 #end 179 #end
166 }) 180 })
167 const formRef = ref() // 表单 Ref 181 const formRef = ref() // 表单 Ref
  182 +## 特殊:树表专属逻辑
  183 +#if ( $table.templateType == 2 )
  184 +const ${classNameVar}Tree = ref() // 树形结构
  185 +#end
  186 +## 特殊:主子表专属逻辑
  187 +#if ( $table.templateType == 10 || $table.templateType == 12 )
  188 +#if ( $subTables && $subTables.size() > 0 )
  189 +
  190 +/** 子表的表单 */
  191 +const subTabsName = ref('$subClassNameVars.get(0)')
  192 +#foreach ($subClassNameVar in $subClassNameVars)
  193 +const ${subClassNameVar}FormRef = ref()
  194 +#end
  195 +#end
  196 +#end
168 197
169 /** 打开弹窗 */ 198 /** 打开弹窗 */
170 const open = async (type: string, id?: number) => { 199 const open = async (type: string, id?: number) => {
@@ -181,6 +210,10 @@ const open = async (type: string, id?: number) =&gt; { @@ -181,6 +210,10 @@ const open = async (type: string, id?: number) =&gt; {
181 formLoading.value = false 210 formLoading.value = false
182 } 211 }
183 } 212 }
  213 +## 特殊:树表专属逻辑
  214 +#if ( $table.templateType == 2 )
  215 + await get${simpleClassName}Tree()
  216 +#end
184 } 217 }
185 defineExpose({ open }) // 提供 open 方法,用于打开弹窗 218 defineExpose({ open }) // 提供 open 方法,用于打开弹窗
186 219
@@ -188,13 +221,38 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗 @@ -188,13 +221,38 @@ defineExpose({ open }) // 提供 open 方法,用于打开弹窗
188 const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调 221 const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
189 const submitForm = async () => { 222 const submitForm = async () => {
190 // 校验表单 223 // 校验表单
191 - if (!formRef) return  
192 - const valid = await formRef.value.validate()  
193 - if (!valid) return 224 + await formRef.value.validate()
  225 +## 特殊:主子表专属逻辑
  226 +#if ( $table.templateType == 10 || $table.templateType == 12 )
  227 +#if ( $subTables && $subTables.size() > 0 )
  228 + // 校验子表单
  229 + #foreach ($subTable in $subTables)
  230 + #set ($index = $foreach.count - 1)
  231 + #set ($subClassNameVar = $subClassNameVars.get($index))
  232 + try {
  233 + await ${subClassNameVar}FormRef.value.validate()
  234 + } catch (e) {
  235 + subTabsName.value = '${subClassNameVar}'
  236 + return
  237 + }
  238 + #end
  239 +#end
  240 +#end
194 // 提交请求 241 // 提交请求
195 formLoading.value = true 242 formLoading.value = true
196 try { 243 try {
197 const data = formData.value as unknown as ${simpleClassName}Api.${simpleClassName}VO 244 const data = formData.value as unknown as ${simpleClassName}Api.${simpleClassName}VO
  245 +## 特殊:主子表专属逻辑
  246 +#if ( $table.templateType == 10 || $table.templateType == 12 )
  247 +#if ( $subTables && $subTables.size() > 0 )
  248 + // 拼接子表的数据
  249 + #foreach ($subTable in $subTables)
  250 + #set ($index = $foreach.count - 1)
  251 + #set ($subClassNameVar = $subClassNameVars.get($index))
  252 + data.${subClassNameVar}#if ( $subTable.subJoinMany)s#end = ${subClassNameVar}FormRef.value.getData()
  253 + #end
  254 +#end
  255 +#end
198 if (formType.value === 'create') { 256 if (formType.value === 'create') {
199 await ${simpleClassName}Api.create${simpleClassName}(data) 257 await ${simpleClassName}Api.create${simpleClassName}(data)
200 message.success(t('common.createSuccess')) 258 message.success(t('common.createSuccess'))
@@ -213,22 +271,28 @@ const submitForm = async () =&gt; { @@ -213,22 +271,28 @@ const submitForm = async () =&gt; {
213 /** 重置表单 */ 271 /** 重置表单 */
214 const resetForm = () => { 272 const resetForm = () => {
215 formData.value = { 273 formData.value = {
216 -#set ($listOperationLastIndex = -1)## 求最后一个需要 , 的地方  
217 -#foreach ($column in $columns)  
218 - #if ($column.createOperation || $column.updateOperation)  
219 - #set ($listOperationLastIndex = $foreach.index)  
220 - #end  
221 -#end  
222 #foreach ($column in $columns) 274 #foreach ($column in $columns)
223 #if ($column.createOperation || $column.updateOperation) 275 #if ($column.createOperation || $column.updateOperation)
224 #if ($column.htmlType == "checkbox") 276 #if ($column.htmlType == "checkbox")
225 - $column.javaField: []#if($foreach.index < $listOperationLastIndex),#end 277 + $column.javaField: [],
226 #else 278 #else
227 - $column.javaField: undefined#if($foreach.index < $listOperationLastIndex),#end 279 + $column.javaField: undefined,
228 #end 280 #end
229 #end 281 #end
230 #end 282 #end
231 } 283 }
232 formRef.value?.resetFields() 284 formRef.value?.resetFields()
233 } 285 }
234 -</script> 286 +## 特殊:树表专属逻辑
  287 +#if ( $table.templateType == 2 )
  288 +
  289 +/** 获得${table.classComment}树 */
  290 +const get${simpleClassName}Tree = async () => {
  291 + ${classNameVar}Tree.value = []
  292 + const data = await ${simpleClassName}Api.get${simpleClassName}List()
  293 + const root: Tree = { id: 0, name: '顶级${table.classComment}', children: [] }
  294 + root.children = handleTree(data, 'id', '${treeParentColumn.javaField}')
  295 + ${classNameVar}Tree.value.push(root)
  296 +}
  297 +#end
  298 +</script>
235 \ No newline at end of file 299 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
@@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
8 :inline="true" 8 :inline="true"
9 label-width="68px" 9 label-width="68px"
10 > 10 >
11 - #set ($dictMethods = [])## 使用到的 dict 字典方法  
12 #foreach($column in $columns) 11 #foreach($column in $columns)
13 #if ($column.listOperation) 12 #if ($column.listOperation)
14 #set ($dictType = $column.dictType) 13 #set ($dictType = $column.dictType)
@@ -36,20 +35,13 @@ @@ -36,20 +35,13 @@
36 </el-form-item> 35 </el-form-item>
37 #elseif ($column.htmlType == "select" || $column.htmlType == "radio") 36 #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
38 <el-form-item label="${comment}" prop="${javaField}"> 37 <el-form-item label="${comment}" prop="${javaField}">
39 - #if ($javaField.length() + $comment.length() > 8)  
40 <el-select 38 <el-select
41 v-model="queryParams.${javaField}" 39 v-model="queryParams.${javaField}"
42 placeholder="请选择${comment}" 40 placeholder="请选择${comment}"
43 clearable 41 clearable
44 class="!w-240px" 42 class="!w-240px"
45 > 43 >
46 - #else  
47 - <el-select v-model="queryParams.${javaField}" placeholder="请选择${comment}" clearable class="!w-240px">  
48 - #end  
49 #if ("" != $dictType)## 设置了 dictType 数据字典的情况 44 #if ("" != $dictType)## 设置了 dictType 数据字典的情况
50 - #if (!$dictMethods.contains($dictMethod))## 如果不存在,则添加到 dictMethods 数组中,后续好 import  
51 - #set($ignore = $dictMethods.add($dictMethod) )  
52 - #end  
53 <el-option 45 <el-option
54 v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())" 46 v-for="dict in $dictMethod(DICT_TYPE.$dictType.toUpperCase())"
55 :key="dict.value" 47 :key="dict.value"
@@ -92,16 +84,12 @@ @@ -92,16 +84,12 @@
92 <el-form-item> 84 <el-form-item>
93 <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> 85 <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
94 <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> 86 <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
95 - #if ($permissionPrefix.length() <= 12)  
96 - <el-button type="primary" @click="openForm('create')" v-hasPermi="['${permissionPrefix}:create']">  
97 - #else  
98 <el-button 87 <el-button
99 type="primary" 88 type="primary"
100 plain 89 plain
101 @click="openForm('create')" 90 @click="openForm('create')"
102 v-hasPermi="['${permissionPrefix}:create']" 91 v-hasPermi="['${permissionPrefix}:create']"
103 > 92 >
104 - #end  
105 <Icon icon="ep:plus" class="mr-5px" /> 新增 93 <Icon icon="ep:plus" class="mr-5px" /> 新增
106 </el-button> 94 </el-button>
107 <el-button 95 <el-button
@@ -113,13 +101,61 @@ @@ -113,13 +101,61 @@
113 > 101 >
114 <Icon icon="ep:download" class="mr-5px" /> 导出 102 <Icon icon="ep:download" class="mr-5px" /> 导出
115 </el-button> 103 </el-button>
  104 +## 特殊:树表专属逻辑
  105 +#if ( $table.templateType == 2 )
  106 + <el-button type="danger" plain @click="toggleExpandAll">
  107 + <Icon icon="ep:sort" class="mr-5px" /> 展开/折叠
  108 + </el-button>
  109 +#end
116 </el-form-item> 110 </el-form-item>
117 </el-form> 111 </el-form>
118 </ContentWrap> 112 </ContentWrap>
119 113
120 <!-- 列表 --> 114 <!-- 列表 -->
121 <ContentWrap> 115 <ContentWrap>
  116 +## 特殊:主子表专属逻辑
  117 +#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
  118 + <el-table
  119 + v-loading="loading"
  120 + :data="list"
  121 + :stripe="true"
  122 + :show-overflow-tooltip="true"
  123 + highlight-current-row
  124 + @current-change="handleCurrentChange"
  125 + >
  126 +## 特殊:树表专属逻辑
  127 +#elseif ( $table.templateType == 2 )
  128 + <el-table
  129 + v-loading="loading"
  130 + :data="list"
  131 + :stripe="true"
  132 + :show-overflow-tooltip="true"
  133 + row-key="id"
  134 + :default-expand-all="isExpandAll"
  135 + v-if="refreshTable"
  136 + >
  137 +#else
122 <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> 138 <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  139 +#end
  140 +## 特殊:主子表专属逻辑
  141 +#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
  142 + <!-- 子表的列表 -->
  143 + <el-table-column type="expand">
  144 + <template #default="scope">
  145 + <el-tabs model-value="$subClassNameVars.get(0)">
  146 + #foreach ($subTable in $subTables)
  147 + #set ($index = $foreach.count - 1)
  148 + #set ($subClassNameVar = $subClassNameVars.get($index))
  149 + #set ($subSimpleClassName = $subSimpleClassNames.get($index))
  150 + #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
  151 + <el-tab-pane label="${subTable.classComment}" name="$subClassNameVar">
  152 + <${subSimpleClassName}List :${subJoinColumn_strikeCase}="scope.row.id" />
  153 + </el-tab-pane>
  154 + #end
  155 + </el-tabs>
  156 + </template>
  157 + </el-table-column>
  158 +#end
123 #foreach($column in $columns) 159 #foreach($column in $columns)
124 #if ($column.listOperationResult) 160 #if ($column.listOperationResult)
125 #set ($dictType=$column.dictType) 161 #set ($dictType=$column.dictType)
@@ -134,7 +170,7 @@ @@ -134,7 +170,7 @@
134 :formatter="dateFormatter" 170 :formatter="dateFormatter"
135 width="180px" 171 width="180px"
136 /> 172 />
137 - #elseif("" != $column.dictType)## 数据字典 173 + #elseif($column.dictType && "" != $column.dictType)## 数据字典
138 <el-table-column label="${comment}" align="center" prop="${javaField}"> 174 <el-table-column label="${comment}" align="center" prop="${javaField}">
139 <template #default="scope"> 175 <template #default="scope">
140 <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" /> 176 <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" />
@@ -177,21 +213,41 @@ @@ -177,21 +213,41 @@
177 213
178 <!-- 表单弹窗:添加/修改 --> 214 <!-- 表单弹窗:添加/修改 -->
179 <${simpleClassName}Form ref="formRef" @success="getList" /> 215 <${simpleClassName}Form ref="formRef" @success="getList" />
  216 +## 特殊:主子表专属逻辑
  217 +#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
  218 + <!-- 子表的列表 -->
  219 + <ContentWrap>
  220 + <el-tabs model-value="$subClassNameVars.get(0)">
  221 + #foreach ($subTable in $subTables)
  222 + #set ($index = $foreach.count - 1)
  223 + #set ($subClassNameVar = $subClassNameVars.get($index))
  224 + #set ($subSimpleClassName = $subSimpleClassNames.get($index))
  225 + #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
  226 + <el-tab-pane label="${subTable.classComment}" name="$subClassNameVar">
  227 + <${subSimpleClassName}List :${subJoinColumn_strikeCase}="currentRow.id" />
  228 + </el-tab-pane>
  229 + #end
  230 + </el-tabs>
  231 + </ContentWrap>
  232 +#end
180 </template> 233 </template>
181 234
182 <script setup lang="ts"> 235 <script setup lang="ts">
183 -#if ($dictMethods.size() > 0)  
184 -import { DICT_TYPE#foreach ($dictMethod in $dictMethods), ${dictMethod}#end } from '@/utils/dict'  
185 -#end  
186 -#foreach ($column in $columns)  
187 - #if ($column.listOperationResult && $column.htmlType == "datetime") 236 +import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
188 import { dateFormatter } from '@/utils/formatTime' 237 import { dateFormatter } from '@/utils/formatTime'
189 - #break  
190 - #end 238 +## 特殊:树表专属逻辑
  239 +#if ( $table.templateType == 2 )
  240 +import { handleTree } from '@/utils/tree'
191 #end 241 #end
192 import download from '@/utils/download' 242 import download from '@/utils/download'
193 -import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' 243 +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
194 import ${simpleClassName}Form from './${simpleClassName}Form.vue' 244 import ${simpleClassName}Form from './${simpleClassName}Form.vue'
  245 +## 特殊:主子表专属逻辑
  246 +#if ( $table.templateType != 10 )
  247 +#foreach ($subSimpleClassName in $subSimpleClassNames)
  248 +import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue'
  249 +#end
  250 +#end
195 251
196 defineOptions({ name: '${table.className}' }) 252 defineOptions({ name: '${table.className}' })
197 253
@@ -199,24 +255,24 @@ const message = useMessage() // 消息弹窗 @@ -199,24 +255,24 @@ const message = useMessage() // 消息弹窗
199 const { t } = useI18n() // 国际化 255 const { t } = useI18n() // 国际化
200 256
201 const loading = ref(true) // 列表的加载中 257 const loading = ref(true) // 列表的加载中
202 -const total = ref(0) // 列表的总页数  
203 const list = ref([]) // 列表的数据 258 const list = ref([]) // 列表的数据
  259 +## 特殊:树表专属逻辑(树不需要分页接口)
  260 +#if ( $table.templateType != 2 )
  261 +const total = ref(0) // 列表的总页数
  262 +#end
204 const queryParams = reactive({ 263 const queryParams = reactive({
  264 +## 特殊:树表专属逻辑(树不需要分页接口)
  265 +#if ( $table.templateType != 2 )
205 pageNo: 1, 266 pageNo: 1,
206 pageSize: 10, 267 pageSize: 10,
207 - #set ($listOperationLastIndex = -1)## 求最后一个需要 , 的地方  
208 - #foreach ($column in $columns)  
209 - #if ($column.listOperation)  
210 - #set ($listOperationLastIndex = $foreach.index)  
211 - #end  
212 - #end 268 +#end
213 #foreach ($column in $columns) 269 #foreach ($column in $columns)
214 #if ($column.listOperation) 270 #if ($column.listOperation)
215 #if ($column.listOperationCondition != 'BETWEEN') 271 #if ($column.listOperationCondition != 'BETWEEN')
216 - $column.javaField: null#if($foreach.index < $listOperationLastIndex),#end 272 + $column.javaField: null,
217 #end 273 #end
218 #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") 274 #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN")
219 - $column.javaField: []#if($foreach.index < $listOperationLastIndex),#end 275 + $column.javaField: [],
220 #end 276 #end
221 #end 277 #end
222 #end 278 #end
@@ -228,9 +284,15 @@ const exportLoading = ref(false) // 导出的加载中 @@ -228,9 +284,15 @@ const exportLoading = ref(false) // 导出的加载中
228 const getList = async () => { 284 const getList = async () => {
229 loading.value = true 285 loading.value = true
230 try { 286 try {
  287 +## 特殊:树表专属逻辑(树不需要分页接口)
  288 + #if ( $table.templateType == 2 )
  289 + const data = await ${simpleClassName}Api.get${simpleClassName}List(queryParams)
  290 + list.value = handleTree(data, 'id', '${treeParentColumn.javaField}')
  291 + #else
231 const data = await ${simpleClassName}Api.get${simpleClassName}Page(queryParams) 292 const data = await ${simpleClassName}Api.get${simpleClassName}Page(queryParams)
232 list.value = data.list 293 list.value = data.list
233 total.value = data.total 294 total.value = data.total
  295 + #end
234 } finally { 296 } finally {
235 loading.value = false 297 loading.value = false
236 } 298 }
@@ -281,9 +343,31 @@ const handleExport = async () =&gt; { @@ -281,9 +343,31 @@ const handleExport = async () =&gt; {
281 exportLoading.value = false 343 exportLoading.value = false
282 } 344 }
283 } 345 }
  346 +## 特殊:主子表专属逻辑
  347 +#if ( $table.templateType == 11 )
  348 +
  349 +/** 选中行操作 */
  350 +const currentRow = ref({}) // 选中行
  351 +const handleCurrentChange = (row) => {
  352 + currentRow.value = row
  353 +}
  354 +#end
  355 +## 特殊:树表专属逻辑
  356 +#if ( $table.templateType == 2 )
  357 +
  358 +/** 展开/折叠操作 */
  359 +const isExpandAll = ref(true) // 是否展开,默认全部展开
  360 +const refreshTable = ref(true) // 重新渲染表格状态
  361 +const toggleExpandAll = async () => {
  362 + refreshTable.value = false
  363 + isExpandAll.value = !isExpandAll.value
  364 + await nextTick()
  365 + refreshTable.value = true
  366 +}
  367 +#end
284 368
285 /** 初始化 **/ 369 /** 初始化 **/
286 onMounted(() => { 370 onMounted(() => {
287 getList() 371 getList()
288 }) 372 })
289 -</script> 373 -</script>
  374 +</script>
290 \ No newline at end of file 375 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm
1 import type { CrudSchema } from '@/hooks/web/useCrudSchemas' 1 import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
2 -#foreach ($column in $columns)  
3 - #if ($column.listOperationResult && $column.htmlType == "datetime")  
4 import { dateFormatter } from '@/utils/formatTime' 2 import { dateFormatter } from '@/utils/formatTime'
5 - #break  
6 - #end  
7 -#end  
8 3
9 // 表单校验 4 // 表单校验
10 export const rules = reactive({ 5 export const rules = reactive({
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/form.vue.vm
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 </Dialog> 8 </Dialog>
9 </template> 9 </template>
10 <script setup lang="ts"> 10 <script setup lang="ts">
11 - import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' 11 +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
12 import { rules, allSchemas } from './${classNameVar}.data' 12 import { rules, allSchemas } from './${classNameVar}.data'
13 const { t } = useI18n() // 国际化 13 const { t } = useI18n() // 国际化
14 const message = useMessage() // 消息弹窗 14 const message = useMessage() // 消息弹窗
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/index.vue.vm
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 </template> 54 </template>
55 <script setup lang="ts" name="${table.className}"> 55 <script setup lang="ts" name="${table.className}">
56 import { allSchemas } from './${classNameVar}.data' 56 import { allSchemas } from './${classNameVar}.data'
57 -import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' 57 +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}'
58 import ${simpleClassName}Form from './${simpleClassName}Form.vue' 58 import ${simpleClassName}Form from './${simpleClassName}Form.vue'
59 59
60 // tableObject:表格的属性对象,可获得分页大小、条数等属性 60 // tableObject:表格的属性对象,可获得分页大小、条数等属性
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/form.vue.vm
@@ -5,7 +5,7 @@ import { useI18n } from &#39;@/hooks/web/useI18n&#39; @@ -5,7 +5,7 @@ import { useI18n } from &#39;@/hooks/web/useI18n&#39;
5 import { useMessage } from '@/hooks/web/useMessage' 5 import { useMessage } from '@/hooks/web/useMessage'
6 import { BasicForm, useForm } from '@/components/Form' 6 import { BasicForm, useForm } from '@/components/Form'
7 import { BasicModal, useModalInner } from '@/components/Modal' 7 import { BasicModal, useModalInner } from '@/components/Modal'
8 -import { create${simpleClassName}, get${simpleClassName}, update${simpleClassName} } from '@/api/${table.moduleName}/${classNameVar}' 8 +import { create${simpleClassName}, get${simpleClassName}, update${simpleClassName} } from '@/api/${table.moduleName}/${table.businessName}'
9 9
10 defineOptions({ name: '${table.className}Modal' }) 10 defineOptions({ name: '${table.className}Modal' })
11 11
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben/views/index.vue.vm
@@ -5,7 +5,7 @@ import { useI18n } from &#39;@/hooks/web/useI18n&#39; @@ -5,7 +5,7 @@ import { useI18n } from &#39;@/hooks/web/useI18n&#39;
5 import { useMessage } from '@/hooks/web/useMessage' 5 import { useMessage } from '@/hooks/web/useMessage'
6 import { useModal } from '@/components/Modal' 6 import { useModal } from '@/components/Modal'
7 import { useTable } from '@/components/Table' 7 import { useTable } from '@/components/Table'
8 -import { delete${simpleClassName}, export${simpleClassName}, get${simpleClassName}Page } from '@/api/${table.moduleName}/${classNameVar}' 8 +import { delete${simpleClassName}, export${simpleClassName}, get${simpleClassName}Page } from '@/api/${table.moduleName}/${table.businessName}'
9 9
10 defineOptions({ name: '${table.className}' }) 10 defineOptions({ name: '${table.className}' })
11 11
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/null/.gitkeep deleted
yudao-module-infra/yudao-module-infra-biz/src/test-integration/java/cn/iocoder/yudao/module/infra/dal/mysql/codegen/SchemaColumnMapperTest.java deleted
1 -package cn.iocoder.yudao.module.infra.dal.mysql.codegen;  
2 -  
3 -import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaColumnDO;  
4 -import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest;  
5 -import org.junit.jupiter.api.Test;  
6 -  
7 -import javax.annotation.Resource;  
8 -import java.util.List;  
9 -  
10 -import static org.junit.jupiter.api.Assertions.assertTrue;  
11 -  
12 -public class SchemaColumnMapperTest extends BaseDbUnitTest {  
13 -  
14 - @Resource  
15 - private SchemaColumnMapper schemaColumnMapper;  
16 -  
17 - @Test  
18 - public void testSelectListByTableName() {  
19 - List<SchemaColumnDO> columns = schemaColumnMapper.selectListByTableName("", "inf_config");  
20 - assertTrue(columns.size() > 0);  
21 - }  
22 -  
23 -}  
yudao-module-infra/yudao-module-infra-biz/src/test-integration/java/cn/iocoder/yudao/module/infra/dal/package-info.java deleted
1 -/**  
2 - * 占位  
3 - */  
4 -package cn.iocoder.yudao.module.infra.dal;  
yudao-module-infra/yudao-module-infra-biz/src/test-integration/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenEngineTest.java deleted
1 -package cn.iocoder.yudao.module.infra.service.codegen;  
2 -  
3 -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO;  
4 -import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO;  
5 -import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenColumnMapper;  
6 -import cn.iocoder.yudao.module.infra.dal.mysql.codegen.CodegenTableMapper;  
7 -import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenEngine;  
8 -import cn.iocoder.yudao.module.infra.test.BaseDbUnitTest;  
9 -import org.junit.jupiter.api.Test;  
10 -  
11 -import javax.annotation.Resource;  
12 -import java.util.List;  
13 -import java.util.Map;  
14 -  
15 -public class CodegenEngineTest extends BaseDbUnitTest {  
16 -  
17 - @Resource  
18 - private CodegenTableMapper codegenTableMapper;  
19 - @Resource  
20 - private CodegenColumnMapper codegenColumnMapper;  
21 -  
22 - @Resource  
23 - private CodegenEngine codegenEngine;  
24 -  
25 - @Test  
26 - public void testExecute() {  
27 - CodegenTableDO table = codegenTableMapper.selectById(20);  
28 - List<CodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId());  
29 - Map<String, String> result = codegenEngine.execute(table, columns);  
30 - result.forEach((s, s2) -> System.out.println(s2));  
31 -// System.out.println(result.get("vue/views/system/test/index.vue"));  
32 - }  
33 -  
34 -}  
yudao-module-infra/yudao-module-infra-biz/src/test-integration/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenSQLParserTest.java deleted
1 -package cn.iocoder.yudao.module.infra.service.codegen;  
2 -  
3 -import cn.iocoder.yudao.module.infra.service.codegen.inner.CodegenSQLParser;  
4 -import cn.iocoder.yudao.module.infra.test.BaseDbUnitTest;  
5 -import org.junit.jupiter.api.Test;  
6 -  
7 -public class CodegenSQLParserTest extends BaseDbUnitTest {  
8 -  
9 - @Test  
10 - public void testParse() {  
11 - String sql = "CREATE TABLE `infra_test_demo` (\n" +  
12 - " `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '编号',\n" +  
13 - " `name` varchar(100) NOT NULL DEFAULT '' COMMENT '名字',\n" +  
14 - " `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态',\n" +  
15 - " `type` tinyint(4) NOT NULL COMMENT '类型',\n" +  
16 - " `category` tinyint(4) NOT NULL COMMENT '分类',\n" +  
17 - " `remark` varchar(500) DEFAULT NULL COMMENT '备注',\n" +  
18 - " `create_by` varchar(64) DEFAULT '' COMMENT '创建者',\n" +  
19 - " `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',\n" +  
20 - " `update_by` varchar(64) DEFAULT '' COMMENT '更新者',\n" +  
21 - " `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',\n" +  
22 - " `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',\n" +  
23 - " PRIMARY KEY (`id`) USING BTREE\n" +  
24 - ") ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8mb4 COMMENT='字典类型表';";  
25 - CodegenSQLParser.parse(sql);  
26 - // TODO 芋艿:后续完善断言  
27 - }  
28 -  
29 -}