diff --git a/pom.xml b/pom.xml
index fdb7d41..de53fbd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,12 @@
org.apache.commons
commons-lang3
+
+
+ cn.hutool
+ hutool-all
+ 5.8.11
+
diff --git a/src/main/java/com/teaching/backend/common/ErrorCode.java b/src/main/java/com/teaching/backend/common/ErrorCode.java
index 84ddc09..e7eb076 100644
--- a/src/main/java/com/teaching/backend/common/ErrorCode.java
+++ b/src/main/java/com/teaching/backend/common/ErrorCode.java
@@ -14,6 +14,8 @@ public enum ErrorCode {
NO_AUTH_ERROR(40101, "无权限"),
NOT_FOUND_ERROR(40400, "请求数据不存在"),
FORBIDDEN_ERROR(40300, "禁止访问"),
+
+ PARAMS_ILLEGAL(42000, "请求参数违法"),
SYSTEM_ERROR(50000, "系统内部异常"),
OPERATION_ERROR(50001, "操作失败");
diff --git a/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java b/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java
new file mode 100644
index 0000000..0924024
--- /dev/null
+++ b/src/main/java/com/teaching/backend/controller/courses/CourseObjectivesController.java
@@ -0,0 +1,64 @@
+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.mapper.courses.CourseObjectivesMapper;
+import com.teaching.backend.model.dto.courses.CourseObjectivesDTO;
+import com.teaching.backend.model.entity.courses.CourseObjectives;
+import com.teaching.backend.service.courses.ICourseObjectivesService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.time.LocalDateTime;
+
+/**
+ *
+ * 前端控制器
+ *
+ *
+ * @author zjh
+ * @since 2024-05-31
+ */
+@Api(tags = "项目目标管理接口")
+@RestController
+@RequestMapping("/course_objectives")
+public class CourseObjectivesController {
+
+
+ @Autowired
+ ICourseObjectivesService courseObjectivesService;
+
+ @Autowired
+ CourseObjectivesMapper courseObjectivesMapper;
+
+ @ApiOperation("新增分项目标-默认第一个必须添加思政目标")
+ @PostMapping("/addobjectives")
+ public BaseResponse saveCourseObjectives(@RequestBody CourseObjectivesDTO courseObjectivesDTO){
+ String data = courseObjectivesService.addObjectives(courseObjectivesDTO);
+ return ResultUtils.success(data);
+ }
+
+ @ApiOperation("删除分项目标-只能最后一个删除思政目标")
+ @DeleteMapping("/{id}")
+ public BaseResponse deleteCourseObjectivesByIds(@PathVariable String id){
+ String data = courseObjectivesService.deleteObjectives(id);
+ return ResultUtils.success(data);
+ }
+
+ @ApiOperation("编辑分项目标")
+ @PutMapping
+ public BaseResponse updateCourseObjectives(@RequestBody CourseObjectivesDTO courseObjectivesDTO){
+ String pid = courseObjectivesDTO.getPid();
+ CourseObjectives courseObjectives = courseObjectivesMapper.selectById(pid);
+ BeanUtil.copyProperties(courseObjectivesDTO, courseObjectives);
+ courseObjectives.setUpdateTime(LocalDateTime.now());
+ courseObjectivesService.updateById(courseObjectives);
+ return ResultUtils.success("编辑成功");
+ }
+
+
+}
diff --git a/src/main/java/com/teaching/backend/controller/courses/CoursesController.java b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java
new file mode 100644
index 0000000..84b43a9
--- /dev/null
+++ b/src/main/java/com/teaching/backend/controller/courses/CoursesController.java
@@ -0,0 +1,81 @@
+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.query.CourseQuery;
+import com.teaching.backend.model.vo.CoursesVO;
+import com.teaching.backend.service.courses.ICoursesService;
+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-05-30
+ */
+@Api(tags = "教师管理课程接口")
+@RestController
+@RequestMapping("/coursesteacher")
+public class CoursesController {
+
+ @Autowired
+ ICoursesService coursesService;
+
+ @ApiOperation("新增课程--同步新增课程的总体目标")
+ @PostMapping("/addcourse")
+ public BaseResponse saveCourse(@RequestBody CoursesDTO coursesDTO, @RequestParam String teacherId){
+ String data = coursesService.saveCourseWithObjective(coursesDTO, teacherId);
+ return ResultUtils.success(data);
+ }
+
+
+ @ApiOperation("查询课程列表")
+ @GetMapping("/page")
+ public BaseResponse> getCourses(CourseQuery courseQuery, @RequestParam String teacherId){
+ PageDTO coursesList = coursesService.queryCourses(courseQuery,teacherId);
+ return ResultUtils.success(coursesList);
+ }
+
+ @ApiOperation("根据id查询课程")
+ @GetMapping("/{id}")
+ public BaseResponse getByIdCourse(@PathVariable String id){
+ Courses course = coursesService.getById(id);
+ CoursesDTO coursesDTO = new CoursesDTO();
+ BeanUtils.copyProperties(course,coursesDTO);
+ return ResultUtils.success(coursesDTO);
+ }
+
+ @ApiOperation("根据id修改课程")
+ @PutMapping
+ public BaseResponse editCourse(@RequestBody CoursesDTO coursesDTO){
+ String courseId = coursesDTO.getId();
+ Courses course = coursesService.getById(courseId);
+ BeanUtil.copyProperties(coursesDTO, course);
+ coursesService.updateById(course);
+ return ResultUtils.success("编辑成功");
+ }
+
+ //TODO:删除功能暂未完善,数据表缺失
+ @ApiOperation("根据ids批量删除课程")
+ @DeleteMapping("/{ids}")
+ public BaseResponse deleteCourses(@PathVariable List ids){
+ System.out.println(ids);
+ coursesService.removeBatchByIds(ids);
+ return ResultUtils.success("删除成功");
+ }
+
+
+}
diff --git a/src/main/java/com/teaching/backend/mapper/courses/CourseObjectivesMapper.java b/src/main/java/com/teaching/backend/mapper/courses/CourseObjectivesMapper.java
new file mode 100644
index 0000000..0498edf
--- /dev/null
+++ b/src/main/java/com/teaching/backend/mapper/courses/CourseObjectivesMapper.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.CourseObjectives;
+
+/**
+ *
+ * Mapper 接口
+ *
+ *
+ * @author zjh
+ * @since 2024-05-31
+ */
+public interface CourseObjectivesMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/teaching/backend/mapper/courses/CoursesMapper.java b/src/main/java/com/teaching/backend/mapper/courses/CoursesMapper.java
new file mode 100644
index 0000000..14d3764
--- /dev/null
+++ b/src/main/java/com/teaching/backend/mapper/courses/CoursesMapper.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.Courses;
+
+/**
+ *
+ * Mapper 接口
+ *
+ *
+ * @author zjh
+ * @since 2024-05-30
+ */
+public interface CoursesMapper 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
new file mode 100644
index 0000000..fa6cc3a
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/dto/courses/CourseObjectivesDTO.java
@@ -0,0 +1,39 @@
+package com.teaching.backend.model.dto.courses;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(description = "分项目标参数实体")
+public class CourseObjectivesDTO {
+ /**
+ * 内部编号
+ */
+ @ApiModelProperty("id")
+ private String id;
+
+ /**
+ * 分项目标名称
+ */
+ @ApiModelProperty(value = "分项目标名称",required = true)
+ private String name;
+ /**
+ * 分项目标类型 思政1 知识2、素质3、价值4
+ */
+ @ApiModelProperty(value = "分项目标类型 思政1 知识2、素质3、价值4",required = true)
+ private String type;
+ /**
+ * 分项目标描述
+ */
+ @ApiModelProperty(value = "分项目标内容",required = true)
+ private String content;
+
+ /**
+ * 父节点
+ */
+ @ApiModelProperty(value = "父节点pid",required = true)
+ 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
new file mode 100644
index 0000000..65a6794
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/dto/courses/CoursesDTO.java
@@ -0,0 +1,100 @@
+package com.teaching.backend.model.dto.courses;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel(description = "教师创建课程参数实体")
+public class CoursesDTO {
+ /**
+ * 内部编号
+ */
+ @ApiModelProperty("id")
+ private String id;
+ /**
+ * 创建人 教师id
+ */
+ @ApiModelProperty("负责教师")
+ private String teacher;
+ /**
+ * 创建日期
+ */
+ @ApiModelProperty("创建日期")
+ private LocalDateTime createTime;
+ /**
+ * 课程封面
+ */
+ @ApiModelProperty("图片")
+ private String img;
+
+ /**
+ * 课程类别 专业教育 通识教育
+ */
+ @ApiModelProperty(value = "课程类别:专业教育 通识教育",required = true)
+ private String category;
+
+ /**
+ * 课程性质 必修选修任修
+ */
+ @ApiModelProperty(value = "课程性质:必修,选修,任修",required = true)
+ private String nature;
+
+ /**
+ * 课程名称
+ */
+ @ApiModelProperty(value = "课程名称",required = true)
+ private String name;
+
+ /**
+ * 课程编码
+ */
+ @ApiModelProperty(value = "课程编码",required = true)
+ private String code;
+
+
+ /**
+ * 课程学分
+ */
+ @ApiModelProperty(value = "课程学分",required = true)
+ private BigDecimal credit;
+
+ /**
+ * 课程学时
+ */
+ @ApiModelProperty(value = "课程学时",required = true)
+ private Integer classhours;
+
+ /**
+ * 考核类型 考试 考查
+ */
+ @ApiModelProperty(value = "考核类型:考试 考查",required = true)
+ private String assessmenttype;
+
+ /**
+ * 考核方式 开卷 闭卷 其他
+ */
+ @ApiModelProperty(value = "考核方式:开卷 闭卷 其他",required = true)
+ private String assessmentway;
+
+ /**
+ * 教学方法
+ */
+ @ApiModelProperty("教学方法")
+ private String teachermethod;
+
+ /**
+ * 教学方式
+ */
+ @ApiModelProperty("教学方式")
+ private String teacherway;
+
+ /**
+ * 课程简介
+ */
+ @ApiModelProperty("课程简介")
+ private String description;
+}
diff --git a/src/main/java/com/teaching/backend/model/dto/courses/PageDTO.java b/src/main/java/com/teaching/backend/model/dto/courses/PageDTO.java
new file mode 100644
index 0000000..6543158
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/dto/courses/PageDTO.java
@@ -0,0 +1,60 @@
+package com.teaching.backend.model.dto.courses;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Data
+@ApiModel(description = "分页结果")
+public class PageDTO {
+ @ApiModelProperty("总条数")
+ private Long total;
+ @ApiModelProperty("总页数")
+ private Long pages;
+ @ApiModelProperty("集合")
+ private List list;
+
+ public static PageDTO of(Page p, Class clazz){
+ PageDTO dto = new PageDTO<>();
+ // 1.总条数
+ dto.setTotal(p.getTotal());
+ // 2.总页数
+ dto.setPages(p.getPages());
+ // 3.当前页数据
+ List records = p.getRecords();
+ if (CollUtil.isEmpty(records)) {
+ dto.setList(Collections.emptyList());
+ return dto;
+ }
+ // 4.拷贝user的VO
+ dto.setList(BeanUtil.copyToList(records, clazz));
+ // 5.返回
+ return dto;
+ }
+
+ public static PageDTO of(Page p, Function convertor){
+ PageDTO dto = new PageDTO<>();
+ // 1.总条数
+ dto.setTotal(p.getTotal());
+ // 2.总页数
+ dto.setPages(p.getPages());
+ // 3.当前页数据
+ List records = p.getRecords();
+ if (CollUtil.isEmpty(records)) {
+ dto.setList(Collections.emptyList());
+ return dto;
+ }
+ // 4.拷贝user的VO
+ dto.setList(records.stream().map(convertor).collect(Collectors.toList()));
+ // 5.返回
+ return dto;
+ }
+}
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
new file mode 100644
index 0000000..ed298f7
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/entity/courses/CourseObjectives.java
@@ -0,0 +1,68 @@
+package com.teaching.backend.model.entity.courses;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ *
+ *
+ *
+ *
+ * @author zjh
+ * @since 2024-05-31
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("course_objectives")
+@ApiModel(value="CourseObjectives对象", description="")
+public class CourseObjectives implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "内部编号")
+ @TableId(value = "id", type = IdType.ASSIGN_UUID)
+ private String id;
+
+ @ApiModelProperty(value = "创建日期")
+ private LocalDateTime createTime;
+
+
+ @ApiModelProperty(value = "更新日期")
+ private LocalDateTime updateTime;
+
+ @ApiModelProperty(value = "父级节点")
+ private String pid;
+
+ @ApiModelProperty(value = "是否有子节点")
+ private String hasChild;
+
+ @ApiModelProperty(value = "目标名称")
+ private String name;
+
+ @ApiModelProperty(value = "目标类型")
+ private String type;
+
+ @ApiModelProperty(value = "目标内容")
+ private String content;
+
+ @ApiModelProperty(value = "课程id")
+ private String courseid;
+
+ @ApiModelProperty(value = "毕业要求id")
+ private String requireid;
+
+ @ApiModelProperty(value = "毕业要求")
+ private String temp;
+
+
+}
diff --git a/src/main/java/com/teaching/backend/model/entity/courses/Courses.java b/src/main/java/com/teaching/backend/model/entity/courses/Courses.java
new file mode 100644
index 0000000..bb23b59
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/entity/courses/Courses.java
@@ -0,0 +1,143 @@
+package com.teaching.backend.model.entity.courses;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ *
+ *
+ *
+ *
+ * @author zjh
+ * @since 2024-05-30
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("courses")
+public class Courses implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 内部编号
+ */
+ @TableId(value = "id", type = IdType.ASSIGN_UUID)
+ private String id;
+
+
+ /**
+ * 创建日期
+ */
+ private LocalDateTime createTime;
+
+ /**
+ * 更新日期
+ */
+ private LocalDateTime updateTime;
+
+ /**
+ * 课程封面
+ */
+ private String img;
+
+ /**
+ * 课程类别
+ */
+ private String category;
+
+ /**
+ * 课程性质
+ */
+ private String nature;
+
+ /**
+ * 课程名称
+ */
+ private String name;
+
+ /**
+ * 课程编码
+ */
+ private String code;
+
+ /**
+ * 开课学期
+ */
+ private String semester;
+
+ /**
+ * 课程学分
+ */
+ private BigDecimal credit;
+
+ /**
+ * 课程学时
+ */
+ private Integer classhours;
+
+ /**
+ * 理论学时
+ */
+ private Integer theoryhours;
+
+ /**
+ * 实践学时
+ */
+ private Integer practicehours;
+
+ /**
+ * 实验学时
+ */
+ private Integer experimenthours;
+
+ /**
+ * 其他学时
+ */
+ private Integer otherhours;
+
+ /**
+ * 上课周数
+ */
+ private Integer weeks;
+
+ /**
+ * 考核类型
+ */
+ private String assessmenttype;
+
+ /**
+ * 考核方式
+ */
+ private String assessmentway;
+
+ /**
+ * 负责教师
+ */
+ private String teacher;
+
+ /**
+ * 教学方法
+ */
+ private String teachermethod;
+
+ /**
+ * 教学方式
+ */
+ private String teacherway;
+
+ /**
+ * 课程简介
+ */
+ private String description;
+
+
+}
diff --git a/src/main/java/com/teaching/backend/model/query/CourseQuery.java b/src/main/java/com/teaching/backend/model/query/CourseQuery.java
new file mode 100644
index 0000000..095a095
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/query/CourseQuery.java
@@ -0,0 +1,14 @@
+package com.teaching.backend.model.query;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@ApiModel(description = "课程查询条件实体")
+public class CourseQuery extends PageQuery {
+ @ApiModelProperty("课程名称关键字")
+ private String name;
+}
diff --git a/src/main/java/com/teaching/backend/model/query/PageQuery.java b/src/main/java/com/teaching/backend/model/query/PageQuery.java
new file mode 100644
index 0000000..de934c9
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/query/PageQuery.java
@@ -0,0 +1,44 @@
+package com.teaching.backend.model.query;
+
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(description = "分页查询实体")
+public class PageQuery {
+ @ApiModelProperty("页码")
+ private Integer pageNo = 1;
+ @ApiModelProperty("页码")
+ private Integer pageSize = 10;
+ @ApiModelProperty("排序字段")
+ private String sortBy;
+ @ApiModelProperty("是否升序")
+ private Boolean isAsc = true;
+
+ public Page toMpPage(OrderItem ... items){
+ // 1.分页条件
+ Page page = Page.of(pageNo, pageSize);
+ // 2.排序条件
+ if(StrUtil.isNotBlank(sortBy)){
+ // 不为空
+ page.addOrder(new OrderItem(sortBy, isAsc));
+ }else if(items != null){
+ // 为空,默认排序
+ page.addOrder(items);
+ }
+ return page;
+ }
+ public Page toMpPage(String defaultSortBy, Boolean defaultAsc){
+ return toMpPage(new OrderItem(defaultSortBy, defaultAsc));
+ }
+ public Page toMpPageDefaultSortByCreateTime(){
+ return toMpPage(new OrderItem("create_time", false));
+ }
+ public Page toMpPageDefaultSortByUpdateTime(){
+ return toMpPage(new OrderItem("update_time", false));
+ }
+}
diff --git a/src/main/java/com/teaching/backend/model/vo/CoursesVO.java b/src/main/java/com/teaching/backend/model/vo/CoursesVO.java
new file mode 100644
index 0000000..3a14a6e
--- /dev/null
+++ b/src/main/java/com/teaching/backend/model/vo/CoursesVO.java
@@ -0,0 +1,48 @@
+package com.teaching.backend.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@ApiModel(description = "课程VO实体")
+public class CoursesVO {
+
+ /**
+ * 内部编号
+ */
+ @ApiModelProperty("id")
+ private String id;
+ /**
+ * 教师id
+ */
+ @ApiModelProperty("教师id")
+ private String teacher;
+ /**
+ * 课程封面
+ */
+ @ApiModelProperty("图片")
+ private String img;
+
+ /**
+ * 课程名称
+ */
+ @ApiModelProperty(value = "课程名称",required = true)
+ private String name;
+
+
+ /**
+ * 课程学分
+ */
+ @ApiModelProperty(value = "课程学分",required = true)
+ private BigDecimal credit;
+
+ /**
+ * 课程学时
+ */
+ @ApiModelProperty(value = "课程学时",required = true)
+ private Integer classhours;
+
+}
diff --git a/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java b/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java
new file mode 100644
index 0000000..15d8f0c
--- /dev/null
+++ b/src/main/java/com/teaching/backend/service/courses/ICourseObjectivesService.java
@@ -0,0 +1,20 @@
+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;
+
+/**
+ *
+ * 服务类
+ *
+ *
+ * @author zjh
+ * @since 2024-05-31
+ */
+public interface ICourseObjectivesService extends IService {
+
+ String addObjectives(CourseObjectivesDTO courseObjectivesDTO);
+
+ String deleteObjectives(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
new file mode 100644
index 0000000..951743d
--- /dev/null
+++ b/src/main/java/com/teaching/backend/service/courses/ICoursesService.java
@@ -0,0 +1,27 @@
+package com.teaching.backend.service.courses;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+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.query.CourseQuery;
+import com.teaching.backend.model.vo.CoursesVO;
+
+
+/**
+ *
+ * 服务类
+ *
+ *
+ * @author zjh
+ * @since 2024-05-30
+ */
+public interface ICoursesService extends IService {
+
+ String saveCourseWithObjective(CoursesDTO coursesDTO, String teacherId);
+
+ PageDTO queryCourses(CourseQuery courseQuery, String teacherId);
+
+
+}
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
new file mode 100644
index 0000000..7642876
--- /dev/null
+++ b/src/main/java/com/teaching/backend/service/impl/courses/CourseObjectivesServiceImpl.java
@@ -0,0 +1,94 @@
+package com.teaching.backend.service.impl.courses;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.model.dto.courses.CourseObjectivesDTO;
+import com.teaching.backend.model.entity.courses.CourseObjectives;
+import com.teaching.backend.service.courses.ICourseObjectivesService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+
+/**
+ *
+ * 服务实现类
+ *
+ *
+ * @author zjh
+ * @since 2024-05-31
+ */
+@Service
+public class CourseObjectivesServiceImpl extends ServiceImpl implements ICourseObjectivesService {
+
+
+ @Autowired
+ CourseObjectivesMapper courseObjectivesMapper;
+
+ @Override
+ public String addObjectives(CourseObjectivesDTO courseObjectivesDTO) {
+ String pid = courseObjectivesDTO.getPid();
+ if(pid.equals(null)){
+ throw new BusinessException(ErrorCode.NOT_FOUND_ERROR,"pid父节点不能为空");
+ }
+ String hasChild = courseObjectivesMapper.selectById(pid).getHasChild();
+ String type = courseObjectivesDTO.getType();
+ if (hasChild.equals("0") && !type.equals("1")){
+ throw new BusinessException(ErrorCode.PARAMS_ILLEGAL,"请在添加完思政目标以后再添加此类型目标!");
+ }
+ //判断是否已经添加过思政目标
+ // TODO:思政目标能不能有多个??
+ if (courseObjectivesDTO.getType().equals("1")){
+ LambdaQueryWrapper 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,"思政目标已存在,禁止重复添加!");
+ }
+ }
+ //往表里面写分项目标
+ CourseObjectives courseObjectives = new CourseObjectives();
+ BeanUtil.copyProperties(courseObjectivesDTO,courseObjectives);
+ courseObjectives.setCreateTime(LocalDateTime.now());
+ courseObjectivesMapper.insert(courseObjectives);
+ //插入数据以后要把总体目标那边的haschild改成1
+ CourseObjectives objectives = courseObjectivesMapper.selectById(pid);
+ objectives.setHasChild("1");
+ courseObjectivesMapper.updateById(objectives);
+ return "添加成功";
+ }
+
+ @Override
+ public String deleteObjectives(String id) {
+
+ CourseObjectives courseObjectives = courseObjectivesMapper.selectById(id);
+ String type = courseObjectives.getType();
+ String pid = courseObjectives.getPid();
+ if (type.equals("1")){
+ 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 "删除成功";
+ }
+ else
+ {
+ throw new BusinessException(ErrorCode.OPERATION_ERROR, "请删除其他类型的分目标后再来删除思政目标");
+ }
+ }
+ else {
+ courseObjectivesMapper.deleteById(id);
+ return "删除成功";
+ }
+ }
+}
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
new file mode 100644
index 0000000..8ae4f40
--- /dev/null
+++ b/src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
@@ -0,0 +1,92 @@
+package com.teaching.backend.service.impl.courses;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+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.CoursesMapper;
+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.query.CourseQuery;
+import com.teaching.backend.model.vo.CoursesVO;
+import com.teaching.backend.service.courses.ICoursesService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+
+/**
+ *
+ * 服务实现类
+ *
+ *
+ * @author zjh
+ * @since 2024-05-30
+ */
+@Service
+public class CoursesServiceImpl extends ServiceImplimplements ICoursesService {
+
+ @Autowired
+ CoursesMapper coursesMapper;
+
+ @Autowired
+ CourseObjectivesMapper courseObjectivesMapper;
+
+ @Override
+ @Transactional
+ public String saveCourseWithObjective(CoursesDTO coursesDTO, String teacherId) {
+ Courses courses = new Courses();
+ CourseObjectives courseObjectives = new CourseObjectives();
+ BeanUtils.copyProperties(coursesDTO, courses);
+// List teacherIds = new ArrayList<>();
+// teacherIds.add(teacherId);
+// courses.setTeacher(String.valueOf(teacherIds));
+ courses.setTeacher(teacherId);
+ courses.setCreateTime(LocalDateTime.now());
+ String code = coursesDTO.getCode();
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("code", code);
+ Long count = coursesMapper.selectCount(queryWrapper);
+ if(count==0){
+ int insert = coursesMapper.insert(courses);
+ if (insert>0){
+ Courses courses1 = coursesMapper.selectOne(queryWrapper);
+ courseObjectives.setCourseid(courses1.getId());
+ courseObjectives.setCreateTime(courses1.getCreateTime());
+ courseObjectives.setName(courses1.getName()+"课程总体目标");
+ courseObjectivesMapper.insert(courseObjectives);
+ }
+ return "添加成功";
+ }else {
+ throw new BusinessException(ErrorCode.OPERATION_ERROR, "这个课程已经存在了!请联系系统相关人员为您导入课程数据!");
+ }
+
+ }
+
+ @Override
+ public PageDTO queryCourses(CourseQuery courseQuery, String teacherId) {
+ //要搜索的课程名字
+ String name = courseQuery.getName();
+ // 1.1构建分页条件
+ Page page = courseQuery.toMpPageDefaultSortByCreateTime();
+ // 2.分页查询
+ Page p = lambdaQuery()
+ .like(name != null, Courses::getName, name)
+// .eq(Courses::getTeacher,teacherId)
+// .apply("JSON_CONTAINS(teacher, JSON_QUOTE({0}))", teacherId)
+ .apply("FIND_IN_SET({0}, teacher)", teacherId)
+ .page(page);
+
+
+ return PageDTO.of(p,CoursesVO.class);
+ }
+
+
+}
diff --git a/src/main/resources/mapper/CourseObjectivesMapper.xml b/src/main/resources/mapper/CourseObjectivesMapper.xml
new file mode 100644
index 0000000..768a1c4
--- /dev/null
+++ b/src/main/resources/mapper/CourseObjectivesMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/src/main/resources/mapper/CoursesMapper.xml b/src/main/resources/mapper/CoursesMapper.xml
new file mode 100644
index 0000000..40f1979
--- /dev/null
+++ b/src/main/resources/mapper/CoursesMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+