敏捷工具
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.9 KiB

2 years ago
  1. package com.whn.hellospring.controller;
  2. import com.whn.hellospring.model.CoffeeOrderDTO;
  3. import com.whn.hellospring.request.DeleteOrderRequest;
  4. import com.whn.hellospring.request.GetOrderRequest;
  5. import com.whn.hellospring.request.getOrderListWithCustomerIdRequest;
  6. import com.whn.hellospring.service.CoffeeOrderService;
  7. import com.whn.hellospring.service.CoffeeService;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.*;
  10. import javax.validation.Valid;
  11. import java.util.List;
  12. @RestController
  13. @RequestMapping(value = "/order")
  14. public class CoffeeOrderController extends BaseController{
  15. @Autowired
  16. CoffeeOrderService orderService;
  17. @Autowired
  18. CoffeeService coffeeService;
  19. /**
  20. * 创建一个订单
  21. */
  22. @PostMapping(value = "/create")
  23. public String createOrder(@Valid @RequestBody CoffeeOrderDTO coffeeOrderDTO){
  24. orderService.createOrder(coffeeOrderDTO);
  25. return "success";
  26. }
  27. /**
  28. * 获取一个订单根据orderId
  29. */
  30. @PostMapping(value = "/getOrder")
  31. public CoffeeOrderDTO getOrderById(@RequestBody GetOrderRequest request){
  32. CoffeeOrderDTO orderDTO = orderService.getOrderById(request.getId());
  33. return orderDTO;
  34. }
  35. /**
  36. * 订单删除
  37. */
  38. @PostMapping(value = "/delete")
  39. public String deleteOrderById(@RequestBody DeleteOrderRequest request){
  40. orderService.deleteOrderById(request.getId());
  41. return "success";
  42. }
  43. /**
  44. * 根据客户id获取订单列表
  45. */
  46. @PostMapping(value = "/getOrderListWithCustomerId")
  47. public List<CoffeeOrderDTO> getOrderListWithCustomerId(@RequestBody getOrderListWithCustomerIdRequest request){
  48. List<CoffeeOrderDTO> orderListByCustomerId = orderService.getOrderListByCustomerId(request.getCustomerId());
  49. return orderListByCustomerId;
  50. }
  51. }