- mapping层(dao层)
//实现一些增删改查操作
@Mapper//将接口交由IOC容器管理
public interface DeptMapper {
//添加增删改查所用注解
@insert
@delete
@update
@select
}
@RestController//表明这是一个请求处理类
public class DeptController {
@GetMapping("路径名")//该路径下GET请求将调用此方法
@PutMapping("路径名")//该路径下PUT请求将调用此方法
@DeleteMapping("路径名")//该路径下DELETE请求将调用此方法
@PostMapping("路径名")//该路径下POST请求将调用此方法
}
//解释@PathVariable和@PathVariable注解
//分别对请求体和参数中的内容进行打包
/**
* 新增部门
*/
@PostMapping("/depts")
public Result add(@RequestBody Dept dept){
System.out.println("新增部门" + dept);
deptService.add(dept);
return Result.success();
}
/**
* 获取修改部门信息
*/
@GetMapping("/depts/{id}")
public Result getInfo(@PathVariable("id") Integer deptId){
System.out.println("修改部门id:"+ deptId);
Dept dept = deptService.getById(deptId);
return Result.success(dept);
}