123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package com.example.controller;
- import com.example.common.Result;
- import com.example.entity.Orders;
- import com.example.service.OrdersService;
- import com.github.pagehelper.PageInfo;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.List;
- /**
- * 订单信息前端操作接口
- **/
- @RestController
- @RequestMapping("/orders")
- public class OrdersController {
- @Resource
- private OrdersService ordersService;
- /**
- * 小程序下单
- */
- @PostMapping("/addOrder")
- public Result addOrder(@RequestBody Orders orders) {
- ordersService.addOrder(orders);
- return Result.success();
- }
- /**
- * 新增
- */
- @PostMapping("/add")
- public Result add(@RequestBody Orders orders) {
- ordersService.add(orders);
- return Result.success();
- }
- /**
- * 删除
- */
- @DeleteMapping("/delete/{id}")
- public Result deleteById(@PathVariable Integer id) {
- ordersService.deleteById(id);
- return Result.success();
- }
- /**
- * 批量删除
- */
- @DeleteMapping("/delete/batch")
- public Result deleteBatch(@RequestBody List<Integer> ids) {
- ordersService.deleteBatch(ids);
- return Result.success();
- }
- /**
- * 修改
- */
- @PutMapping("/update")
- public Result updateById(@RequestBody Orders orders) {
- ordersService.updateById(orders);
- return Result.success();
- }
- /**
- * 根据ID查询
- */
- @GetMapping("/selectById/{id}")
- public Result selectById(@PathVariable Integer id) {
- Orders orders = ordersService.selectById(id);
- return Result.success(orders);
- }
- /**
- * 查询所有
- */
- @GetMapping("/selectAll")
- public Result selectAll(Orders orders) {
- List<Orders> list = ordersService.selectAll(orders);
- return Result.success(list);
- }
- /**
- * 分页查询
- */
- @GetMapping("/selectPage")
- public Result selectPage(Orders orders,
- @RequestParam(defaultValue = "1") Integer pageNum,
- @RequestParam(defaultValue = "10") Integer pageSize) {
- PageInfo<Orders> page = ordersService.selectPage(orders, pageNum, pageSize);
- return Result.success(page);
- }
- }
|