Skip to content

Commit

Permalink
使用spring doc代替spring fox,openapi 3.0规范
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenWatermelon committed Feb 21, 2023
1 parent a906a9c commit 53a2d96
Show file tree
Hide file tree
Showing 98 changed files with 788 additions and 1,044 deletions.
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,21 @@ uni-app:https://gitee.com/gz-yami/mall4uni

## 技术选型

| 技术 | 版本 | 说明 |
| ---------------------- | ------ | --------------------------------------- |
| Spring Boot | 2.7.0 | MVC核心框架 |
| Spring Security oauth2 | 2.7.0 | 认证和授权框架 |
| MyBatis | 3.5.0 | ORM框架 |
| MyBatisPlus | 3.1.0 | 基于mybatis,使用lambda表达式的 |
| Swagger-UI | 2.9.2 | 文档生产工具 |
| Hibernator-Validator | 6.0.17 | 验证框架 |
| redisson | 3.10.6 | 对redis进行封装、集成分布式锁等 |
| hikari | 3.2.0 | 数据库连接池 |
| log4j2 | 2.11.2 | 更快的log日志工具 |
| fst | 2.57 | 更快的序列化和反序列化工具 |
| orika | 1.5.4 | 更快的bean复制工具 |
| lombok | 1.18.8 | 简化对象封装工具 |
| hutool | 5.7.22 | 更适合国人的java工具集 |
| knife4j | 3.0.3 | 基于swagger,更便于国人使用的swagger ui |
| 技术 | 版本 | 说明 |
|------------------------|--------|------------------------------|
| Spring Boot | 2.7.0 | MVC核心框架 |
| Spring Security oauth2 | 2.7.0 | 认证和授权框架 |
| MyBatis | 3.5.0 | ORM框架 |
| MyBatisPlus | 3.1.0 | 基于mybatis,使用lambda表达式的 |
| spring-doc | 1.6.9 | 接口文档工具 |
| Hibernator-Validator | 6.0.17 | 验证框架 |
| redisson | 3.10.6 | 对redis进行封装、集成分布式锁等 |
| hikari | 3.2.0 | 数据库连接池 |
| logback | 1.2.11 | log日志工具 |
| orika | 1.5.4 | 更快的bean复制工具 |
| lombok | 1.18.8 | 简化对象封装工具 |
| hutool | 5.7.22 | 更适合国人的java工具集 |
| knife4j | 4.0.0 | 基于swagger,更便于国人使用的swagger ui |



Expand Down
208 changes: 0 additions & 208 deletions doc/基本框架设计/Swagger文档.md

This file was deleted.

14 changes: 7 additions & 7 deletions doc/接口设计/1. 购物车的设计.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

