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("编辑成功"); } }