| 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 {

    1. @Autowired<br /> **private **EduTeacherService **eduTeacherService**;
    2. _/*<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 /> }
    3. _/*<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请求 修改 的写法:

    1. @PutMapping("{id}")
    2. public R updateById(
    3. @ApiParam(name = "id", value = "讲师ID", required = true)
    4. @PathVariable String id,
    5. @ApiParam(name = "teacher", value = "讲师对象", required = true)
    6. @RequestBody Teacher teacher){
    7. teacher.setId(id);
    8. teacherService.updateById(teacher);
    9. return R.ok();
    10. }