javaEEday10-tlias-案例-部门管理-统一功能模块的父路径
This commit is contained in:
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Slf4j//自动生成logback日志框架的对象log,在整个类中都可以直接使用logger
|
||||
@RequestMapping("/depts")//部门功能的统一URL前缀
|
||||
public class DeptController {
|
||||
|
||||
@Autowired//让spring容器进行依赖注入
|
||||
@@ -20,7 +21,8 @@ public class DeptController {
|
||||
//private static Logger logger = LoggerFactory.getLogger("com.inmind.controller.DeptController");
|
||||
|
||||
// @RequestMapping(value = "/depts",method = {RequestMethod.GET})
|
||||
@GetMapping("/depts")
|
||||
// @GetMapping("/depts")
|
||||
@GetMapping
|
||||
public Result deptList(){
|
||||
//接收请求
|
||||
log.info("查询全部部门数据请求");
|
||||
@@ -30,7 +32,8 @@ public class DeptController {
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/depts/{id}",method = {RequestMethod.DELETE})
|
||||
@DeleteMapping("/depts/{id}")
|
||||
// @DeleteMapping("/depts/{id}")
|
||||
@DeleteMapping("/{id}")
|
||||
//PathVariable:路径参数的注解,用来将url地址上的id参数赋值给形参id
|
||||
public Result deleteDept(@PathVariable Integer id){
|
||||
log.info("删除部门:{}",id);
|
||||
@@ -41,7 +44,8 @@ public class DeptController {
|
||||
}
|
||||
|
||||
//请求参数为json时{} [],要使用java的对象或者集合来接收
|
||||
@PostMapping("/depts")
|
||||
// @PostMapping("/depts")
|
||||
@PostMapping
|
||||
public Result addDept(@RequestBody Dept dept) {
|
||||
log.info("新增部门{}",dept);
|
||||
//调用业务层的新增部门方法
|
||||
|
||||
Reference in New Issue
Block a user