```java
@PostMapping("/info")
@ApiOperation(value = "获取用户购物车信息", notes = "获取用户购物车信息,参数为用户选中的活动项数组,以购物车id为key")
@Operation(summary = "获取用户购物车信息" , description = "获取用户购物车信息,参数为用户选中的活动项数组,以购物车id为key")
public ResponseEntity<List<ShopCartDto>> info(@RequestBody Map<Long, ShopCartParam> basketIdShopCartParamMap) {
String userId = SecurityUtils.getUser().getUserId();

Expand Down Expand Up @@ -47,13 +47,13 @@
@Data
public class ShopCartDto implements Serializable {

@ApiModelProperty(value = "店铺ID", required = true)
@Schema(description = "店铺ID" , required = true)
private Long shopId;

@ApiModelProperty(value = "店铺名称", required = true)
@Schema(description = "店铺名称" , required = true)
private String shopName;

@ApiModelProperty(value = "购物车满减活动携带的商品", required = true)
@Schema(description = "购物车满减活动携带的商品" , required = true)
private List<ShopCartItemDiscountDto> shopCartItemDiscounts;

}
Expand All @@ -64,18 +64,18 @@ public class ShopCartDto implements Serializable {
```java
public class ShopCartItemDiscountDto implements Serializable {

@ApiModelProperty(value = "已选满减项", required = true)
@Schema(description = "已选满减项" , required = true)
private ChooseDiscountItemDto chooseDiscountItemDto;

@ApiModelProperty(value = "商品列表")
@Schema(description = "商品列表" )
private List<ShopCartItemDto> shopCartItems;
}
```

我们再留意`ShopCartItemDto` 这个`bean` ,发现还有这个东西:

```java
@ApiModelProperty("参与满减活动列表")
@Schema(description = "参与满减活动列表" )
private List<DiscountDto> discounts = new ArrayList<>();
```

Expand Down
30 changes: 15 additions & 15 deletions doc/接口设计/2. 订单设计-确认订单.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

```java
public class OrderParam {
@ApiModelProperty(value = "购物车id 数组")
@Schema(description = "购物车id 数组" )
private List<Long> basketIds;

@ApiModelProperty(value = "立即购买时提交的商品项")
@Schema(description = "立即购买时提交的商品项" )
private OrderItemParam orderItem;
}
```
Expand All @@ -38,7 +38,7 @@ public class OrderParam {

```java
@PostMapping("/confirm")
@ApiOperation(value = "结算,生成订单信息", notes = "传入下单所需要的参数进行下单")
@Operation(summary = "结算,生成订单信息" , description = "传入下单所需要的参数进行下单")
public ResponseEntity<ShopCartOrderMergerDto> confirm(@Valid @RequestBody OrderParam orderParam) {
// 根据店铺组装购车中的商品信息,返回每个店铺中的购物车商品信息
List<ShopCartDto> shopCarts = basketService.getShopCarts(shopCartItems);
Expand All @@ -61,14 +61,14 @@ public class OrderParam {

```java
public class OrderParam {
@ApiModelProperty(value = "地址ID,0为默认地址",required=true)
@Schema(description = "地址ID,0为默认地址" ,required=true)
@NotNull(message = "地址不能为空")
private Long addrId;

@ApiModelProperty(value = "用户是否改变了优惠券的选择,如果用户改变了优惠券的选择,则完全根据传入参数进行优惠券的选择")
@Schema(description = "用户是否改变了优惠券的选择,如果用户改变了优惠券的选择,则完全根据传入参数进行优惠券的选择" )
private Integer userChangeCoupon;

@ApiModelProperty(value = "优惠券id数组")
@Schema(description = "优惠券id数组" )
private List<Long> couponIds;
}
```
Expand All @@ -81,7 +81,7 @@ public class OrderParam {

```java
@PostMapping("/confirm")
@ApiOperation(value = "结算,生成订单信息", notes = "传入下单所需要的参数进行下单")
@Operation(summary = "结算,生成订单信息" , description = "传入下单所需要的参数进行下单")
public ResponseEntity<ShopCartOrderMergerDto> confirm(@Valid @RequestBody OrderParam orderParam) {
for (ShopCartDto shopCart : shopCarts) {
applicationContext.publishEvent(new ConfirmOrderEvent(shopCartOrder,orderParam,shopAllShopCartItems));
Expand Down Expand Up @@ -167,25 +167,25 @@ public class ConfirmOrderListener {
@Data
public class ShopCartOrderMergerDto implements Serializable{

@ApiModelProperty(value = "实际总值", required = true)
@Schema(description = "实际总值" , required = true)
private Double actualTotal;

@ApiModelProperty(value = "商品总值", required = true)
@Schema(description = "商品总值" , required = true)
private Double total;

@ApiModelProperty(value = "商品总数", required = true)
@Schema(description = "商品总数" , required = true)
private Integer totalCount;

@ApiModelProperty(value = "订单优惠金额(所有店铺优惠金额相加)", required = true)
@Schema(description = "订单优惠金额(所有店铺优惠金额相加)" , required = true)
private Double orderReduce;

@ApiModelProperty(value = "地址Dto", required = true)
@Schema(description = "地址Dto" , required = true)
private UserAddrDto userAddr;

@ApiModelProperty(value = "每个店铺的购物车信息", required = true)
@Schema(description = "每个店铺的购物车信息" , required = true)
private List<ShopCartOrderDto> shopCartOrders;

@ApiModelProperty(value = "整个订单可以使用的优惠券列表", required = true)
@Schema(description = "整个订单可以使用的优惠券列表" , required = true)
private List<CouponOrderDto> coupons;
}

Expand All @@ -194,7 +194,7 @@ public class ShopCartOrderMergerDto implements Serializable{
这里又有一段我们熟悉的代码:

```java
@ApiModelProperty(value = "每个店铺的购物车信息", required = true)
@Schema(description = "每个店铺的购物车信息" , required = true)
private List<ShopCartOrderDto> shopCartOrders;
```
没错这里返回的数据格式,和购物车的格式是一样的,因为第一步当中已经说明,订单来自于购物车的计算,所以会在基础上条件新的数据,基本上就是返回给前端的数据了。
Loading

0 comments on commit 53a2d96

Please sign in to comment.