OrdersController.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package com.example.controller;
  2. import com.example.common.Result;
  3. import com.example.entity.Orders;
  4. import com.example.service.OrdersService;
  5. import com.github.pagehelper.PageInfo;
  6. import org.springframework.web.bind.annotation.*;
  7. import javax.annotation.Resource;
  8. import java.util.List;
  9. /**
  10. * 订单信息前端操作接口
  11. **/
  12. @RestController
  13. @RequestMapping("/orders")
  14. public class OrdersController {
  15. @Resource
  16. private OrdersService ordersService;
  17. /**
  18. * 小程序下单
  19. */
  20. @PostMapping("/addOrder")
  21. public Result addOrder(@RequestBody Orders orders) {
  22. ordersService.addOrder(orders);
  23. return Result.success();
  24. }
  25. /**
  26. * 新增
  27. */
  28. @PostMapping("/add")
  29. public Result add(@RequestBody Orders orders) {
  30. ordersService.add(orders);
  31. return Result.success();
  32. }
  33. /**
  34. * 删除
  35. */
  36. @DeleteMapping("/delete/{id}")
  37. public Result deleteById(@PathVariable Integer id) {
  38. ordersService.deleteById(id);
  39. return Result.success();
  40. }
  41. /**
  42. * 批量删除
  43. */
  44. @DeleteMapping("/delete/batch")
  45. public Result deleteBatch(@RequestBody List<Integer> ids) {
  46. ordersService.deleteBatch(ids);
  47. return Result.success();
  48. }
  49. /**
  50. * 修改
  51. */
  52. @PutMapping("/update")
  53. public Result updateById(@RequestBody Orders orders) {
  54. ordersService.updateById(orders);
  55. return Result.success();
  56. }
  57. /**
  58. * 根据ID查询
  59. */
  60. @GetMapping("/selectById/{id}")
  61. public Result selectById(@PathVariable Integer id) {
  62. Orders orders = ordersService.selectById(id);
  63. return Result.success(orders);
  64. }
  65. /**
  66. * 查询所有
  67. */
  68. @GetMapping("/selectAll")
  69. public Result selectAll(Orders orders) {
  70. List<Orders> list = ordersService.selectAll(orders);
  71. return Result.success(list);
  72. }
  73. /**
  74. * 分页查询
  75. */
  76. @GetMapping("/selectPage")
  77. public Result selectPage(Orders orders,
  78. @RequestParam(defaultValue = "1") Integer pageNum,
  79. @RequestParam(defaultValue = "10") Integer pageSize) {
  80. PageInfo<Orders> page = ordersService.selectPage(orders, pageNum, pageSize);
  81. return Result.success(page);
  82. }
  83. }