1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| @Slf4j @RestController @RequestMapping("/emps") public class EmpController {
@Autowired private EmpService empService;
@GetMapping public Result page(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pageSize, String name, Short gender, @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin, @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){ log.info("分页查询, 参数: {},{},{},{},{},{}",page,pageSize,name,gender,begin,end); PageBean pageBean = empService.page(page,pageSize,name,gender,begin,end); return Result.success(pageBean); }
@Log @DeleteMapping("/{ids}") public Result delete(@PathVariable List<Integer> ids){ log.info("批量删除操作, ids:{}",ids); empService.delete(ids); return Result.success(); }
@Log @PostMapping public Result save(@RequestBody Emp emp){ log.info("新增员工, emp: {}", emp); empService.save(emp); return Result.success(); }
@GetMapping("/{id}") public Result getById(@PathVariable Integer id){ log.info("根据ID查询员工信息, id: {}",id); Emp emp = empService.getById(id); return Result.success(emp); }
@Log @PutMapping public Result update(@RequestBody Emp emp){ log.info("更新员工信息 : {}", emp); empService.update(emp); return Result.success(); } }
|