定义在类上:@Api
定义在方法上:@ApiOperation
定义在参数上:@ApiParam
定在在需要提示的,形参前面:@ApiParam(name = “id”, value = “讲师ID”, required = true)
| package com.wzy.serviceedu.controller;
import com.wzy.serviceedu.entity.EduTeacher;
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.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: 查询所有讲师信息<br /> * @Author: WangZiYao<br /> * @Date: 2021/9/10 13:49<br /> */<br /> //http://localhost:8001/serviceedu/teacher/findAll<br /> @ApiOperation(value = **"所有讲师列表"**)<br /> @GetMapping(value = **"/findAll"**)<br /> **public **List<EduTeacher> findAllTeacher(){<br /> //调用service中的list方法,传入null值查询所有的数据<br /> List<EduTeacher> list = **eduTeacherService**.list(**null**);<br /> **return **list;<br /> }
/*<br /> * @Description: 逻辑删除讲师的方法<br /> * @Author: WangZiYao<br /> * @Date: 2021/9/10 13:50<br /> * @ApiParam(name = "id", value = "讲师ID", required = true),swagger中的提示<br /> */<br /> @ApiOperation(value = **"根据ID逻辑删除讲师"**)<br /> @DeleteMapping(value = **"/{id}"**)<br /> **public boolean **removeTeacher(@ApiParam(name = **"id"**, value = **"讲师ID"**, required = **true**) @PathVariable(**"id"**) String id){<br /> **boolean **flag = **eduTeacherService**.removeById(id);<br /> **return **flag;<br /> }
}
| | —- |