| package com.wzy.serviceedu.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wzy.commonutils.R;
import com.wzy.serviceedu.entity.EduTeacher;
import com.wzy.serviceedu.entity.vo.TeacherQuery;
import com.wzy.serviceedu.service.EduTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/*
讲师 前端控制器
@author wzy
* @since 2021-09-10
*/
@Api(description=“讲师管理”)
@RestController
@RequestMapping(“/serviceedu/teacher”)
public class EduTeacherController {
@Autowired<br /> **private **EduTeacherService **eduTeacherService**;
_/*<br /> * @Description: id修改讲师信息<br /> * @Author: WangZiYao<br /> * @Date: 2021/9/10 23:26<br /> * 一般修改应该用Put请求,但是这里为使用 @RequestBody 传输数据,用Post请求。<br /> */<br /> _@PostMapping(value = **"/updateIdTeacher"**)<br /> **public **R updateIdTeacher(@RequestBody EduTeacher eduTeacher){<br /> **boolean **result = **eduTeacherService**.updateById(eduTeacher);<br /> **if **(result) {<br /> **return **R._ok_();<br /> } **else **{<br /> **return **R._error_();<br /> }<br /> }
_/*<br /> * @Description: 通过ID查询讲师信息<br /> * @Author: WangZiYao<br /> * @Date: 2021/9/10 23:23<br /> */<br /> _@GetMapping(value = **"/getIdTeacher/{id}"**)<br /> **public **R getIdTeacher(@PathVariable String id){<br /> EduTeacher eduTeacher = **eduTeacherService**.getById(id);<br /> **return **R._ok_().data(**"teacher"**,eduTeacher);<br /> }
}
| | —- |
Put请求 修改 的写法:
@PutMapping("{id}")
public R updateById(
@ApiParam(name = "id", value = "讲师ID", required = true)
@PathVariable String id,
@ApiParam(name = "teacher", value = "讲师对象", required = true)
@RequestBody Teacher teacher){
teacher.setId(id);
teacherService.updateById(teacher);
return R.ok();
}