Commit 21afbe4d0cd3ebfda547e8d548690d17ef017c16

Authored by yangfan
2 parents 327b2d2d d2343ef0
src/main/java/com/diligrp/xtrade/order/controllor/OrderApiControllor.java renamed to src/main/java/com/diligrp/xtrade/order/controllor/OrderApiController.java
1   -package com.diligrp.xtrade.order.controllor;
2   -
3   -import java.util.List;
4   -
5   -import javax.annotation.Resource;
6   -
7   -import org.springframework.validation.annotation.Validated;
8   -import org.springframework.web.bind.annotation.RequestBody;
9   -import org.springframework.web.bind.annotation.RequestMapping;
10   -import org.springframework.web.bind.annotation.RequestMethod;
11   -import org.springframework.web.bind.annotation.RestController;
12   -
13   -import com.diligrp.xtrade.order.domain.dto.OrderCreateRequestDto;
14   -import com.diligrp.xtrade.order.domain.dto.OrderQueryRequestDto;
15   -import com.diligrp.xtrade.order.domain.dto.OrderQueryResponseDto;
16   -import com.diligrp.xtrade.order.service.Orderservice;
17   -import com.diligrp.xtrade.shared.domain.Message;
18   -
19   -/**
20   - * 订单相关接口实现
21   - * @author zhangxing
22   - * @Date 2020/04/13
23   - */
24   -@RestController
25   -@RequestMapping(value = "/sapi/order")
26   -public class OrderApiControllor {
27   -
28   - @Resource
29   - private Orderservice orderservice;
30   -
31   - /**
32   - * 订单创建接口
33   - */
34   - @RequestMapping(value = "/createOrder",method = {RequestMethod.POST})
35   - public Message<Boolean> createOrder(@RequestBody @Validated OrderCreateRequestDto orderCreateRequestDto) {
36   - orderservice.createOrder(orderCreateRequestDto);
37   - return Message.<Boolean>builder().success(Boolean.TRUE);
38   - }
39   -
40   - /**
41   - * 订单列表接口
42   - */
43   - @RequestMapping(value = "/listOrders")
44   - public Message<List<OrderQueryResponseDto>> listOrders(@RequestBody OrderQueryRequestDto orderQueryRequestDto) {
45   - return Message.<List<OrderQueryResponseDto>>builder().success(orderservice.orderLists(orderQueryRequestDto));
46   - }
47   -
48   - /**
49   - * 订单详情
50   - */
51   - @RequestMapping(value = "/orderDetail")
52   - public Message<OrderQueryResponseDto> orderDetail(@RequestBody @Validated OrderQueryRequestDto orderQueryRequestDto) {
53   - return Message.<OrderQueryResponseDto>builder().success(orderservice.orderDetail(orderQueryRequestDto));
54   - }
55   -}
  1 +package com.diligrp.xtrade.order.controllor;
  2 +
  3 +import java.util.List;
  4 +
  5 +import javax.annotation.Resource;
  6 +
  7 +import org.springframework.validation.annotation.Validated;
  8 +import org.springframework.web.bind.annotation.RequestBody;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestMethod;
  11 +import org.springframework.web.bind.annotation.RestController;
  12 +
  13 +import com.diligrp.xtrade.order.domain.dto.OrderCreateRequestDto;
  14 +import com.diligrp.xtrade.order.domain.dto.OrderQueryRequestDto;
  15 +import com.diligrp.xtrade.order.domain.dto.OrderQueryResponseDto;
  16 +import com.diligrp.xtrade.order.service.Orderservice;
  17 +import com.diligrp.xtrade.shared.domain.Message;
  18 +
  19 +/**
  20 + * 订单相关接口实现
  21 + * @author zhangxing
  22 + * @Date 2020/04/13
  23 + */
  24 +@RestController
  25 +@RequestMapping(value = "/sapi/order")
  26 +public class OrderApiController {
  27 +
  28 + @Resource
  29 + private Orderservice orderservice;
  30 +
  31 + /**
  32 + * 订单创建接口
  33 + */
  34 + @RequestMapping(value = "/createOrder",method = {RequestMethod.POST})
  35 + public Message<Boolean> createOrder(@RequestBody @Validated OrderCreateRequestDto orderCreateRequestDto) {
  36 + orderservice.createOrder(orderCreateRequestDto);
  37 + return Message.<Boolean>builder().success(Boolean.TRUE);
  38 + }
  39 +
  40 + /**
  41 + * 订单列表接口
  42 + */
  43 + @RequestMapping(value = "/listOrders")
  44 + public Message<List<OrderQueryResponseDto>> listOrders(@RequestBody OrderQueryRequestDto orderQueryRequestDto) {
  45 + return Message.<List<OrderQueryResponseDto>>builder().success(orderservice.orderLists(orderQueryRequestDto));
  46 + }
  47 +
  48 + /**
  49 + * 订单详情
  50 + */
  51 + @RequestMapping(value = "/orderDetail")
  52 + public Message<OrderQueryResponseDto> orderDetail(@RequestBody @Validated OrderQueryRequestDto orderQueryRequestDto) {
  53 + return Message.<OrderQueryResponseDto>builder().success(orderservice.orderDetail(orderQueryRequestDto));
  54 + }
  55 +}
... ...
src/main/java/com/diligrp/xtrade/order/exception/OrderExceptionHandler.java
1   -package com.diligrp.xtrade.order.exception;
2   -
3   -import org.springframework.web.bind.annotation.ControllerAdvice;
4   -import org.springframework.web.bind.annotation.ExceptionHandler;
5   -import org.springframework.web.bind.annotation.ResponseBody;
6   -
7   -import com.diligrp.xtrade.shared.domain.Message;
8   -import com.netflix.client.ClientException;
9   -
10   -/**
11   - * @Auther: zhangxing
12   - * @Date: 2020/4/17 11:22
13   - */
14   -@ControllerAdvice
15   -public class OrderExceptionHandler {
16   -
17   - @ResponseBody
18   - @ExceptionHandler({ClientException.class})
19   - public Message<?> handleFeignClientException(ClientException ex) {
20   - return Message.builder().failure(ex.getMessage());
21   - }
22   -
23   - @ResponseBody
24   - @ExceptionHandler({OrderException.class})
25   - public Message<?> handleOrderException(OrderException ex) {
26   - return Message.builder().failure(ex.getCode(), ex.getMessage());
27   - }
28   -}
  1 +package com.diligrp.xtrade.order.exception;
  2 +
  3 +import org.springframework.web.bind.annotation.ControllerAdvice;
  4 +import org.springframework.web.bind.annotation.ExceptionHandler;
  5 +import org.springframework.web.bind.annotation.ResponseBody;
  6 +
  7 +import com.diligrp.xtrade.shared.domain.Message;
  8 +
  9 +/**
  10 + * @Auther: zhangxing
  11 + * @Date: 2020/4/17 11:22
  12 + */
  13 +@ControllerAdvice
  14 +public class OrderExceptionHandler {
  15 +
  16 + @ResponseBody
  17 + @ExceptionHandler({OrderException.class})
  18 + public Message<?> handleOrderException(OrderException ex) {
  19 + return Message.builder().failure(ex.getCode(), ex.getMessage());
  20 + }
  21 +}
... ...