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);
String data = objectiveContentsService.deleteById(id);
return ResultUtils.success(data);
}
@ApiOperation("修改目标内容")
@PutMapping("/update")
public BaseResponse updateContent(@RequestBody ObjectiveContents objectiveContents){
objectiveContentsService.updateById(objectiveContents);
return ResultUtils.success("修改成功");
}
@ApiOperation("根据id查询目标内容")
@GetMapping("/{id}")
public BaseResponse updateContent(@PathVariable String id){
ObjectiveContents objectiveContent = objectiveContentsService.getById(id);
return ResultUtils.success(objectiveContent);
}
}