From fa04f598882c1325ee0a088040c905ef14af9f21 Mon Sep 17 00:00:00 2001 From: Alan <3052806735@qq.com> Date: Thu, 6 Jun 2024 20:34:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=AE=E6=A0=87=E7=B1=BB=E5=9E=8B=EF=BC=88?= =?UTF-8?q?=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5=EF=BC=89=20=E6=80=BB?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=EF=BC=8C=E5=88=86=E7=9B=AE=E6=A0=87=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E5=AF=B9=E5=BA=94=E7=9A=84=E5=86=85=E5=AE=B9=EF=BC=88?= =?UTF-8?q?=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5=EF=BC=89--=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=9C=89=E9=99=90=E5=AE=9A=20=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E7=9A=84=E6=9F=A5=E8=AF=A2=EF=BC=88=E6=8C=89?= =?UTF-8?q?id=E6=9F=A5=EF=BC=89=20=E8=AF=BE=E7=A8=8B=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=9A=82=E6=9C=AA=E5=AE=8C=E6=88=90=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8?= =?UTF-8?q?objective=5Fcontents=E5=92=8Cobjectives=5Ftype?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/teaching2.0.sql | 239 ++++++++++++++++++ .../teaching/backend/common/ErrorCode.java | 3 +- .../teaching/backend/common/ResultUtils.java | 2 +- .../courses/CourseObjectivesController.java | 14 + .../controller/courses/CoursesController.java | 11 +- .../courses/ObjectiveContentsController.java | 50 ++++ .../courses/ObjectivesTypeController.java | 69 +++++ .../exception/GlobalExceptionHandler.java | 45 ++++ .../courses/CourseObjectivesMapper.java | 4 + .../courses/ObjectiveContentsMapper.java | 16 ++ .../mapper/courses/ObjectivesTypeMapper.java | 17 ++ .../dto/courses/CourseObjectivesDTO.java | 20 +- .../backend/model/dto/courses/CoursesDTO.java | 8 +- .../entity/courses/CourseObjectives.java | 4 +- .../entity/courses/ObjectiveContents.java | 40 +++ .../model/entity/courses/ObjectivesType.java | 38 +++ .../backend/model/query/PageQuery.java | 2 +- .../model/vo/CourseObjectivesTreeVO.java | 26 ++ .../courses/ICourseObjectivesService.java | 20 ++ .../service/courses/ICoursesService.java | 3 + .../courses/IObjectiveContentsService.java | 18 ++ .../courses/IObjectivesTypeService.java | 16 ++ .../courses/CourseObjectivesServiceImpl.java | 150 ++++++++--- .../impl/courses/CoursesServiceImpl.java | 42 ++- .../courses/ObjectiveContentsServiceImpl.java | 21 ++ .../courses/ObjectivesTypeServiceImpl.java | 20 ++ src/main/resources/application.yml | 12 +- .../mapper/CourseObjectivesMapper.xml | 13 +- src/main/resources/mapper/CoursesMapper.xml | 2 +- .../mapper/ObjectiveContentsMapper.xml | 5 + .../resources/mapper/ObjectivesTypeMapper.xml | 5 + 31 files changed, 869 insertions(+), 66 deletions(-) create mode 100644 sql/teaching2.0.sql create mode 100644 src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java create mode 100644 src/main/java/com/teaching/backend/controller/courses/ObjectivesTypeController.java create mode 100644 src/main/java/com/teaching/backend/exception/GlobalExceptionHandler.java create mode 100644 src/main/java/com/teaching/backend/mapper/courses/ObjectiveContentsMapper.java create mode 100644 src/main/java/com/teaching/backend/mapper/courses/ObjectivesTypeMapper.java create mode 100644 src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java create mode 100644 src/main/java/com/teaching/backend/model/entity/courses/ObjectivesType.java create mode 100644 src/main/java/com/teaching/backend/model/vo/CourseObjectivesTreeVO.java create mode 100644 src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java create mode 100644 src/main/java/com/teaching/backend/service/courses/IObjectivesTypeService.java create mode 100644 src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java create mode 100644 src/main/java/com/teaching/backend/service/impl/courses/ObjectivesTypeServiceImpl.java create mode 100644 src/main/resources/mapper/ObjectiveContentsMapper.xml create mode 100644 src/main/resources/mapper/ObjectivesTypeMapper.xml diff --git a/sql/teaching2.0.sql b/sql/teaching2.0.sql new file mode 100644 index 0000000..fccb1d5 --- /dev/null +++ b/sql/teaching2.0.sql @@ -0,0 +1,239 @@ +/* +SQLyog Ultimate v12.09 (64 bit) +MySQL - 8.0.12 : Database - teaching_db +********************************************************************* +*/ + +/*!40101 SET NAMES utf8 */; + +/*!40101 SET SQL_MODE=''*/; + +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; +CREATE DATABASE /*!32312 IF NOT EXISTS*/`teaching_db` /*!40100 DEFAULT CHARACTER SET utf8 */; + +USE `teaching_db`; + +/*Table structure for table `course_objectives` */ + +DROP TABLE IF EXISTS `course_objectives`; + +CREATE TABLE `course_objectives` ( + `id` varchar(36) NOT NULL COMMENT '内部编号', + `create_time` datetime DEFAULT NULL COMMENT '创建日期', + `update_time` datetime DEFAULT NULL COMMENT '更新日期', + `pid` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '父级节点 默认0没有', + `has_child` varchar(3) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '0' COMMENT '是否有子节点 添加子节点变1,默认0没有', + `name` varchar(200) DEFAULT NULL COMMENT '目标名称', + `type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '目标类型', + `course_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '课程id', + `requireid` varchar(32) DEFAULT NULL COMMENT '毕业要求id', + `temp` text COMMENT '毕业要求', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/*Data for the table `course_objectives` */ + +insert into `course_objectives`(`id`,`create_time`,`update_time`,`pid`,`has_child`,`name`,`type`,`course_id`,`requireid`,`temp`) values ('3e42492c201d2a9378be5af2edc92b47','2024-06-06 16:17:39',NULL,'0','0','近代史纲要课程总体目标',NULL,'d8d7bb93f100164659cac44ef2c4f55a',NULL,NULL),('43f2c4b4a10a47784e50e772b9d10457','2024-05-31 17:39:13',NULL,'0','0','测试课程课程总体目标',NULL,'6f5de6dd8c8d5d9d02a63c8444b9d5bb',NULL,NULL),('503dc084653ffd003cb404b62266dc7c','2024-06-06 15:58:43',NULL,'da6e7283befa8965dae0f0f39ea7f24e','0','知识目标','c126ef1a66733ab7a4ba12aba0eb7f82',NULL,NULL,NULL),('53b27c94fe8af02ac8b23d9be9a2e329','2024-06-03 11:32:19',NULL,'da6e7283befa8965dae0f0f39ea7f24e','0','思政目标','71f73bd999f678bcbbdb101e23277feb',NULL,NULL,NULL),('7a302cd72d653647778840b42f4e076a','2024-06-03 10:43:13',NULL,'0','0','软件构造课程总体目标',NULL,'ee2447b4463a5ad3f47e1744d912a824',NULL,NULL),('aa839ff1345a04f95b4efcca02494cab','2024-06-06 16:45:22',NULL,'0','0','毛概课程总体目标',NULL,'72e1ad71bb855ba328f8c17964697354',NULL,NULL),('b41fa8332f39cca11d35635bd9fac720','2024-05-31 11:24:33',NULL,'0','0','计算机导论课程总体目标',NULL,'2fa0fd63262230639d2c45a3acd9045c',NULL,NULL),('c84dc451086f7938c28a4f757957f415','2024-06-06 15:58:19',NULL,'da6e7283befa8965dae0f0f39ea7f24e','0','价值目标','410fc58cd757cd248941af1bea6888e5',NULL,NULL,NULL),('d452f583115465d067a1719458690b95','2024-05-31 11:16:37',NULL,'0','0','计算机组成原理总体目标',NULL,'36c34a4225526dd20ee3840da61d3701',NULL,NULL),('da6e7283befa8965dae0f0f39ea7f24e','2024-05-31 20:49:52','2024-06-06 15:58:43','0','1','离散数学及其应用课程总体目标',NULL,'de3100cad98f76be3176dd39aa748a9e',NULL,NULL); + +/*Table structure for table `courses` */ + +DROP TABLE IF EXISTS `courses`; + +CREATE TABLE `courses` ( + `id` varchar(36) NOT NULL COMMENT '内部编号', + `create_time` datetime DEFAULT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `img` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '课程封面', + `category` varchar(50) DEFAULT NULL COMMENT '课程类别', + `nature` varchar(50) DEFAULT NULL COMMENT '课程性质', + `name` varchar(100) DEFAULT NULL COMMENT '课程名称', + `code` varchar(50) DEFAULT NULL COMMENT '课程编码', + `semester` varchar(50) DEFAULT NULL COMMENT '开课学期', + `credit` decimal(5,2) DEFAULT NULL COMMENT '课程学分', + `classhours` int(11) DEFAULT NULL COMMENT '课程学时', + `theoryhours` int(11) DEFAULT NULL COMMENT '理论学时', + `practicehours` int(11) DEFAULT NULL COMMENT '实践学时', + `experimenthours` int(11) DEFAULT NULL COMMENT '实验学时', + `otherhours` int(11) DEFAULT NULL COMMENT '其他学时', + `weeks` int(11) DEFAULT NULL COMMENT '上课周数', + `assessmenttype` varchar(32) DEFAULT NULL COMMENT '考核类型', + `assessmentway` varchar(32) DEFAULT NULL COMMENT '考核方式', + `teacher` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '负责教师', + `teachermethod` text COMMENT '教学方法', + `teacherway` text COMMENT '教学方式', + `description` text COMMENT '课程简介', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/*Data for the table `courses` */ + +insert into `courses`(`id`,`create_time`,`update_time`,`img`,`category`,`nature`,`name`,`code`,`semester`,`credit`,`classhours`,`theoryhours`,`practicehours`,`experimenthours`,`otherhours`,`weeks`,`assessmenttype`,`assessmentway`,`teacher`,`teachermethod`,`teacherway`,`description`) values ('2fa0fd63262230639d2c45a3acd9045c','2024-05-30 20:58:34',NULL,'','1','1','计算机导论12','111007',NULL,'4.50',64,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334,2140110339','暂定','线下授课',NULL),('36c34a4225526dd20ee3840da61d3701','2024-05-28 20:58:36',NULL,'','1','1','计算机组成原理','111006',NULL,'4.00',64,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334,2140110339','暂定','线下授课',NULL),('6f5de6dd8c8d5d9d02a63c8444b9d5bb','2024-05-26 20:58:40',NULL,'','1','1','测试课程','111008',NULL,'4.00',64,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334,2140110339','暂定','线下授课',NULL),('72e1ad71bb855ba328f8c17964697354','2024-06-06 16:45:22',NULL,'http://teaching-edu123.oss-cn-beijing.aliyuncs.com/KdxGCt8rKbruw3zEDTdkA.jpg','1','1','毛概','111012',NULL,'3.60',48,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334','暂定','线下授课',NULL),('8721e6864387eb99b04692f125ac0a9f','2024-05-27 20:58:43',NULL,'','1','1','SQLServer数据库教程','111004',NULL,'4.00',0,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334,2140110327','暂定111','线下机房授课',NULL),('90ce365ae4e362f616776550e04ae0b4','2024-05-24 20:58:48',NULL,'','1','1','JavaEE','111002',NULL,'4.00',0,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334,2140110327','暂定','线下机房授课',NULL),('a2ba84374d86e85208c5906a96ea8205','2024-05-24 20:58:48',NULL,'https://teaching-edu123.oss-cn-beijing.aliyuncs.com/Borovets_ZH-CN5914681811_UHD.jpg','1','1','JavaWeb','111003',NULL,'4.00',0,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334,2140110327','暂定','线下机房授课',NULL),('d511d26df8de551bc85ce765089771b4','2024-05-24 20:58:48',NULL,'','1','1','高级编程','111001',NULL,'4.00',0,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334,2140110327','暂定','线下机房授课',NULL),('d8d7bb93f100164659cac44ef2c4f55a','2024-06-06 16:17:39',NULL,'','1','1','近代史纲要','111011',NULL,'2.60',48,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334','暂定','线下授课',NULL),('de3100cad98f76be3176dd39aa748a9e','2024-05-31 20:49:52',NULL,'http://teaching-edu123.oss-cn-beijing.aliyuncs.com/E96JlmbPeqvzVcPvg43Lb.jpg','1','1','离散数学及其应用','111009',NULL,'2.00',64,NULL,NULL,NULL,NULL,NULL,'1','1','2140110334','暂定','线下授课',NULL); + +/*Table structure for table `filetable` */ + +DROP TABLE IF EXISTS `filetable`; + +CREATE TABLE `filetable` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `course_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `file_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; + +/*Data for the table `filetable` */ + +insert into `filetable`(`id`,`course_id`,`file_name`,`file_path`) values (1,'1','1f88e9df6f0b4412b0eb067ad057adb5.mp4','video/1f88e9df6f0b4412b0eb067ad057adb5.mp4'),(2,'2','bda16852b6944ae08cfcc70597f8dbb6.md','others/bda16852b6944ae08cfcc70597f8dbb6.md'),(3,'3','4c0dbc0ad84344bc8ba3431346cc7078.md','others/4c0dbc0ad84344bc8ba3431346cc7078.md'); + +/*Table structure for table `objective_contents` */ + +DROP TABLE IF EXISTS `objective_contents`; + +CREATE TABLE `objective_contents` ( + `id` varchar(32) NOT NULL, + `objective_id` varchar(32) DEFAULT NULL COMMENT '对应的目标id', + `content` text COMMENT '内容', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/*Data for the table `objective_contents` */ + +insert into `objective_contents`(`id`,`objective_id`,`content`) values ('3f85eb79c29be4a15c729d98b17676a5','c84dc451086f7938c28a4f757957f415','价值目标3'),('406c85c99bd2d4b9f624ca3a67c3ce66','53b27c94fe8af02ac8b23d9be9a2e329','思政目标2'),('4ad5a1f0f584e35e7af6ef5142773990','503dc084653ffd003cb404b62266dc7c','知识目标1'),('4b4458cd64b0a1e21b54191a89e9f83d','c84dc451086f7938c28a4f757957f415','价值目标2'),('53d9d78b41051696314c0b1c0efa5313','503dc084653ffd003cb404b62266dc7c','知识目标3'),('6689ed187bcbd36309510a21ea492225','da6e7283befa8965dae0f0f39ea7f24e','总目标3'),('979e59083e81f28145e1162069ffebb8','c84dc451086f7938c28a4f757957f415','价值目标1'),('9efcc83089e6de9945499876d1a6235a','da6e7283befa8965dae0f0f39ea7f24e','总目标1'),('c6b3fc522a5479e28cd3f0c9b971a871','53b27c94fe8af02ac8b23d9be9a2e329','思政目标3'),('dc31075d57f371970c5af09fd534a9af','da6e7283befa8965dae0f0f39ea7f24e','总目标2'),('eca937e6f047e3b6b06d67c5b4a9beff','53b27c94fe8af02ac8b23d9be9a2e329','思政目标1'),('ffde482fac55e6dec5b60f6c6208d42c','503dc084653ffd003cb404b62266dc7c','知识目标2'); + +/*Table structure for table `objectives_type` */ + +DROP TABLE IF EXISTS `objectives_type`; + +CREATE TABLE `objectives_type` ( + `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `type_name` varchar(50) DEFAULT NULL COMMENT '类型名称', + PRIMARY KEY (`id`), + UNIQUE KEY `type_name` (`type_name`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +/*Data for the table `objectives_type` */ + +insert into `objectives_type`(`id`,`type_name`) values ('410fc58cd757cd248941af1bea6888e5','价值目标'),('71f73bd999f678bcbbdb101e23277feb','思政目标'),('c126ef1a66733ab7a4ba12aba0eb7f82','知识目标'),('2350f69ef928cd2949e7fc05b05bd0c3','素质目标'); + +/*Table structure for table `se_course_favour` */ + +DROP TABLE IF EXISTS `se_course_favour`; + +CREATE TABLE `se_course_favour` ( + `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'id', + `course_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '课程id', + `user_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '用户', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; + +/*Data for the table `se_course_favour` */ + +insert into `se_course_favour`(`id`,`course_id`,`user_id`) values ('1796378327262564353','a2ba84374d86e85208c5906a96ea8205','2'),('1796454599099658242','36c34a4225526dd20ee3840da61d3701','2'),('1796789887730647041','2fa0fd63262230639d2c45a3acd9045c','2'),('1797497056650289154','d511d26df8de551bc85ce765089771b4','1'),('1797499380101767170','d511d26df8de551bc85ce765089771b4','2'),('1798221492412149761','d511d26df8de551bc85ce765089771b4','5'),('1798621775654993922','d511d26df8de551bc85ce765089771b4','8'),('1798632199670714369','de3100cad98f76be3176dd39aa748a9e','2'); + +/*Table structure for table `se_course_thumb` */ + +DROP TABLE IF EXISTS `se_course_thumb`; + +CREATE TABLE `se_course_thumb` ( + `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `course_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `user_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; + +/*Data for the table `se_course_thumb` */ + +insert into `se_course_thumb`(`id`,`course_id`,`user_id`) values ('1796343958854623233','2','1'),('1796344002215337985','2','2'),('1796362250491191298','1','2'),('1796437673614974977','6','2'),('1796445964822847489','7','4'); + +/*Table structure for table `se_know_favour` */ + +DROP TABLE IF EXISTS `se_know_favour`; + +CREATE TABLE `se_know_favour` ( + `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `course_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `know_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `user_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; + +/*Data for the table `se_know_favour` */ + +insert into `se_know_favour`(`id`,`course_id`,`know_id`,`user_id`) values ('1796378889450295297','1','2','3'); + +/*Table structure for table `se_know_thumb` */ + +DROP TABLE IF EXISTS `se_know_thumb`; + +CREATE TABLE `se_know_thumb` ( + `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `course_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `know_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `user_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; + +/*Data for the table `se_know_thumb` */ + +insert into `se_know_thumb`(`id`,`course_id`,`know_id`,`user_id`) values ('1796347057337982977','1','2','2'),('1796347303317135361','2','2','3'),('1796347343968329730','2','3','3'),('1796347380697849857','1','3','3'); + +/*Table structure for table `se_resource_favour` */ + +DROP TABLE IF EXISTS `se_resource_favour`; + +CREATE TABLE `se_resource_favour` ( + `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `course_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `resource_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `user_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; + +/*Data for the table `se_resource_favour` */ + +insert into `se_resource_favour`(`id`,`course_id`,`resource_id`,`user_id`) values ('1796379012112715778','1','2','3'); + +/*Table structure for table `se_resource_thumb` */ + +DROP TABLE IF EXISTS `se_resource_thumb`; + +CREATE TABLE `se_resource_thumb` ( + `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, + `course_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `resource_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `user_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC; + +/*Data for the table `se_resource_thumb` */ + +insert into `se_resource_thumb`(`id`,`course_id`,`resource_id`,`user_id`) values ('1796366535710904322','2','1','1'); + +/*Table structure for table `user` */ + +DROP TABLE IF EXISTS `user`; + +CREATE TABLE `user` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `userAccount` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '账号', + `userPassword` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '密码', + `userName` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户昵称', + `userAvatar` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '用户头像', + `userRole` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'user' COMMENT '用户角色:user/admin/ban', + `createTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `isDelete` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1793257199111405570 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='用户'; + +/*Data for the table `user` */ + +insert into `user`(`id`,`userAccount`,`userPassword`,`userName`,`userAvatar`,`userRole`,`createTime`,`updateTime`,`isDelete`) values (1793257199111405569,'youhang','84fccf8fe96cab775b23698a9c9b7eaa','游航',NULL,'admin','2024-05-22 20:26:48','2024-05-22 20:27:53',0); + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; diff --git a/src/main/java/com/teaching/backend/common/ErrorCode.java b/src/main/java/com/teaching/backend/common/ErrorCode.java index e7eb076..55fefe0 100644 --- a/src/main/java/com/teaching/backend/common/ErrorCode.java +++ b/src/main/java/com/teaching/backend/common/ErrorCode.java @@ -8,11 +8,12 @@ package com.teaching.backend.common; */ public enum ErrorCode { - SUCCESS(0, "ok"), + SUCCESS(200, "ok"), PARAMS_ERROR(40000, "请求参数错误"), NOT_LOGIN_ERROR(40100, "未登录"), NO_AUTH_ERROR(40101, "无权限"), NOT_FOUND_ERROR(40400, "请求数据不存在"), + CONTENT_EXISTS(41000, "内容存在"), FORBIDDEN_ERROR(40300, "禁止访问"), PARAMS_ILLEGAL(42000, "请求参数违法"), diff --git a/src/main/java/com/teaching/backend/common/ResultUtils.java b/src/main/java/com/teaching/backend/common/ResultUtils.java index 1cd695a..e466a3d 100644 --- a/src/main/java/com/teaching/backend/common/ResultUtils.java +++ b/src/main/java/com/teaching/backend/common/ResultUtils.java @@ -16,7 +16,7 @@ public class ResultUtils { * @return */ public static BaseResponse success(T data) { - return new BaseResponse<>(0, data, "ok"); + return new BaseResponse<>(200, data, "ok"); } /** diff --git a/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java b/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java index 0924024..cead419 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java @@ -7,6 +7,7 @@ import com.teaching.backend.common.ResultUtils; import com.teaching.backend.mapper.courses.CourseObjectivesMapper; import com.teaching.backend.model.dto.courses.CourseObjectivesDTO; import com.teaching.backend.model.entity.courses.CourseObjectives; +import com.teaching.backend.model.vo.CourseObjectivesTreeVO; import com.teaching.backend.service.courses.ICourseObjectivesService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.time.LocalDateTime; +import java.util.List; /** *

@@ -49,6 +51,11 @@ public class CourseObjectivesController { return ResultUtils.success(data); } + /** + * 禁止修改课程编码和名称 + * @param courseObjectivesDTO + * @return + */ @ApiOperation("编辑分项目标") @PutMapping public BaseResponse updateCourseObjectives(@RequestBody CourseObjectivesDTO courseObjectivesDTO){ @@ -60,5 +67,12 @@ public class CourseObjectivesController { return ResultUtils.success("编辑成功"); } + @ApiOperation("查询课程目标内容") + @GetMapping("/list/{id}") + public BaseResponse> queryCourseObjectivesTree(@PathVariable String id){ + List courseObjectivesTreeVO = courseObjectivesService.queryCourseObjectivesTree(id); + return ResultUtils.success(courseObjectivesTreeVO); + } + } diff --git a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java index 84b43a9..9bdde4c 100644 --- a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java +++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java @@ -69,11 +69,12 @@ public class CoursesController { } //TODO:删除功能暂未完善,数据表缺失 - @ApiOperation("根据ids批量删除课程") - @DeleteMapping("/{ids}") - public BaseResponse deleteCourses(@PathVariable List ids){ - System.out.println(ids); - coursesService.removeBatchByIds(ids); + @ApiOperation("根据id删除课程") + @DeleteMapping("/{id}") + public BaseResponse deleteCourses(@PathVariable String id){ + System.out.println(id); + coursesService.deleteBatchByIds(id); +// coursesService.removeBatchByIds(ids); return ResultUtils.success("删除成功"); } diff --git a/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java b/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java new file mode 100644 index 0000000..66afe28 --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/courses/ObjectiveContentsController.java @@ -0,0 +1,50 @@ +package com.teaching.backend.controller.courses; + + +import com.teaching.backend.common.BaseResponse; +import com.teaching.backend.common.ResultUtils; +import com.teaching.backend.model.entity.courses.ObjectiveContents; +import com.teaching.backend.service.courses.IObjectiveContentsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + *

+ * 前端控制器 + *

+ * + * @author zjh + * @since 2024-06-05 + */ +@RestController +@RequestMapping("/objective_contents") +@Api(tags = "目标内容接口") +public class ObjectiveContentsController { + + @Autowired + IObjectiveContentsService objectiveContentsService; + + @ApiOperation("添加目标内容") + @PostMapping("/addcontent") + public BaseResponse saveContent(@RequestBody ObjectiveContents objectiveContents){ + objectiveContentsService.save(objectiveContents); + return ResultUtils.success("添加成功"); + } + + @ApiOperation("删除目标内容") + @DeleteMapping("/{id}") + public BaseResponse deleteContent(@PathVariable String id){ + objectiveContentsService.removeById(id); + return ResultUtils.success("删除成功"); + } + + @ApiOperation("修改目标内容") + @PutMapping("/update") + public BaseResponse updateContent(@RequestBody ObjectiveContents objectiveContents){ + objectiveContentsService.updateById(objectiveContents); + return ResultUtils.success("修改成功"); + } + +} diff --git a/src/main/java/com/teaching/backend/controller/courses/ObjectivesTypeController.java b/src/main/java/com/teaching/backend/controller/courses/ObjectivesTypeController.java new file mode 100644 index 0000000..26a79d3 --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/courses/ObjectivesTypeController.java @@ -0,0 +1,69 @@ +package com.teaching.backend.controller.courses; + + +import cn.hutool.core.bean.BeanUtil; +import com.teaching.backend.common.BaseResponse; +import com.teaching.backend.common.ResultUtils; +import com.teaching.backend.model.dto.courses.CoursesDTO; +import com.teaching.backend.model.dto.courses.PageDTO; +import com.teaching.backend.model.entity.courses.Courses; +import com.teaching.backend.model.entity.courses.ObjectivesType; +import com.teaching.backend.model.query.CourseQuery; +import com.teaching.backend.model.vo.CoursesVO; +import com.teaching.backend.service.courses.ICoursesService; +import com.teaching.backend.service.courses.IObjectivesTypeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + *

+ * 前端控制器 + *

+ * + * @author zjh + * @since 2024-06-05 + */ +@RestController +@RequestMapping("/objectives_type") +@Api(tags = "项目目标类型管理接口") +public class ObjectivesTypeController { + + @Autowired + IObjectivesTypeService objectivesTypeService; + + @ApiOperation("新增目标类型") + @PostMapping("/addobjectives") + public BaseResponse saveObjectives(@RequestBody ObjectivesType objectivesType){ + objectivesTypeService.save(objectivesType); + return ResultUtils.success("添加成功"); + } + + @ApiOperation("删除目标类型") + @DeleteMapping("/deleteobjectives/{id}") + public BaseResponse deleteObjectives(@PathVariable String id){ + objectivesTypeService.removeById(id); + return ResultUtils.success("删除成功"); + } + + @ApiOperation("修改目标类型") + @PutMapping + public BaseResponse updateObjectives(@RequestBody ObjectivesType objectivesType){ + objectivesTypeService.updateById(objectivesType); + return ResultUtils.success("修改成功"); + } + + @ApiOperation("列表显示目标类型") + @GetMapping("/list") + public BaseResponse> ObjectivesList(){ + List list = objectivesTypeService.list(); + return ResultUtils.success(list); + } + + + +} diff --git a/src/main/java/com/teaching/backend/exception/GlobalExceptionHandler.java b/src/main/java/com/teaching/backend/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..5af0a92 --- /dev/null +++ b/src/main/java/com/teaching/backend/exception/GlobalExceptionHandler.java @@ -0,0 +1,45 @@ +package com.teaching.backend.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class GlobalExceptionHandler { + + @ExceptionHandler(BusinessException.class) + public ResponseEntity handleBusinessException(BusinessException ex) { + ErrorResponse errorResponse = new ErrorResponse(ex.getCode(), ex.getMessage()); + return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); + } + + // 其他异常处理器可以按需添加 + + public static class ErrorResponse { + private int code; + private String message; + + public ErrorResponse(int code, String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + } +} + diff --git a/src/main/java/com/teaching/backend/mapper/courses/CourseObjectivesMapper.java b/src/main/java/com/teaching/backend/mapper/courses/CourseObjectivesMapper.java index 0498edf..ec60635 100644 --- a/src/main/java/com/teaching/backend/mapper/courses/CourseObjectivesMapper.java +++ b/src/main/java/com/teaching/backend/mapper/courses/CourseObjectivesMapper.java @@ -2,6 +2,9 @@ package com.teaching.backend.mapper.courses; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.teaching.backend.model.entity.courses.CourseObjectives; +import com.teaching.backend.model.vo.CourseObjectivesTreeVO; + +import java.util.List; /** *

@@ -13,4 +16,5 @@ import com.teaching.backend.model.entity.courses.CourseObjectives; */ public interface CourseObjectivesMapper extends BaseMapper { + List selectTreeNodes(String courseObjectivesId); } diff --git a/src/main/java/com/teaching/backend/mapper/courses/ObjectiveContentsMapper.java b/src/main/java/com/teaching/backend/mapper/courses/ObjectiveContentsMapper.java new file mode 100644 index 0000000..617bcfa --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/courses/ObjectiveContentsMapper.java @@ -0,0 +1,16 @@ +package com.teaching.backend.mapper.courses; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.courses.ObjectiveContents; + +/** + *

+ * Mapper 接口 + *

+ * + * @author zjh + * @since 2024-06-05 + */ +public interface ObjectiveContentsMapper extends BaseMapper { + +} diff --git a/src/main/java/com/teaching/backend/mapper/courses/ObjectivesTypeMapper.java b/src/main/java/com/teaching/backend/mapper/courses/ObjectivesTypeMapper.java new file mode 100644 index 0000000..9d1621b --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/courses/ObjectivesTypeMapper.java @@ -0,0 +1,17 @@ +package com.teaching.backend.mapper.courses; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.courses.ObjectivesType; + +/** + *

+ * Mapper 接口 + *

+ * + * @author zjh + * @since 2024-06-05 + */ +public interface ObjectivesTypeMapper extends BaseMapper { + +} diff --git a/src/main/java/com/teaching/backend/model/dto/courses/CourseObjectivesDTO.java b/src/main/java/com/teaching/backend/model/dto/courses/CourseObjectivesDTO.java index fa6cc3a..4b1129f 100644 --- a/src/main/java/com/teaching/backend/model/dto/courses/CourseObjectivesDTO.java +++ b/src/main/java/com/teaching/backend/model/dto/courses/CourseObjectivesDTO.java @@ -1,12 +1,16 @@ package com.teaching.backend.model.dto.courses; +import com.teaching.backend.model.entity.courses.ObjectiveContents; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.io.Serializable; +import java.util.List; + @Data @ApiModel(description = "分项目标参数实体") -public class CourseObjectivesDTO { +public class CourseObjectivesDTO implements Serializable { /** * 内部编号 */ @@ -19,16 +23,10 @@ public class CourseObjectivesDTO { @ApiModelProperty(value = "分项目标名称",required = true) private String name; /** - * 分项目标类型 思政1 知识2、素质3、价值4 + * 分项目标类型 思政 知识、素质、价值 */ - @ApiModelProperty(value = "分项目标类型 思政1 知识2、素质3、价值4",required = true) + @ApiModelProperty(value = "分项目标类型",required = true) private String type; - /** - * 分项目标描述 - */ - @ApiModelProperty(value = "分项目标内容",required = true) - private String content; - /** * 父节点 */ @@ -36,4 +34,8 @@ public class CourseObjectivesDTO { private String pid; + + + + } diff --git a/src/main/java/com/teaching/backend/model/dto/courses/CoursesDTO.java b/src/main/java/com/teaching/backend/model/dto/courses/CoursesDTO.java index 65a6794..d590709 100644 --- a/src/main/java/com/teaching/backend/model/dto/courses/CoursesDTO.java +++ b/src/main/java/com/teaching/backend/model/dto/courses/CoursesDTO.java @@ -34,13 +34,13 @@ public class CoursesDTO { /** * 课程类别 专业教育 通识教育 */ - @ApiModelProperty(value = "课程类别:专业教育 通识教育",required = true) + @ApiModelProperty(value = "课程类别:专业教育1 通识教育2",required = true) private String category; /** * 课程性质 必修选修任修 */ - @ApiModelProperty(value = "课程性质:必修,选修,任修",required = true) + @ApiModelProperty(value = "课程性质:必修1 选修2 任修3",required = true) private String nature; /** @@ -71,13 +71,13 @@ public class CoursesDTO { /** * 考核类型 考试 考查 */ - @ApiModelProperty(value = "考核类型:考试 考查",required = true) + @ApiModelProperty(value = "考核类型:考试1 考查2",required = true) private String assessmenttype; /** * 考核方式 开卷 闭卷 其他 */ - @ApiModelProperty(value = "考核方式:开卷 闭卷 其他",required = true) + @ApiModelProperty(value = "考核方式:开卷1 闭卷2 其他3",required = true) private String assessmentway; /** diff --git a/src/main/java/com/teaching/backend/model/entity/courses/CourseObjectives.java b/src/main/java/com/teaching/backend/model/entity/courses/CourseObjectives.java index ed298f7..e0848a0 100644 --- a/src/main/java/com/teaching/backend/model/entity/courses/CourseObjectives.java +++ b/src/main/java/com/teaching/backend/model/entity/courses/CourseObjectives.java @@ -52,11 +52,9 @@ public class CourseObjectives implements Serializable { @ApiModelProperty(value = "目标类型") private String type; - @ApiModelProperty(value = "目标内容") - private String content; @ApiModelProperty(value = "课程id") - private String courseid; + private String courseId; @ApiModelProperty(value = "毕业要求id") private String requireid; diff --git a/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java new file mode 100644 index 0000000..4dc89f6 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/courses/ObjectiveContents.java @@ -0,0 +1,40 @@ +package com.teaching.backend.model.entity.courses; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author zjh + * @since 2024-06-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("objective_contents") +@ApiModel(value="ObjectiveContents对象", description="") +public class ObjectiveContents implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.ASSIGN_UUID) + private String id; + + @ApiModelProperty(value = "对应的目标id",required = true) + private String objectiveId; + + @ApiModelProperty(value = "内容",required = true) + private String content; + + +} diff --git a/src/main/java/com/teaching/backend/model/entity/courses/ObjectivesType.java b/src/main/java/com/teaching/backend/model/entity/courses/ObjectivesType.java new file mode 100644 index 0000000..decfc66 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/courses/ObjectivesType.java @@ -0,0 +1,38 @@ +package com.teaching.backend.model.entity.courses; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * + *

+ * + * @author zjh + * @since 2024-06-05 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("objectives_type") +@ApiModel(value="ObjectivesType对象", description="") +public class ObjectivesType implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.ASSIGN_UUID) + @ApiModelProperty(value = "类型编码,不用输入,使用雪花算法生成") + private String id; + + @ApiModelProperty(value = "类型名称",required = true) + private String typeName; + + +} diff --git a/src/main/java/com/teaching/backend/model/query/PageQuery.java b/src/main/java/com/teaching/backend/model/query/PageQuery.java index de934c9..7b8e7da 100644 --- a/src/main/java/com/teaching/backend/model/query/PageQuery.java +++ b/src/main/java/com/teaching/backend/model/query/PageQuery.java @@ -12,7 +12,7 @@ import lombok.Data; public class PageQuery { @ApiModelProperty("页码") private Integer pageNo = 1; - @ApiModelProperty("页码") + @ApiModelProperty("每页数量") private Integer pageSize = 10; @ApiModelProperty("排序字段") private String sortBy; diff --git a/src/main/java/com/teaching/backend/model/vo/CourseObjectivesTreeVO.java b/src/main/java/com/teaching/backend/model/vo/CourseObjectivesTreeVO.java new file mode 100644 index 0000000..d4b75c3 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/vo/CourseObjectivesTreeVO.java @@ -0,0 +1,26 @@ +package com.teaching.backend.model.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.teaching.backend.model.dto.courses.CourseObjectivesDTO; +import com.teaching.backend.model.entity.courses.CourseObjectives; +import com.teaching.backend.model.entity.courses.ObjectiveContents; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.List; + +@Data +@ApiModel(description = "课程目标参数实体") +public class CourseObjectivesTreeVO extends CourseObjectives implements Serializable { + + @ApiModelProperty(value = "目标内容列表") + private List contents; + + @ApiModelProperty(value = "课程目标") + private List courseObjectivesTrees; + +} diff --git a/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java b/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java index 15d8f0c..bd78048 100644 --- a/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java +++ b/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java @@ -3,6 +3,9 @@ package com.teaching.backend.service.courses; import com.baomidou.mybatisplus.extension.service.IService; import com.teaching.backend.model.dto.courses.CourseObjectivesDTO; import com.teaching.backend.model.entity.courses.CourseObjectives; +import com.teaching.backend.model.vo.CourseObjectivesTreeVO; + +import java.util.List; /** *

@@ -14,7 +17,24 @@ import com.teaching.backend.model.entity.courses.CourseObjectives; */ public interface ICourseObjectivesService extends IService { + /** + * 添加课程目标 + * @param courseObjectivesDTO + * @return + */ String addObjectives(CourseObjectivesDTO courseObjectivesDTO); + /** + * 删除课程目标 + * @param id + * @return + */ String deleteObjectives(String id); + + /** + * 查询课程目标以及相关内容 + * @param id + * @return + */ + List queryCourseObjectivesTree(String id); } diff --git a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java index 951743d..c4705e6 100644 --- a/src/main/java/com/teaching/backend/service/courses/ICoursesService.java +++ b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java @@ -8,6 +8,8 @@ import com.teaching.backend.model.entity.courses.Courses; import com.teaching.backend.model.query.CourseQuery; import com.teaching.backend.model.vo.CoursesVO; +import java.util.List; + /** *

@@ -24,4 +26,5 @@ public interface ICoursesService extends IService { PageDTO queryCourses(CourseQuery courseQuery, String teacherId); + void deleteBatchByIds(String id); } diff --git a/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java b/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java new file mode 100644 index 0000000..02d08f2 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/courses/IObjectiveContentsService.java @@ -0,0 +1,18 @@ +package com.teaching.backend.service.courses; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.entity.courses.ObjectiveContents; +import com.teaching.backend.model.vo.CourseObjectivesTreeVO; + +/** + *

+ * 服务类 + *

+ * + * @author zjh + * @since 2024-06-05 + */ +public interface IObjectiveContentsService extends IService { + +} diff --git a/src/main/java/com/teaching/backend/service/courses/IObjectivesTypeService.java b/src/main/java/com/teaching/backend/service/courses/IObjectivesTypeService.java new file mode 100644 index 0000000..8bd1c9a --- /dev/null +++ b/src/main/java/com/teaching/backend/service/courses/IObjectivesTypeService.java @@ -0,0 +1,16 @@ +package com.teaching.backend.service.courses; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.entity.courses.ObjectivesType; + +/** + *

+ * 服务类 + *

+ * + * @author zjh + * @since 2024-06-05 + */ +public interface IObjectivesTypeService extends IService { + +} diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java index 7642876..bdec642 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java @@ -6,13 +6,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.teaching.backend.common.ErrorCode; import com.teaching.backend.exception.BusinessException; import com.teaching.backend.mapper.courses.CourseObjectivesMapper; +import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; import com.teaching.backend.model.dto.courses.CourseObjectivesDTO; import com.teaching.backend.model.entity.courses.CourseObjectives; +import com.teaching.backend.model.entity.courses.ObjectiveContents; +import com.teaching.backend.model.vo.CourseObjectivesTreeVO; import com.teaching.backend.service.courses.ICourseObjectivesService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** *

@@ -29,6 +35,9 @@ public class CourseObjectivesServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper - .eq(CourseObjectives::getPid, pid) - .eq(CourseObjectives::getType, "1"); - Long count = courseObjectivesMapper.selectCount(queryWrapper); - if (count>0){ - throw new BusinessException(ErrorCode.OPERATION_ERROR,"思政目标已存在,禁止重复添加!"); - } + //判断是否已经添加过该类型的目标 + //每个类型的目标只能有一个 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper + .eq(CourseObjectives::getPid, pid) + .eq(CourseObjectives::getType, type); + Long count = courseObjectivesMapper.selectCount(queryWrapper); + if (count>0){ + throw new BusinessException(ErrorCode.CONTENT_EXISTS,"该类型的目标已存在,禁止重复添加!"); } //往表里面写分项目标 - CourseObjectives courseObjectives = new CourseObjectives(); - BeanUtil.copyProperties(courseObjectivesDTO,courseObjectives); - courseObjectives.setCreateTime(LocalDateTime.now()); - courseObjectivesMapper.insert(courseObjectives); + CourseObjectives courseObjectivesNew = new CourseObjectives(); + BeanUtil.copyProperties(courseObjectivesDTO,courseObjectivesNew); + courseObjectivesNew.setCreateTime(LocalDateTime.now()); + courseObjectivesMapper.insert(courseObjectivesNew); //插入数据以后要把总体目标那边的haschild改成1 - CourseObjectives objectives = courseObjectivesMapper.selectById(pid); - objectives.setHasChild("1"); - courseObjectivesMapper.updateById(objectives); + CourseObjectives courseObjectivesOld = courseObjectivesMapper.selectById(pid); + courseObjectivesOld.setUpdateTime(LocalDateTime.now()); + courseObjectivesOld.setHasChild("1"); + courseObjectivesMapper.updateById(courseObjectivesOld); return "添加成功"; } + /** + * 删除课程目标 + * 首先检查是不是思政目标,如果是思政目标就要看此时的总目标下面有没有别的分项目标了,如果有,不准删除, + * 如果此时只有分项目标,检查分项目标下面有没有内容,如果有,禁止删除 + * 删除分项目标也要检查下面有没有内容 + * @param id + * @return + */ @Override public String deleteObjectives(String id) { + final String SI_ZHENG_TYPE="71f73bd999f678bcbbdb101e23277feb"; CourseObjectives courseObjectives = courseObjectivesMapper.selectById(id); + if (courseObjectives == null) { + throw new BusinessException(ErrorCode.NOT_FOUND_ERROR); + } String type = courseObjectives.getType(); String pid = courseObjectives.getPid(); - if (type.equals("1")){ + if (SI_ZHENG_TYPE.equals(type)){ LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(CourseObjectives::getPid, pid); - Long count = courseObjectivesMapper.selectCount(queryWrapper); - if (count==1){ - courseObjectivesMapper.deleteById(id); - CourseObjectives courseObjectives1 = courseObjectivesMapper.selectById(pid); - courseObjectives1.setHasChild("0"); - courseObjectivesMapper.updateById(courseObjectives1); - return "删除成功"; + Long count1 = courseObjectivesMapper.selectCount(queryWrapper); + if (count1==1){ + Long count2 = getCount(id); + if (count2==0) + { + // 删除操作和更新父目标状态 + deleteObjectiveAndUpdateParent(id, pid); + return "删除成功"; + } + else { + throw new BusinessException(ErrorCode.CONTENT_EXISTS, "请删除该目标下的内容后,再删除该目标"); + } } else { - throw new BusinessException(ErrorCode.OPERATION_ERROR, "请删除其他类型的分目标后再来删除思政目标"); + throw new BusinessException(ErrorCode.OPERATION_ERROR, "请删除其他类型的分目标后,再来删除思政目标"); } } else { - courseObjectivesMapper.deleteById(id); - return "删除成功"; + Long count3 = getCount(id); + if (count3==0){ + courseObjectivesMapper.deleteById(id); + return "删除成功"; + } + else { + throw new BusinessException(ErrorCode.CONTENT_EXISTS, "请删除该目标下的内容后,再删除该目标"); + } } } + + private Long getCount(String id) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ObjectiveContents::getObjectiveId, id); + Long count = objectiveContentsMapper.selectCount(queryWrapper); + return count; + } + + private void deleteObjectiveAndUpdateParent(String id, String pid) { + courseObjectivesMapper.deleteById(id); + CourseObjectives parentObjective = courseObjectivesMapper.selectById(pid); + parentObjective.setHasChild("0"); + courseObjectivesMapper.updateById(parentObjective); + } + + @Override + public List queryCourseObjectivesTree(String id) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CourseObjectives::getCourseId, id); + CourseObjectives courseObjectives = courseObjectivesMapper.selectOne(queryWrapper); + String courseObjectivesId = courseObjectives.getId(); + List objectives = courseObjectivesMapper.selectTreeNodes(courseObjectivesId); + Map map = new HashMap<>(); + for (CourseObjectivesTreeVO objective : objectives) { + map.put(objective.getId(), objective); + } + + // 构建树结构 + List roots = new ArrayList<>(); + for (CourseObjectivesTreeVO objective : objectives) { + if ("0".equals(objective.getPid())) { + roots.add(objective); + } else { + CourseObjectivesTreeVO parent = map.get(objective.getPid()); + if (parent != null) { + if (parent.getCourseObjectivesTrees() == null) { + parent.setCourseObjectivesTrees(new ArrayList<>()); + } + parent.getCourseObjectivesTrees().add(objective); + } + } + // 填充内容 + List contents = fetchContentsForObjective(objective.getId()); + objective.setContents(contents); + } + + return roots; + } + + // 获取目标的内容列表 + private List fetchContentsForObjective(String objectiveId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ObjectiveContents::getObjectiveId, objectiveId); + List contents = objectiveContentsMapper.selectList(queryWrapper); + return contents; + } } + diff --git a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java index 8ae4f40..e029902 100644 --- a/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java @@ -1,6 +1,7 @@ package com.teaching.backend.service.impl.courses; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -8,10 +9,12 @@ import com.teaching.backend.common.ErrorCode; import com.teaching.backend.exception.BusinessException; import com.teaching.backend.mapper.courses.CourseObjectivesMapper; import com.teaching.backend.mapper.courses.CoursesMapper; +import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; import com.teaching.backend.model.dto.courses.CoursesDTO; import com.teaching.backend.model.dto.courses.PageDTO; import com.teaching.backend.model.entity.courses.CourseObjectives; import com.teaching.backend.model.entity.courses.Courses; +import com.teaching.backend.model.entity.courses.ObjectiveContents; import com.teaching.backend.model.query.CourseQuery; import com.teaching.backend.model.vo.CoursesVO; import com.teaching.backend.service.courses.ICoursesService; @@ -21,23 +24,26 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; +import java.util.List; /** *

- * 服务实现类 + * 服务实现类 *

* * @author zjh * @since 2024-05-30 */ @Service -public class CoursesServiceImpl extends ServiceImplimplements ICoursesService { +public class CoursesServiceImpl extends ServiceImpl implements ICoursesService { @Autowired CoursesMapper coursesMapper; @Autowired CourseObjectivesMapper courseObjectivesMapper; + @Autowired + ObjectiveContentsMapper objectiveContentsMapper; @Override @Transactional @@ -54,17 +60,17 @@ public class CoursesServiceImpl extends ServiceImplimple QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("code", code); Long count = coursesMapper.selectCount(queryWrapper); - if(count==0){ + if (count == 0) { int insert = coursesMapper.insert(courses); - if (insert>0){ + if (insert > 0) { Courses courses1 = coursesMapper.selectOne(queryWrapper); - courseObjectives.setCourseid(courses1.getId()); + courseObjectives.setCourseId(courses1.getId()); courseObjectives.setCreateTime(courses1.getCreateTime()); - courseObjectives.setName(courses1.getName()+"课程总体目标"); + courseObjectives.setName(courses1.getName() + "课程总体目标"); courseObjectivesMapper.insert(courseObjectives); } return "添加成功"; - }else { + } else { throw new BusinessException(ErrorCode.OPERATION_ERROR, "这个课程已经存在了!请联系系统相关人员为您导入课程数据!"); } @@ -85,7 +91,27 @@ public class CoursesServiceImpl extends ServiceImplimple .page(page); - return PageDTO.of(p,CoursesVO.class); + return PageDTO.of(p, CoursesVO.class); + } + + @Override +// @Transactional + public void deleteBatchByIds(String id) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().eq(CourseObjectives::getCourseId, id); + CourseObjectives courseObjectives = courseObjectivesMapper.selectOne(queryWrapper); + String objectivesId = courseObjectives.getId(); + LambdaQueryWrapper queryWrapper2 = new LambdaQueryWrapper().eq(ObjectiveContents::getObjectiveId, objectivesId); + Long count = objectiveContentsMapper.selectCount(queryWrapper2); + if (courseObjectives.getHasChild().equals("1")) { + throw new BusinessException(ErrorCode.CONTENT_EXISTS, "该课程已有分项目标,禁止删除"); + } + if (!count.equals(0)){ + throw new BusinessException(ErrorCode.CONTENT_EXISTS, "总目标下面还有内容,禁止删除"); + } + else { + coursesMapper.deleteById(id); + courseObjectivesMapper.deleteById(courseObjectives.getId()); + } } diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java new file mode 100644 index 0000000..4d1ca00 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectiveContentsServiceImpl.java @@ -0,0 +1,21 @@ +package com.teaching.backend.service.impl.courses; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; +import com.teaching.backend.model.entity.courses.ObjectiveContents; +import com.teaching.backend.service.courses.IObjectiveContentsService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author zjh + * @since 2024-06-05 + */ +@Service +public class ObjectiveContentsServiceImpl extends ServiceImpl implements IObjectiveContentsService { + +} diff --git a/src/main/java/com/teaching/backend/service/impl/courses/ObjectivesTypeServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/courses/ObjectivesTypeServiceImpl.java new file mode 100644 index 0000000..ad4e8c7 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/courses/ObjectivesTypeServiceImpl.java @@ -0,0 +1,20 @@ +package com.teaching.backend.service.impl.courses; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.teaching.backend.mapper.courses.ObjectivesTypeMapper; +import com.teaching.backend.model.entity.courses.ObjectivesType; +import com.teaching.backend.service.courses.IObjectivesTypeService; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author zjh + * @since 2024-06-05 + */ +@Service +public class ObjectivesTypeServiceImpl extends ServiceImpl implements IObjectivesTypeService { + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 75f762d..b2352d3 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -18,7 +18,17 @@ mybatis: - classpath:dao/*.xml - classpath*:com/**/mapper/*.xml - +# 接口文档配置 +knife4j: + enable: true + openapi: + title: "" + version: 1.0 + group: + default: + api-rule: package + api-rule-resources: + - com.teaching.backend.controller # 接口文档配置 knife4j: enable: true diff --git a/src/main/resources/mapper/CourseObjectivesMapper.xml b/src/main/resources/mapper/CourseObjectivesMapper.xml index 768a1c4..429a2e3 100644 --- a/src/main/resources/mapper/CourseObjectivesMapper.xml +++ b/src/main/resources/mapper/CourseObjectivesMapper.xml @@ -1,5 +1,16 @@ - + + diff --git a/src/main/resources/mapper/CoursesMapper.xml b/src/main/resources/mapper/CoursesMapper.xml index 40f1979..3f9746d 100644 --- a/src/main/resources/mapper/CoursesMapper.xml +++ b/src/main/resources/mapper/CoursesMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/src/main/resources/mapper/ObjectiveContentsMapper.xml b/src/main/resources/mapper/ObjectiveContentsMapper.xml new file mode 100644 index 0000000..738e8e9 --- /dev/null +++ b/src/main/resources/mapper/ObjectiveContentsMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/main/resources/mapper/ObjectivesTypeMapper.xml b/src/main/resources/mapper/ObjectivesTypeMapper.xml new file mode 100644 index 0000000..cd63407 --- /dev/null +++ b/src/main/resources/mapper/ObjectivesTypeMapper.xml @@ -0,0 +1,5 @@ + + + + +