Commit eab8b35d376a0686c17fd0d42972dd2d8fa4ebc6

Authored by Jiang
1 parent b29d8686

完成swagger配置

b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/BuyerConfirmRequestDto.java
... ... @@ -2,6 +2,8 @@ package com.b2c.orders.client.domain.dto.request;
2 2  
3 3 import javax.validation.constraints.NotNull;
4 4  
  5 +import io.swagger.annotations.ApiParam;
  6 +
5 7 public class BuyerConfirmRequestDto extends BaseRequestDto {
6 8  
7 9 /**
... ... @@ -9,10 +11,10 @@ public class BuyerConfirmRequestDto extends BaseRequestDto {
9 11 */
10 12 private static final long serialVersionUID = 5323840474125840652L;
11 13  
12   -// @ApiParam(value = "订单id", required = true)
  14 + @ApiParam(value = "订单id", required = true)
13 15 @NotNull(message = "订单id不能为空")
14 16 private Long orderId;
15   -// @ApiParam(value = "买家id", required = true)
  17 + @ApiParam(value = "买家id", required = true)
16 18 @NotNull(message = "买家id不能为空")
17 19 private Long buyerId;
18 20  
... ...
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/DtmsTimeoutRequestDto.java
... ... @@ -9,7 +9,6 @@ public class DtmsTimeoutRequestDto extends BaseRequestDto {
9 9 */
10 10 private static final long serialVersionUID = 8454009010057359942L;
11 11  
12   -// @ApiParam(value = "订单id", required = true)
13 12 @NotNull(message = "订单id不能为空")
14 13 private Long orderId;
15 14  
... ...
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/OrderListRequestDto.java
1 1 package com.b2c.orders.client.domain.dto.request;
2 2  
3   -import java.util.Date;
4   -
5   -import com.b2c.orders.enums.OrderDeliveryType;
6 3 import com.b2c.orders.enums.OrderStatus;
7   -import com.b2c.orders.enums.PayStatus;
8   -import com.b2c.orders.enums.PayType;
  4 +
  5 +import io.swagger.annotations.ApiParam;
9 6  
10 7 public class OrderListRequestDto {
11 8  
12 9 /**
13 10 * 买家
14 11 */
  12 + @ApiParam(value = "买家id")
15 13 private Long buyerId;
16 14 /**
17 15 * 卖家
18 16 */
  17 + @ApiParam("卖家id")
19 18 private Long sellerId;
20   - /** 配送类型 */
21   - private OrderDeliveryType deliveryType;
22 19 /** 订单状态 */
  20 + @ApiParam("订单状态")
23 21 private OrderStatus orderStatus;
24   - /** 支付状态 */
25   - private PayStatus payStatus;
26   - /** 买家备注说明 */
27   - private String buyerMemo;
28   - /** 支付时间 */
29   - private Date payTime;
30   - /**
31   - * 送货时间
32   - */
33   - private Date deliveryTime;
34   - /**
35   - * 提货时间
36   - */
37   - private Date reservationTime;
38   - /**
39   - * 买家确认收货时间
40   - */
41   - private Date buyerConfirmTime;
42   - /**
43   - * 订单提交时间
44   - */
45   - private Date submitTime;
46   - /** 支付类型 */
47   - private PayType payType;
  22 + @ApiParam("每页显示记录数")
48 23 private Integer pageSize = 10;
  24 + @ApiParam("第几页")
49 25 private Integer page = 1;
50   - private Integer start;
51   - private Integer limit;
52 26  
53 27 public Long getBuyerId() {
54 28 return buyerId;
... ... @@ -66,14 +40,6 @@ public class OrderListRequestDto {
66 40 this.sellerId = sellerId;
67 41 }
68 42  
69   - public OrderDeliveryType getDeliveryType() {
70   - return deliveryType;
71   - }
72   -
73   - public void setDeliveryType(OrderDeliveryType deliveryType) {
74   - this.deliveryType = deliveryType;
75   - }
76   -
77 43 public OrderStatus getOrderStatus() {
78 44 return orderStatus;
79 45 }
... ... @@ -82,70 +48,6 @@ public class OrderListRequestDto {
82 48 this.orderStatus = orderStatus;
83 49 }
84 50  
85   - public PayStatus getPayStatus() {
86   - return payStatus;
87   - }
88   -
89   - public void setPayStatus(PayStatus payStatus) {
90   - this.payStatus = payStatus;
91   - }
92   -
93   - public String getBuyerMemo() {
94   - return buyerMemo;
95   - }
96   -
97   - public void setBuyerMemo(String buyerMemo) {
98   - this.buyerMemo = buyerMemo;
99   - }
100   -
101   - public Date getPayTime() {
102   - return payTime;
103   - }
104   -
105   - public void setPayTime(Date payTime) {
106   - this.payTime = payTime;
107   - }
108   -
109   - public Date getDeliveryTime() {
110   - return deliveryTime;
111   - }
112   -
113   - public void setDeliveryTime(Date deliveryTime) {
114   - this.deliveryTime = deliveryTime;
115   - }
116   -
117   - public Date getReservationTime() {
118   - return reservationTime;
119   - }
120   -
121   - public void setReservationTime(Date reservationTime) {
122   - this.reservationTime = reservationTime;
123   - }
124   -
125   - public Date getBuyerConfirmTime() {
126   - return buyerConfirmTime;
127   - }
128   -
129   - public void setBuyerConfirmTime(Date buyerConfirmTime) {
130   - this.buyerConfirmTime = buyerConfirmTime;
131   - }
132   -
133   - public Date getSubmitTime() {
134   - return submitTime;
135   - }
136   -
137   - public void setSubmitTime(Date submitTime) {
138   - this.submitTime = submitTime;
139   - }
140   -
141   - public PayType getPayType() {
142   - return payType;
143   - }
144   -
145   - public void setPayType(PayType payType) {
146   - this.payType = payType;
147   - }
148   -
149 51 public Integer getPageSize() {
150 52 return pageSize;
151 53 }
... ... @@ -162,20 +64,4 @@ public class OrderListRequestDto {
162 64 this.page = page;
163 65 }
164 66  
165   - public Integer getStart() {
166   - return start;
167   - }
168   -
169   - public void setStart(Integer start) {
170   - this.start = start;
171   - }
172   -
173   - public Integer getLimit() {
174   - return limit;
175   - }
176   -
177   - public void setLimit(Integer limit) {
178   - this.limit = limit;
179   - }
180   -
181 67 }
... ...
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/PayOrderRequestDto.java
... ... @@ -2,6 +2,8 @@ package com.b2c.orders.client.domain.dto.request;
2 2  
3 3 import javax.validation.constraints.NotNull;
4 4  
  5 +import io.swagger.annotations.ApiParam;
  6 +
5 7 public class PayOrderRequestDto extends BaseRequestDto {
6 8  
7 9 /**
... ... @@ -9,10 +11,10 @@ public class PayOrderRequestDto extends BaseRequestDto {
9 11 */
10 12 private static final long serialVersionUID = 7438455154625322536L;
11 13  
12   -// @ApiParam(value = "订单id", required = true)
  14 + @ApiParam(value = "订单id", required = true)
13 15 @NotNull(message = "订单id不能为空")
14 16 private Long orderId;
15   -// @ApiParam(value = "买家id", required = true)
  17 + @ApiParam(value = "买家id", required = true)
16 18 @NotNull(message = "买家id不能为空")
17 19 private Long buyerId;
18 20  
... ...
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/SellerRefuseRequestDto.java
... ... @@ -2,6 +2,8 @@ package com.b2c.orders.client.domain.dto.request;
2 2  
3 3 import javax.validation.constraints.NotNull;
4 4  
  5 +import io.swagger.annotations.ApiParam;
  6 +
5 7 public class SellerRefuseRequestDto extends BaseRequestDto {
6 8  
7 9 /**
... ... @@ -9,10 +11,10 @@ public class SellerRefuseRequestDto extends BaseRequestDto {
9 11 */
10 12 private static final long serialVersionUID = 1563792094069115492L;
11 13  
12   -// @ApiParam(value = "订单id", required = true)
  14 + @ApiParam(value = "订单id", required = true)
13 15 @NotNull(message = "订单id不能为空")
14 16 private Long orderId;
15   -// @ApiParam(value = "商家id", required = true)
  17 + @ApiParam(value = "商家id", required = true)
16 18 @NotNull(message = "商家id不能为空")
17 19 private Long sellerId;
18 20  
... ...
b2c-orders-client/src/main/java/com/b2c/orders/client/domain/dto/request/TakeOrderRequestDto.java
... ... @@ -2,6 +2,8 @@ package com.b2c.orders.client.domain.dto.request;
2 2  
3 3 import javax.validation.constraints.NotNull;
4 4  
  5 +import io.swagger.annotations.ApiParam;
  6 +
5 7 public class TakeOrderRequestDto extends BaseRequestDto {
6 8  
7 9 /**
... ... @@ -9,16 +11,16 @@ public class TakeOrderRequestDto extends BaseRequestDto {
9 11 */
10 12 private static final long serialVersionUID = -1409059930851556435L;
11 13  
12   -// @ApiParam(value = "订单id", required = true)
  14 + @ApiParam(value = "订单id", required = true)
13 15 @NotNull(message = "订单id不能为空")
14 16 private Long orderId;
15   -// @ApiParam(value = "商家id", required = true)
  17 + @ApiParam(value = "商家id", required = true)
16 18 @NotNull(message = "商家id不能为空")
17 19 private Long sellerId;
18 20 /**
19 21 * 订单总价
20 22 */
21   -// @ApiParam(value = "订单总价", required = true)
  23 + // @ApiParam(value = "订单总价", required = true)
22 24 @NotNull(message = "订单总价不能为空")
23 25 private Long totalPrice;
24 26  
... ...
b2c-orders-domain/src/main/java/com/b2c/orders/domain/Order.java
... ... @@ -66,6 +66,10 @@ public class Order extends BaseDomain {
66 66 private Date reservationTime;
67 67 /** 买家确认收货时间 */
68 68 private Date buyerConfirmTime;
  69 + /**
  70 + * 商家确认收款时间
  71 + */
  72 + private Date sellerConfirmTime;
69 73 /** 订单提交时间 */
70 74 private Date submitTime;
71 75 /** 支付类型 */
... ... @@ -75,7 +79,7 @@ public class Order extends BaseDomain {
75 79 /** 乐观锁(版本号) */
76 80 private Long versionNum;
77 81 /** 删除标志 */
78   - private Integer isDelete;
  82 + private Boolean delete;
79 83 /**
80 84 * 店铺
81 85 */
... ...
b2c-orders-web/pom.xml
... ... @@ -66,6 +66,22 @@
66 66 </exclusion>
67 67 </exclusions>
68 68 </dependency>
  69 + <dependency>
  70 + <groupId>com.fasterxml.jackson.core</groupId>
  71 + <artifactId>jackson-core</artifactId>
  72 + </dependency>
  73 + <dependency>
  74 + <groupId>com.fasterxml.jackson.core</groupId>
  75 + <artifactId>jackson-databind</artifactId>
  76 + </dependency>
  77 + <dependency>
  78 + <groupId>io.springfox</groupId>
  79 + <artifactId>springfox-swagger-ui</artifactId>
  80 + </dependency>
  81 + <dependency>
  82 + <groupId>io.swagger</groupId>
  83 + <artifactId>swagger-annotations</artifactId>
  84 + </dependency>
69 85 <!-- https://mvnrepository.com/artifact/com.mangofactory/swagger-springmvc -->
70 86 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
71 87 <!-- <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId>
... ...
b2c-orders-web/src/main/java/com/b2c/orders/configuration/SwaggerConfiguration.java
1 1 package com.b2c.orders.configuration;
2 2  
3 3 import org.springframework.context.annotation.Bean;
  4 +import org.springframework.context.annotation.ComponentScan;
4 5 import org.springframework.context.annotation.Configuration;
5 6 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
6 7 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
7 8 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
8 9  
9   -import springfox.documentation.builders.RequestHandlerSelectors;
10 10 import springfox.documentation.service.ApiInfo;
11 11 import springfox.documentation.spi.DocumentationType;
12 12 import springfox.documentation.spring.web.plugins.Docket;
... ... @@ -18,7 +18,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
18 18 public class SwaggerConfiguration extends WebMvcConfigurerAdapter {
19 19  
20 20 public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.b2c.orders";
21   -
  21 +
22 22 @Override
23 23 public void addResourceHandlers(ResourceHandlerRegistry registry) {
24 24 registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
... ... @@ -30,9 +30,8 @@ public class SwaggerConfiguration extends WebMvcConfigurerAdapter {
30 30 @Bean
31 31 public Docket swaggerSpringMvcPlugin() {
32 32 Docket docket = new Docket(DocumentationType.SWAGGER_2);
33   - docket.select().apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE)).build();
34   - ApiInfo apiInfo = new ApiInfo("咱的APP", "店铺用户接口", "1.1", "urn:tos", "b2c", "logistics-park", "http://zandeapp.com");
35   - docket.apiInfo(apiInfo);
  33 + ApiInfo apiInfo = new ApiInfo("一体化", "网关接口", "1.1", "urn:tos", "dili", "logistics-park", "http://dili.com");
  34 + docket.apiInfo(apiInfo);
36 35 return docket;
37 36 }
38 37 }
... ...
b2c-orders-web/src/main/java/com/b2c/orders/web/restful/OrderRestController.java
... ... @@ -7,6 +7,7 @@ import org.springframework.http.MediaType;
7 7 import org.springframework.validation.BindingResult;
8 8 import org.springframework.web.bind.annotation.RequestBody;
9 9 import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestMethod;
10 11 import org.springframework.web.bind.annotation.RestController;
11 12  
12 13 import com.b2c.dtms.common.enums.dtms.HandleCode;
... ... @@ -28,9 +29,10 @@ import com.b2c.orders.commons.exceptions.ApplicationException;
28 29 import com.b2c.orders.rpc.exception.DtmsRpcException;
29 30 import com.b2c.orders.service.OrderService;
30 31  
  32 +import io.swagger.annotations.Api;
31 33 import io.swagger.annotations.ApiOperation;
32 34  
33   -//@Api("订单api")
  35 +@Api("订单api")
34 36 @RestController
35 37 @RequestMapping("/api")
36 38 public class OrderRestController {
... ... @@ -39,7 +41,7 @@ public class OrderRestController {
39 41 private OrderService orderService;
40 42  
41 43 @ApiOperation("提交订单")
42   - @RequestMapping(value = "/buyer/submit", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  44 + @RequestMapping(value = "/submit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
43 45 public SubmitOrderResponseDto submit(@RequestBody @Valid SubmitOrderRequestDto order, BindingResult br) {
44 46 SubmitOrderResponseDto dto = new SubmitOrderResponseDto();
45 47 try {
... ... @@ -53,7 +55,7 @@ public class OrderRestController {
53 55 }
54 56  
55 57 @ApiOperation("商家接单")
56   - @RequestMapping(value = "/seller/take", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  58 + @RequestMapping(value = "/take", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
57 59 public BaseResponseDto take(@RequestBody @Valid TakeOrderRequestDto request, BindingResult br) {
58 60 BaseResponseDto dto = new BaseResponseDto();
59 61 try {
... ... @@ -67,7 +69,7 @@ public class OrderRestController {
67 69 }
68 70  
69 71 @ApiOperation("买家支付")
70   - @RequestMapping(value = "/buyer/pay", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  72 + @RequestMapping(value = "/pay", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
71 73 public BaseResponseDto pay(@RequestBody @Valid PayOrderRequestDto request, BindingResult br) {
72 74 BaseResponseDto dto = new BaseResponseDto();
73 75 try {
... ... @@ -81,7 +83,7 @@ public class OrderRestController {
81 83 }
82 84  
83 85 @ApiOperation("买家确认收货")
84   - @RequestMapping(value = "/buyer/confirm", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  86 + @RequestMapping(value = "/buyerConfirm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
85 87 public BaseResponseDto buyerConfirm(@RequestBody @Valid BuyerConfirmRequestDto request, BindingResult br) {
86 88 BaseResponseDto response = new BaseResponseDto();
87 89 try {
... ... @@ -95,7 +97,7 @@ public class OrderRestController {
95 97 }
96 98  
97 99 @ApiOperation("商家确认收款")
98   - @RequestMapping(value = "/seller/confirm", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  100 + @RequestMapping(value = "/sellerConfirm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
99 101 public BaseResponseDto sellerConfirm(@RequestBody @Valid SellerConfirmRequestDto request, BindingResult br) {
100 102 BaseResponseDto response = new BaseResponseDto();
101 103 try {
... ... @@ -108,7 +110,7 @@ public class OrderRestController {
108 110 return response;
109 111 }
110 112  
111   - @RequestMapping(value = "/dtms/confirm", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  113 + @RequestMapping(value = "/dtmsConfirm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
112 114 public DtmsCallBackReturn dtmsConfirm(@RequestBody @Valid DtmsConfirmRequestDto dto, BindingResult br) {
113 115 DtmsCallBackReturn response = new DtmsCallBackReturn();
114 116 try {
... ... @@ -122,7 +124,7 @@ public class OrderRestController {
122 124 }
123 125  
124 126 @ApiOperation("商家拒绝接单")
125   - @RequestMapping(value = "/seller/refuse", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  127 + @RequestMapping(value = "/refuse", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
126 128 public BaseResponseDto sellerRefuse(@RequestBody @Valid SellerRefuseRequestDto request, BindingResult br) {
127 129 BaseResponseDto response = new BaseResponseDto();
128 130 try {
... ... @@ -136,7 +138,7 @@ public class OrderRestController {
136 138 }
137 139  
138 140 @ApiOperation("买家取消订单")
139   - @RequestMapping(value = "/buyer/cancel", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  141 + @RequestMapping(value = "/cancel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
140 142 public BaseResponseDto buyerCancel(@RequestBody @Valid BuyerCancelRequestDto request, BindingResult br) {
141 143 BaseResponseDto response = new BaseResponseDto();
142 144 try {
... ... @@ -149,7 +151,7 @@ public class OrderRestController {
149 151 return response;
150 152 }
151 153  
152   - @RequestMapping(value = "/dtms/timeout", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  154 + @RequestMapping(value = "/timeout", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
153 155 public DtmsCallBackReturn dtmsTimeout(@RequestBody @Valid DtmsTimeoutRequestDto request, BindingResult br) {
154 156 DtmsCallBackReturn response = new DtmsCallBackReturn();
155 157 try {
... ... @@ -163,7 +165,7 @@ public class OrderRestController {
163 165 }
164 166  
165 167 @ApiOperation("查询订单")
166   - @RequestMapping(value = "/list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  168 + @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
167 169 public OrderListResponseDto list(@RequestBody OrderListRequestDto request) {
168 170 throw new RuntimeException("该方法还没实现");
169 171 }
... ...
b2c-orders-web/src/main/resources/spring.xml
... ... @@ -14,8 +14,8 @@
14 14 http://www.springframework.org/schema/cache/spring-cache-4.3.xsd"
15 15 default-lazy-init="true">
16 16 <context:component-scan base-package="com.b2c.orders">
17   - <context:exclude-filter type="annotation"
18   - expression="org.springframework.stereotype.Controller" />
  17 + <!-- <context:exclude-filter type="annotation"
  18 + expression="org.springframework.stereotype.Controller" /> -->
19 19 </context:component-scan>
20 20 <context:annotation-config />
21 21  
... ...
b2c-orders-web/src/main/resources/springmvc-config.xml
... ... @@ -25,6 +25,9 @@
25 25 </property>
26 26 </bean>
27 27  
  28 + <!-- Direct static mappings -->
  29 + <mvc:resources mapping="*.html" location="/" />
  30 +
28 31 <!-- mvc:annotation-driven 使用默认的 stringHttpMessageConverter,默认的编码为ISO-8859-1,因此需要替换它 -->
29 32 <mvc:annotation-driven>
30 33 <mvc:message-converters>
... ... @@ -32,7 +35,7 @@
32 35 </mvc:message-converters>
33 36 </mvc:annotation-driven>
34 37  
35   - <context:component-scan base-package="com.b2c.orders.**" />
  38 + <!-- <context:component-scan base-package="com.b2c.orders.**" /> -->
36 39  
37 40 <aop:aspectj-autoproxy proxy-target-class="true" />
38 41 <context:annotation-config />
... ...
... ... @@ -103,6 +103,16 @@
103 103 </exclusions>
104 104 </dependency>
105 105 <dependency>
  106 + <groupId>io.springfox</groupId>
  107 + <artifactId>springfox-swagger-ui</artifactId>
  108 + <version>2.2.2</version>
  109 + </dependency>
  110 + <dependency>
  111 + <groupId>io.swagger</groupId>
  112 + <artifactId>swagger-annotations</artifactId>
  113 + <version>1.5.3</version>
  114 + </dependency>
  115 + <dependency>
106 116 <groupId>com.b2c.website</groupId>
107 117 <artifactId>diligrp-website-util</artifactId>
108 118 <version>0.0.2-SNAPSHOT</version>
... ... @@ -118,6 +128,17 @@
118 128 </exclusions>
119 129 </dependency>
120 130 <dependency>
  131 + <groupId>com.fasterxml.jackson.core</groupId>
  132 + <artifactId>jackson-core</artifactId>
  133 + <version>2.8.1</version>
  134 + </dependency>
  135 +
  136 + <dependency>
  137 + <groupId>com.fasterxml.jackson.core</groupId>
  138 + <artifactId>jackson-databind</artifactId>
  139 + <version>2.8.5</version>
  140 + </dependency>
  141 + <dependency>
121 142 <groupId>com.yqyw</groupId>
122 143 <artifactId>orders-client</artifactId>
123 144 <version>${orders.client.sdk.version}</version>
... ...