图谱-后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.2 KiB

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;
/**
* <p>
* 前端控制器
* </p>
*
* @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<String> saveCourseObjectives(@RequestBody CourseObjectivesDTO courseObjectivesDTO){
String data = courseObjectivesService.addObjectives(courseObjectivesDTO);
return ResultUtils.success(data);
}
@ApiOperation("删除分项目标-只能最后一个删除思政目标")
@DeleteMapping("/{id}")
public BaseResponse<String> deleteCourseObjectivesByIds(@PathVariable String id){
String data = courseObjectivesService.deleteObjectives(id);
return ResultUtils.success(data);
}
@ApiOperation("编辑分项目标")
@PutMapping
public BaseResponse<String> 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("编辑成功");
}
}