From 9fb182e21a7ed794bec6e85a934c5237de1d9d69 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 5 Dec 2020 23:13:39 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E8=AE=BF=E9=97=AE=E4=BB=A4=E7=89=8C?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=20Redis=20=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E7=BC=93=E5=AD=98=202.=20=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=20order=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../biz/bo/OrderLastLogisticsInfoBO.java | 85 --------- .../mall/order/biz/bo/OrderLogisticsBO.java | 41 ----- .../order/biz/bo/OrderLogisticsInfoBO.java | 82 --------- .../biz/bo/OrderLogisticsInfoWithOrderBO.java | 100 ----------- .../mall/order/biz/bo/OrderReturnInfoBO.java | 141 --------------- .../mall/order/biz/bo/OrderReturnListBO.java | 122 ------------- .../order/biz/bo/comment/OrderCommentBO.java | 86 ---------- .../biz/bo/comment/OrderCommentCreateBO.java | 25 --- .../OrderCommentInfoAndMerchantReplyBO.java | 29 ---- .../biz/bo/comment/OrderCommentInfoBO.java | 84 --------- .../comment/OrderCommentMerchantReplyBO.java | 21 --- .../biz/bo/comment/OrderCommentPageBO.java | 159 ----------------- .../bo/comment/OrderCommentReplyCreateBO.java | 24 --- .../bo/comment/OrderCommentReplyPageBO.java | 83 --------- .../comment/OrderCommentStateInfoPageBO.java | 87 ---------- .../biz/bo/comment/OrderCommentTimeOutBO.java | 25 --- .../bo/order/OrderLastLogisticsInfoBO.java | 85 --------- .../order/biz/bo/order/OrderLogisticsBO.java | 41 ----- .../biz/bo/order/OrderLogisticsInfoBO.java | 82 --------- .../order/OrderLogisticsInfoWithOrderBO.java | 100 ----------- .../order/biz/bo/order/OrderReturnInfoBO.java | 141 --------------- .../order/biz/bo/order/OrderReturnListBO.java | 122 ------------- .../order/UsersOrderController.java | 30 ---- moved/product/pom.xml | 35 ---- .../product/biz/bo/attr/ProductAttrBO.java | 30 ---- .../biz/bo/attr/ProductAttrSimpleBO.java | 25 --- moved/product/product-start/pom.xml | 106 ------------ .../user/UserAddressController.http | 1 + system-service-project/pom.xml | 1 + .../config/SystemBizProperties.java | 30 ++++ .../convert/oauth/OAuth2Convert.java | 5 +- .../mapper/oauth/OAuth2AccessTokenMapper.java | 11 ++ .../dal/redis/RedisKeyConstants.java | 24 +++ .../redis/dao/OAuth2AccessTokenRedisDAO.java | 36 ++++ .../manager/admin/AdminManager.java | 7 +- .../manager/oauth/OAuth2Manager.java | 47 ----- .../rpc/oauth/OAuth2RpcImpl.java | 18 +- .../service/oauth/OAuth2Service.java | 117 ++----------- .../service/oauth/OAuth2ServiceImpl.java | 161 ++++++++++++++++++ .../service/oauth/bo/OAuth2AccessTokenBO.java | 36 ---- .../src/main/resources/application.properties | 4 - .../src/main/resources/application.yaml | 7 +- .../system-service-integration-test}/pom.xml | 23 +-- .../service/oauth/OAuth2ServiceImplTest.java | 21 +++ .../systemservice/service/package-info.java | 1 + .../config/TradeBizProperties.java | 3 + 47 files changed, 326 insertions(+), 2220 deletions(-) delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLastLogisticsInfoBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsInfoBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsInfoWithOrderBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderReturnInfoBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderReturnListBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentCreateBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentInfoAndMerchantReplyBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentInfoBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentMerchantReplyBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentPageBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentReplyCreateBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentReplyPageBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentStateInfoPageBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentTimeOutBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLastLogisticsInfoBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsInfoBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsInfoWithOrderBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderReturnInfoBO.java delete mode 100644 moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderReturnListBO.java delete mode 100644 moved/product/pom.xml delete mode 100644 moved/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrBO.java delete mode 100644 moved/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrSimpleBO.java delete mode 100644 moved/product/product-start/pom.xml create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/config/SystemBizProperties.java create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/redis/RedisKeyConstants.java create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/redis/dao/OAuth2AccessTokenRedisDAO.java delete mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/oauth/OAuth2Manager.java create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2ServiceImpl.java delete mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/bo/OAuth2AccessTokenBO.java delete mode 100644 system-service-project/system-service-app/src/main/resources/application.properties rename {moved/product/product-service-api => system-service-project/system-service-integration-test}/pom.xml (50%) create mode 100644 system-service-project/system-service-integration-test/src/test/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2ServiceImplTest.java create mode 100644 system-service-project/system-service-integration-test/src/test/java/cn/iocoder/mall/systemservice/service/package-info.java diff --git a/README.md b/README.md index 00367906..4c950c43 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ TODO 此处应有一个架构图的装逼 JPG 图。 | `pay-service-project` | 支付 RPC 服务 | 随机 | | | `trade-service-project` | 交易 RPC 服务 | 随机 | | | `product-service-project` | 商品 RPC 服务 | 随机 | | -| `search-service-project` | 搜索å RPC 服务 | 随机 | | +| `search-service-project` | 搜索 RPC 服务 | 随机 | | ------- diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLastLogisticsInfoBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLastLogisticsInfoBO.java deleted file mode 100644 index 81421a26..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLastLogisticsInfoBO.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.mall.order.biz.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 订单物流 - 最后一个物流信息 - * - * @author Sin - * @time 2019-04-12 22:03 - */ -@Data -@Accessors(chain = true) -public class OrderLastLogisticsInfoBO implements Serializable { - - /** - * id - */ - private Integer id; - /** - * 收件区域编号 - */ - private String areaNo; - /** - * 收件人名称 - */ - private String name; - /** - * 收件手机号 - */ - private String mobile; - /** - * 收件详细地址 - */ - private String address; - /** - * 物流 (字典) - */ - private Integer logistics; - /** - * 物流 (字典) 转换后的值 - */ - private String logisticsText; - /** - * 物流编号 - */ - private String logisticsNo; - - /// - /// 物流信息 - - /** - * 最后一个物流信息 - */ - private LogisticsDetail lastLogisticsDetail; - - @Data - @Accessors(chain = true) - public static class LogisticsDetail { - /** - * id - */ - private Integer id; - /** - * 物流id - */ - private Integer orderLogisticsId; - /** - * 物流时间 - */ - private Date logisticsTime; - /** - * 物流时间 text - */ - private String logisticsTimeText; - /** - * 物流信息 - */ - private String logisticsInformation; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsBO.java deleted file mode 100644 index f9f06307..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsBO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.mall.order.biz.bo; - -import cn.iocoder.mall.mybatis.core.dataobject.BaseDO; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 订单物流信息 - * - * @author Sin - * @time 2019-03-19 20:47 - */ -@Data -@Accessors(chain = true) -public class OrderLogisticsBO extends BaseDO { - - /** - * id - */ - private Integer id; - /** - * 收件区域编号 - */ - private String areaNo; - /** - * 收件人名称 - */ - private String name; - /** - * 收件手机号 - */ - private String mobile; - /** - * 收件详细地址 - */ - private String address; - /** - * 物流编号 - */ - private String logisticsNo; -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsInfoBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsInfoBO.java deleted file mode 100644 index 8fc2c5b7..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsInfoBO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.mall.order.biz.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 订单物流 - 详细信息 - * - * @author Sin - * @time 2019-04-12 22:03 - */ -@Data -@Accessors(chain = true) -public class OrderLogisticsInfoBO implements Serializable { - - /** - * id - */ - private Integer id; - /** - * 收件区域编号 - */ - private String areaNo; - /** - * 收件人名称 - */ - private String name; - /** - * 收件手机号 - */ - private String mobile; - /** - * 收件详细地址 - */ - private String address; - /** - * 物流 (字典) - */ - private Integer logistics; - /** - * 物流 (字典) 转换后的值 - */ - private String logisticsText; - /** - * 物流编号 - */ - private String logisticsNo; - - /// - /// 物流信息 - - private List details; - - @Data - @Accessors(chain = true) - public static class LogisticsDetail { - /** - * id - */ - private Integer id; - /** - * 物流id - */ - private Integer orderLogisticsId; - /** - * 物流时间 - */ - private Date logisticsTime; - /** - * 物流时间 text - */ - private String logisticsTimeText; - /** - * 物流信息 - */ - private String logisticsInformation; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsInfoWithOrderBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsInfoWithOrderBO.java deleted file mode 100644 index 0d8d537f..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderLogisticsInfoWithOrderBO.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.mall.order.biz.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 订单物流 - 详细信息 - * - * @author Sin - * @time 2019-04-12 22:03 - */ -@Data -@Accessors(chain = true) -public class OrderLogisticsInfoWithOrderBO implements Serializable { - - /** - * 订单id - */ - private Integer orderId; - /** - * 订单编号 - */ - private String orderNo; - /** - * 物流信息 - */ - private List logistics; - - @Data - @Accessors(chain = true) - public static class Logistics { - - /** - * id - */ - private Integer id; - /** - * 收件区域编号 - */ - private String areaNo; - /** - * 收件人名称 - */ - private String name; - /** - * 收件手机号 - */ - private String mobile; - /** - * 收件详细地址 - */ - private String address; - /** - * 物流 (字典) - */ - private Integer logistics; - /** - * 物流 (字典) 转换后的值 - */ - private String logisticsText; - /** - * 物流编号 - */ - private String logisticsNo; - - /// - /// 物流信息 - - private List details; - } - - @Data - @Accessors(chain = true) - public static class LogisticsDetail { - /** - * id - */ - private Integer id; - /** - * 物流id - */ - private Integer orderLogisticsId; - /** - * 物流时间 - */ - private Date logisticsTime; - /** - * 物流时间 text - */ - private String logisticsTimeText; - /** - * 物流信息 - */ - private String logisticsInformation; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderReturnInfoBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderReturnInfoBO.java deleted file mode 100644 index 5d7f3887..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderReturnInfoBO.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.mall.order.biz.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 订单退货 info - * - * @author Sin - * @time 2019-04-27 10:19 - */ -@Data -@Accessors(chain = true) -public class OrderReturnInfoBO implements Serializable { - - /** - * 退货信息 - */ - private ReturnInfo returnInfo; - /** - * 订单 item - */ - private List orderItems; - /** - * 最后一个物流信息/最新物流信息 - */ - private OrderLastLogisticsInfoBO lastLogisticsInfo; - - @Data - @Accessors(chain = true) - public static class OrderItem { - - /** - * 商品编号 - */ - private Integer skuId; - /** - * 商品名称 - */ - private String skuName; - /** - * 商品图片 - */ - private String skuImage; - /** - * 数量 - */ - private Integer quantity; - /** - * 最终总金额,单位:分。 - */ - private Integer presentTotal; - } - - @Data - @Accessors(chain = true) - public static class ReturnInfo { - - /** - * 编号自动增长 - */ - private Integer id; - /** - * 服务号 - */ - private String serviceNumber; - /** - * 订单编号 - */ - private Integer orderId; - /** - * 订单号 (保存一个冗余) - */ - private String orderNo; - /** - * 物流id - */ - private Integer orderLogisticsId; - - /// - /// 退货原因 - - /** - * 退货金额 - */ - private Integer refundPrice; - /** - * 退货原因(字典值) - */ - private Integer reason; - /** - * 问题描述 - */ - private String describe; - - /// - /// 时间信息 - - /** - * 同意时间 - */ - private Date approvalTime; - /** - * 物流时间(填写物流单号时间) - */ - private Date logisticsTime; - /** - * 收货时间 - */ - private Date receiverTime; - /** - * 成交时间(确认时间) - */ - private Date closingTime; - /** - * 退款类型 - * - * - 1、退货退款 - * - 2、退款 - */ - private Integer serviceType; - /** - * 退款类型 转换值 - */ - private String serviceTypeText; - /** - * 状态 - * - * - 1、退货申请 - * - 2、申请成功 - * - 3、申请失败 - * - 4、退货中 - * - 5、退货成功 - */ - private Integer status; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderReturnListBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderReturnListBO.java deleted file mode 100644 index c5c71349..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/OrderReturnListBO.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.mall.order.biz.bo; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 订单退货 list - * - * @author Sin - * @time 2019-05-06 21:54 - */ -@Data -@Accessors(chain = true) -public class OrderReturnListBO implements Serializable { - - /** - * 分页当前 index - */ - private Integer index; - /** - * pageSize - */ - private Integer pageSize; - /** - * totalCount - */ - private Integer totalCount; - /** - * data - */ - private List data; - - @Data - @Accessors(chain = true) - public static class OrderReturn { - - /** - * 编号自动增长 - */ - private Integer id; - /** - * 服务号 - */ - private String serviceNumber; - /** - * 订单编号 - */ - private Integer orderId; - /** - * 订单号 (保存一个冗余) - */ - private String orderNo; - /** - * 物流id - */ - private Integer orderLogisticsId; - - /// - /// 退货原因 - - /** - * 退货金额 - */ - private Integer refundPrice; - /** - * 退货原因(字典值) - */ - private Integer reason; - /** - * 问题描述 - */ - private String describe; - - /// - /// 时间信息 - - /** - * 同意时间 - */ - private Date approvalTime; - /** - * 物流时间(填写物流单号时间) - */ - private Date logisticsTime; - /** - * 收货时间 - */ - private Date receiverTime; - /** - * 成交时间(确认时间) - */ - private Date closingTime; - /** - * 服务类型 - * - * - 1、退货退款 - * - 2、退款 - */ - private Integer serviceType; - /** - * 状态 - * - * - 1、退货申请 - * - 2、申请成功 - * - 3、申请失败 - * - 4、退货中 - * - 5、退货成功 - */ - private Integer status; - /** - * 创建时间 - */ - private Date createTime; - /** - * 更新时间 - */ - private Date updateTime; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentBO.java deleted file mode 100644 index 55cd1de1..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentBO.java +++ /dev/null @@ -1,86 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; - -/** - * - * 订单评价 - * - * @author wtz - * @time 2019-05-14 20:00:00 - */ -@Data -@Accessors(chain = true) -public class OrderCommentBO implements Serializable { - - /** - * 总条数 - */ - private Integer total; - - /** - * 好评 - */ - private Integer positiveTotal; - - /** - * 中评 - */ - private Integer moderateTotal; - - /** - * 差评 - */ - private Integer negativeTotal; - - /** - * 评论 id - */ - private Integer id; - - /** - * 用户头像 - */ - private String userAvatar; - - /** - * 用户的真实姓名 - */ - private String userNickName; - - /** - * 评价星 - */ - private Integer star; - - /** - * 评论的内容 - */ - private String commentContent; - - /** - * 评论的图片地址 - */ - private String commentPics; - - /** - * 回复条数 - */ - private Integer replayCount; - - /** - * 点赞数 - */ - private Integer collectCount; - - /** - * 创建时间 - */ - private Date createTime; - - -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentCreateBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentCreateBO.java deleted file mode 100644 index dd354b46..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentCreateBO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * - * 订单评论创建 - * - * @author wtz - * @time 2019-05-19 18:32 - * - */ -@Data -@Accessors(chain = true) -public class OrderCommentCreateBO implements Serializable { - - /** - * 订单评论 id - */ - private Integer id; - -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentInfoAndMerchantReplyBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentInfoAndMerchantReplyBO.java deleted file mode 100644 index cbe7a996..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentInfoAndMerchantReplyBO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -/** - * - * 评论详情和商家评论回复 - * - * @author wtz - * @time 2019-06-03 20:30 - */ -@Data -@Accessors(chain = true) -public class OrderCommentInfoAndMerchantReplyBO { - - /** - * 评论详情 - */ - private OrderCommentInfoBO orderCommentInfoBO; - - /** - * 商家评论回复 - */ - private List orderCommentMerchantReplyBOS; - -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentInfoBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentInfoBO.java deleted file mode 100644 index f227e530..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentInfoBO.java +++ /dev/null @@ -1,84 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; - -/** - * - * 订单回复评价详情 - * - * @author wtz - * @time 2019-05-16 18:40 - * - */ -@Data -@Accessors(chain = true) -public class OrderCommentInfoBO implements Serializable { - - /** - * 评论 id - */ - private Integer id; - - /** - * 用户头像 - */ - private String userAvatar; - - /** - * 用户昵称 - */ - private String userNickName; - - /** - * 评价星 - */ - private Integer star; - - /** - * 评论的内容 - */ - private String commentContent; - - /** - * 评论的图片地址 - */ - private String commentPics; - - - /** - * 点赞数 - */ - private Integer likeCount; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 商品 sku id - */ - private int productSkuId; - - /** - * 商品 sku 属性 - */ - private String productSkuAttrs; - - /** - * 商品 sku 价格 - */ - private String productSkuPrice; - - /** - * 商品 sku 地址 - */ - private String productSkuPicUrl; - - -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentMerchantReplyBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentMerchantReplyBO.java deleted file mode 100644 index 31444cf4..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentMerchantReplyBO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * - * 商家评论回复 - * - * @author wtz - * @time 2019-06-03 19:30 - */ -@Data -@Accessors(chain = true) -public class OrderCommentMerchantReplyBO { - - /** - * 商家评论回复 - */ - private String replyContent; -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentPageBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentPageBO.java deleted file mode 100644 index 286db0f9..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentPageBO.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - - -/** - * - * 订单评论分页展示 - * - * @author wtz - * @time 2019-05-14 20:00:00 - */ -@Data -@Accessors(chain = true) -public class OrderCommentPageBO implements Serializable { - - /** - * 总条数 - */ - private Integer total; - -// 评论标签化等等在做 -// /** -// * 好评 -// */ -// private Integer positiveTotal; -// -// /** -// * 中评 -// */ -// private Integer moderateTotal; -// -// /** -// * 差评 -// */ -// private Integer negativeTotal; - -// /** -// * 评论列表 -// */ -// private List orderCommentItems; - - /** - * 评论 id - */ - private Integer id; - - /** - * 用户头像 - */ - private String userAvatar; - - /** - * 用户的真实姓名 - */ - private String userNickName; - - /** - * 评价星 - */ - private Integer star; - - /** - * 评论的内容 - */ - private String commentContent; - - /** - * 评论的图片地址 - */ - private String commentPics; - - /** - * 回复条数 - */ - private Integer replayCount; - - /** - * 点赞数 - */ - private Integer likeCount; - - /** - * 创建时间 - */ - private Date createTime; - - /** - * 商家回复列表 - * 只展示最近的一条 - */ - private String replyContent; - - - - @Data - @Accessors(chain = true) - @AllArgsConstructor - public static class OrderCommentItem{ -// /** -// * 评论 id -// */ -// private Integer id; -// -// /** -// * 用户头像 -// */ -// private String userAvatar; -// -// /** -// * 用户的真实姓名 -// */ -// private String userNickName; -// -// /** -// * 评价星 -// */ -// private Integer star; -// -// /** -// * 评论的内容 -// */ -// private String commentContent; -// -// /** -// * 评论的图片地址 -// */ -// private String commentPics; -// -// /** -// * 回复条数 -// */ -// private Integer replayCount; -// -// /** -// * 点赞数 -// */ -// private Integer likeCount; -// -// /** -// * 创建时间 -// */ -// private Date createTime; -// -// /** -// * 商家回复列表 -// * 只展示最近的一条 -// */ -// private String replyContent; - - } - -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentReplyCreateBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentReplyCreateBO.java deleted file mode 100644 index dcfe860a..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentReplyCreateBO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * - * 订单回复创建 - * - * @author wtz - * @time 2019-05-19 18:35 - */ -@Data -@Accessors(chain = true) -public class OrderCommentReplyCreateBO implements Serializable { - - - /** - * 评论回复 id - */ - private Integer id; -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentReplyPageBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentReplyPageBO.java deleted file mode 100644 index 3415c8ca..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentReplyPageBO.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * - * 评论回复分页展示 - * - * @author wtz - * @time 2019-05-19 14:19 - * - */ -@Data -@Accessors(chain = true) -public class OrderCommentReplyPageBO implements Serializable { - - /** - * 评论回复总数 - */ - private Integer total; - - /** - * 用户回复 - */ - List orderCommentReplayItems; - - - @Data - @Accessors(chain = true) - public static class OrderCommentReplayItem{ - /** - * 回复 id - */ - private Integer id; - - /** - * 回复的类型 - */ - private Integer replyType; - - /** - * 回复的内容 - */ - private String replyContent; - - /** - * 回复的用户 id - */ - private int replyUserId; - - /** - * 回复用户的真实姓名 - */ - private String replyUserNickName; - - /** - * 回复用户的头像 - */ - private String replyUserAvatar; - - /** - * 回复的点赞数 - */ - private int replyCollectCount; - - /** - * 回复目标用户昵称 - */ - private String parentUserNickName; - - /** - * 创建时间 - */ - private Date createTime; - - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentStateInfoPageBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentStateInfoPageBO.java deleted file mode 100644 index 894a2a23..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentStateInfoPageBO.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * - * 订单评论状态详情分页(这么设计因为这个接口需要登陆以后才能看到所以与订单分页接口分开) - * - * @author wtz - * @time 2019-06-07 10:39 - */ -@Data -@Accessors(chain = true) -public class OrderCommentStateInfoPageBO implements Serializable { - - /** - * (待/已)评论总数 - */ - private Integer total; - - /** - * 评论状态 - */ - private List orderCommentStateInfoItems; - - @Data - @Accessors(chain = true) - public static class OrderCommentStateInfoItem{ - - /** - * 订单 id - */ - private Integer orderId; - - /** - * 订单编号 - */ - private String orderNo; - - /** - * 商品 id - */ - private Integer productSpuId; - - /** - * 商品名称 - */ - private String productSpuName; - - /** - * 商品 sku id - */ - private Integer productSkuId; - - /** - * 商品 sku 属性 - */ - private String productSkuAttrs; - - /** - * 商品 sku 价格 - */ - private Integer productSkuPrice; - - /** - * 商品 sku url - */ - private String productSkuPicUrl; - - /** - * 订单评论状态 - */ - private Integer commentState; - - /** - * 创建时间 - */ - private Date createTime; - } - - -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentTimeOutBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentTimeOutBO.java deleted file mode 100644 index d5728f7c..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/comment/OrderCommentTimeOutBO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.comment; - -import lombok.Data; -import lombok.experimental.Accessors; -import org.springframework.beans.factory.annotation.Autowired; - -import java.io.Serializable; - - -/** - * 订单评论超时 - * - * @author wtz - * @time 2019-06-15 13:52 - */ -@Data -@Accessors(chain = true) -public class OrderCommentTimeOutBO implements Serializable { - - /** - * 评论 id - */ - private Integer id; - -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLastLogisticsInfoBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLastLogisticsInfoBO.java deleted file mode 100644 index daa9d26a..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLastLogisticsInfoBO.java +++ /dev/null @@ -1,85 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.order; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 订单物流 - 最后一个物流信息 - * - * @author Sin - * @time 2019-04-12 22:03 - */ -@Data -@Accessors(chain = true) -public class OrderLastLogisticsInfoBO implements Serializable { - - /** - * id - */ - private Integer id; - /** - * 收件区域编号 - */ - private String areaNo; - /** - * 收件人名称 - */ - private String name; - /** - * 收件手机号 - */ - private String mobile; - /** - * 收件详细地址 - */ - private String address; - /** - * 物流 (字典) - */ - private Integer logistics; - /** - * 物流 (字典) 转换后的值 - */ - private String logisticsText; - /** - * 物流编号 - */ - private String logisticsNo; - - /// - /// 物流信息 - - /** - * 最后一个物流信息 - */ - private LogisticsDetail lastLogisticsDetail; - - @Data - @Accessors(chain = true) - public static class LogisticsDetail { - /** - * id - */ - private Integer id; - /** - * 物流id - */ - private Integer orderLogisticsId; - /** - * 物流时间 - */ - private Date logisticsTime; - /** - * 物流时间 text - */ - private String logisticsTimeText; - /** - * 物流信息 - */ - private String logisticsInformation; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsBO.java deleted file mode 100644 index 96e92684..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsBO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.order; - -import cn.iocoder.mall.mybatis.core.dataobject.BaseDO; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 订单物流信息 - * - * @author Sin - * @time 2019-03-19 20:47 - */ -@Data -@Accessors(chain = true) -public class OrderLogisticsBO extends BaseDO { - - /** - * id - */ - private Integer id; - /** - * 收件区域编号 - */ - private String areaNo; - /** - * 收件人名称 - */ - private String name; - /** - * 收件手机号 - */ - private String mobile; - /** - * 收件详细地址 - */ - private String address; - /** - * 物流编号 - */ - private String logisticsNo; -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsInfoBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsInfoBO.java deleted file mode 100644 index f87296db..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsInfoBO.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.order; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 订单物流 - 详细信息 - * - * @author Sin - * @time 2019-04-12 22:03 - */ -@Data -@Accessors(chain = true) -public class OrderLogisticsInfoBO implements Serializable { - - /** - * id - */ - private Integer id; - /** - * 收件区域编号 - */ - private String areaNo; - /** - * 收件人名称 - */ - private String name; - /** - * 收件手机号 - */ - private String mobile; - /** - * 收件详细地址 - */ - private String address; - /** - * 物流 (字典) - */ - private Integer logistics; - /** - * 物流 (字典) 转换后的值 - */ - private String logisticsText; - /** - * 物流编号 - */ - private String logisticsNo; - - /// - /// 物流信息 - - private List details; - - @Data - @Accessors(chain = true) - public static class LogisticsDetail { - /** - * id - */ - private Integer id; - /** - * 物流id - */ - private Integer orderLogisticsId; - /** - * 物流时间 - */ - private Date logisticsTime; - /** - * 物流时间 text - */ - private String logisticsTimeText; - /** - * 物流信息 - */ - private String logisticsInformation; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsInfoWithOrderBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsInfoWithOrderBO.java deleted file mode 100644 index d09578fd..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderLogisticsInfoWithOrderBO.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.order; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 订单物流 - 详细信息 - * - * @author Sin - * @time 2019-04-12 22:03 - */ -@Data -@Accessors(chain = true) -public class OrderLogisticsInfoWithOrderBO implements Serializable { - - /** - * 订单id - */ - private Integer orderId; - /** - * 订单编号 - */ - private String orderNo; - /** - * 物流信息 - */ - private List logistics; - - @Data - @Accessors(chain = true) - public static class Logistics { - - /** - * id - */ - private Integer id; - /** - * 收件区域编号 - */ - private String areaNo; - /** - * 收件人名称 - */ - private String name; - /** - * 收件手机号 - */ - private String mobile; - /** - * 收件详细地址 - */ - private String address; - /** - * 物流 (字典) - */ - private Integer logistics; - /** - * 物流 (字典) 转换后的值 - */ - private String logisticsText; - /** - * 物流编号 - */ - private String logisticsNo; - - /// - /// 物流信息 - - private List details; - } - - @Data - @Accessors(chain = true) - public static class LogisticsDetail { - /** - * id - */ - private Integer id; - /** - * 物流id - */ - private Integer orderLogisticsId; - /** - * 物流时间 - */ - private Date logisticsTime; - /** - * 物流时间 text - */ - private String logisticsTimeText; - /** - * 物流信息 - */ - private String logisticsInformation; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderReturnInfoBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderReturnInfoBO.java deleted file mode 100644 index 5ae3d316..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderReturnInfoBO.java +++ /dev/null @@ -1,141 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.order; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * 订单退货 info - * - * @author Sin - * @time 2019-04-27 10:19 - */ -@Data -@Accessors(chain = true) -public class OrderReturnInfoBO implements Serializable { - - /** - * 退货信息 - */ - private ReturnInfo returnInfo; - /** - * 订单 item - */ - private List orderItems; - /** - * 最后一个物流信息/最新物流信息 - */ - private OrderLastLogisticsInfoBO lastLogisticsInfo; - - @Data - @Accessors(chain = true) - public static class OrderItem { - - /** - * 商品编号 - */ - private Integer skuId; - /** - * 商品名称 - */ - private String skuName; - /** - * 商品图片 - */ - private String skuImage; - /** - * 数量 - */ - private Integer quantity; - /** - * 最终总金额,单位:分。 - */ - private Integer presentTotal; - } - - @Data - @Accessors(chain = true) - public static class ReturnInfo { - - /** - * 编号自动增长 - */ - private Integer id; - /** - * 服务号 - */ - private String serviceNumber; - /** - * 订单编号 - */ - private Integer orderId; - /** - * 订单号 (保存一个冗余) - */ - private String orderNo; - /** - * 物流id - */ - private Integer orderLogisticsId; - - /// - /// 退货原因 - - /** - * 退货金额 - */ - private Integer refundPrice; - /** - * 退货原因(字典值) - */ - private Integer reason; - /** - * 问题描述 - */ - private String describe; - - /// - /// 时间信息 - - /** - * 同意时间 - */ - private Date approvalTime; - /** - * 物流时间(填写物流单号时间) - */ - private Date logisticsTime; - /** - * 收货时间 - */ - private Date receiverTime; - /** - * 成交时间(确认时间) - */ - private Date closingTime; - /** - * 退款类型 - * - * - 1、退货退款 - * - 2、退款 - */ - private Integer serviceType; - /** - * 退款类型 转换值 - */ - private String serviceTypeText; - /** - * 状态 - * - * - 1、退货申请 - * - 2、申请成功 - * - 3、申请失败 - * - 4、退货中 - * - 5、退货成功 - */ - private Integer status; - } -} diff --git a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderReturnListBO.java b/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderReturnListBO.java deleted file mode 100644 index e5ce9ead..00000000 --- a/moved/order/order-biz/src/main/java/cn/iocoder/mall/order/biz/bo/order/OrderReturnListBO.java +++ /dev/null @@ -1,122 +0,0 @@ -package cn.iocoder.mall.order.biz.bo.order; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 订单退货 list - * - * @author Sin - * @time 2019-05-06 21:54 - */ -@Data -@Accessors(chain = true) -public class OrderReturnListBO implements Serializable { - - /** - * 分页当前 index - */ - private Integer index; - /** - * pageSize - */ - private Integer pageSize; - /** - * totalCount - */ - private Integer totalCount; - /** - * data - */ - private List data; - - @Data - @Accessors(chain = true) - public static class OrderReturn { - - /** - * 编号自动增长 - */ - private Integer id; - /** - * 服务号 - */ - private String serviceNumber; - /** - * 订单编号 - */ - private Integer orderId; - /** - * 订单号 (保存一个冗余) - */ - private String orderNo; - /** - * 物流id - */ - private Integer orderLogisticsId; - - /// - /// 退货原因 - - /** - * 退货金额 - */ - private Integer refundPrice; - /** - * 退货原因(字典值) - */ - private Integer reason; - /** - * 问题描述 - */ - private String describe; - - /// - /// 时间信息 - - /** - * 同意时间 - */ - private Date approvalTime; - /** - * 物流时间(填写物流单号时间) - */ - private Date logisticsTime; - /** - * 收货时间 - */ - private Date receiverTime; - /** - * 成交时间(确认时间) - */ - private Date closingTime; - /** - * 服务类型 - * - * - 1、退货退款 - * - 2、退款 - */ - private Integer serviceType; - /** - * 状态 - * - * - 1、退货申请 - * - 2、申请成功 - * - 3、申请失败 - * - 4、退货中 - * - 5、退货成功 - */ - private Integer status; - /** - * 创建时间 - */ - private Date createTime; - /** - * 更新时间 - */ - private Date updateTime; - } -} diff --git a/moved/order/order-rest/src/main/java/cn/iocoder/mall/order/rest/controller/order/UsersOrderController.java b/moved/order/order-rest/src/main/java/cn/iocoder/mall/order/rest/controller/order/UsersOrderController.java index ca3ce2e1..00983824 100644 --- a/moved/order/order-rest/src/main/java/cn/iocoder/mall/order/rest/controller/order/UsersOrderController.java +++ b/moved/order/order-rest/src/main/java/cn/iocoder/mall/order/rest/controller/order/UsersOrderController.java @@ -16,36 +16,6 @@ import org.springframework.web.bind.annotation.RestController; @Api(description = "用户订单") // TODO FROM 芋艿 to 小范,description 已经废弃啦 public class UsersOrderController { - -// @PostMapping("create_order_from_cart") -// @RequiresLogin -// @ApiOperation("创建订单购物车") -// public CommonResult createOrderFromCart(@RequestParam("userAddressId") Integer userAddressId, -// @RequestParam(value = "couponCardId", required = false) Integer couponCardId, -// @RequestParam(value = "remark", required = false) String remark, -// HttpServletRequest request) { -// Integer userId = UserSecurityContextHolder.getContext().getUserId(); -// // 获得购物车中选中的商品 -// List cartItems = cartService.list(userId, true); -// if (cartItems.isEmpty()) { -// return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_CREATE_CART_IS_EMPTY.getCode()); -// } -// // 创建 OrderCreateDTO 对象 -// OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.createOrderCreateDTO(userId, userAddressId, -// remark, HttpUtil.getIp(request), -// cartItems, couponCardId); -// // 创建订单 -// CommonResult createResult = orderService.createOrder(orderCreateDTO); -// if (createResult.isError()) { -// return CommonResult.error(createResult); -// } -// // 清空购物车 // TODO 芋艿,需要标记删除的原因,即结果为创建为某个订单。 -// cartService.deleteList(userId, cartItems.stream().map(CartItemBO::getSkuId).collect(Collectors.toList())); -// // 返回结果 -// return createResult; -// } -// - // // @PostMapping("confirm_receiving") // @RequiresLogin diff --git a/moved/product/pom.xml b/moved/product/pom.xml deleted file mode 100644 index 4926a772..00000000 --- a/moved/product/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - onemall - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - product - product - pom - - - product-rpc-api - product-rpc - product-rest - product-biz - - - - - - cn.iocoder.mall - mall-dependencies - 1.0-SNAPSHOT - pom - import - - - - - diff --git a/moved/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrBO.java b/moved/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrBO.java deleted file mode 100644 index 5519c84e..00000000 --- a/moved/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrBO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.mall.product.biz.bo.attr; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; - -@Data -@Accessors(chain = true) -public class ProductAttrBO implements Serializable { - - /** - * 规格编号 - */ - private Integer id; - /** - * 规格名 - */ - private String name; - /** - * 状态 - */ - private Integer status; - /** - * 创建时间 - */ - private Date createTime; - -} diff --git a/moved/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrSimpleBO.java b/moved/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrSimpleBO.java deleted file mode 100644 index c8b588b6..00000000 --- a/moved/product/product-biz/src/main/java/cn/iocoder/mall/product/biz/bo/attr/ProductAttrSimpleBO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.mall.product.biz.bo.attr; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; - -/** - * 商品规格精简 VO - */ -@Data -@Accessors(chain = true) -public class ProductAttrSimpleBO implements Serializable { - - /** - * 规格编号 - */ - private Integer id; - /** - * 规格名 - */ - private String name; - - -} diff --git a/moved/product/product-start/pom.xml b/moved/product/product-start/pom.xml deleted file mode 100644 index 5a0c29a9..00000000 --- a/moved/product/product-start/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - product - cn.iocoder.mall - 1.0-SNAPSHOT - - 4.0.0 - - product-start - - - - - cn.iocoder.mall - common-framework - 1.0-SNAPSHOT - - - cn.iocoder.mall - mall-spring-boot - 1.0-SNAPSHOT - - - cn.iocoder.mall - product-service-api - 1.0-SNAPSHOT - - - cn.iocoder.mall - product-service-impl - 1.0-SNAPSHOT - - - - cn.iocoder.mall - mall-spring-boot-starter-mybatis - 1.0-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-web - - - - io.springfox - springfox-swagger2 - - - com.github.xiaoymin - swagger-bootstrap-ui - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-sentinel - - - - - org.springframework.boot - spring-boot-starter-actuator - - - - io.micrometer - micrometer-registry-prometheus - - - - - org.springframework.boot - spring-boot-starter-test - test - - - cn.iocoder.mall - mall-spring-boot-starter-security - 1.0-SNAPSHOT - compile - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/user/UserAddressController.http b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/user/UserAddressController.http index 95d9d04e..95baf0cb 100644 --- a/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/user/UserAddressController.http +++ b/shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/user/UserAddressController.http @@ -1,5 +1,6 @@ ### /user-address/get-default 成功 GET {{shop-api-base-url}}/user-address/get-default Authorization: Bearer {{user-access-token}} +dubbo-tag: {{dubboTag}} ### diff --git a/system-service-project/pom.xml b/system-service-project/pom.xml index bc920f5a..be2f0674 100644 --- a/system-service-project/pom.xml +++ b/system-service-project/pom.xml @@ -14,6 +14,7 @@ system-service-api system-service-app + system-service-integration-test diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/config/SystemBizProperties.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/config/SystemBizProperties.java new file mode 100644 index 00000000..2786dd34 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/config/SystemBizProperties.java @@ -0,0 +1,30 @@ +package cn.iocoder.mall.systemservice.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; + +/** + * 系统服务的业务配置项 + */ +@Component +@ConfigurationProperties("biz") +@Validated +@Data +public class SystemBizProperties { + + /** + * 访问令牌过期时间,单位:毫秒 + */ + @NotNull(message = "访问令牌过期时间不能为空") + private int accessTokenExpireTimeMillis; + /** + * 刷新令牌过期时间,单位:毫秒 + */ + @NotNull(message = "刷新令牌过期时间不能为空") + private int refreshTokenExpireTimeMillis; + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/oauth/OAuth2Convert.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/oauth/OAuth2Convert.java index 77e0b20d..cb493d67 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/oauth/OAuth2Convert.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/oauth/OAuth2Convert.java @@ -2,7 +2,6 @@ package cn.iocoder.mall.systemservice.convert.oauth; import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; -import cn.iocoder.mall.systemservice.service.oauth.bo.OAuth2AccessTokenBO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -13,8 +12,6 @@ public interface OAuth2Convert { OAuth2Convert INSTANCE = Mappers.getMapper(OAuth2Convert.class); @Mapping(source = "id", target = "accessToken") - OAuth2AccessTokenBO convert(OAuth2AccessTokenDO bean); - - OAuth2AccessTokenRespDTO convert(OAuth2AccessTokenBO bean); + OAuth2AccessTokenRespDTO convert(OAuth2AccessTokenDO bean); } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/oauth/OAuth2AccessTokenMapper.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/oauth/OAuth2AccessTokenMapper.java index 6569df68..dc5bb218 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/oauth/OAuth2AccessTokenMapper.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/oauth/OAuth2AccessTokenMapper.java @@ -5,9 +5,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface OAuth2AccessTokenMapper extends BaseMapper { + default OAuth2AccessTokenDO selectByUserIdAndUserType(Integer userId, Integer userType) { + return selectOne(new QueryWrapper() + .eq("user_id", userId).eq("user_type", userType)); + } + default int deleteByUserIdAndUserType(Integer userId, Integer userType) { return delete(new QueryWrapper() .eq("user_id", userId).eq("user_type", userType)); @@ -17,4 +24,8 @@ public interface OAuth2AccessTokenMapper extends BaseMapper return delete(new QueryWrapper().eq("refresh_token", refreshToken)); } + default List selectListByRefreshToken(String refreshToken) { + return selectList(new QueryWrapper().eq("refresh_token", refreshToken)); + } + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/redis/RedisKeyConstants.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/redis/RedisKeyConstants.java new file mode 100644 index 00000000..af11419a --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/redis/RedisKeyConstants.java @@ -0,0 +1,24 @@ +package cn.iocoder.mall.systemservice.dal.redis; + +import cn.iocoder.mall.redis.core.RedisKeyDefine; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO; + +import java.time.Duration; + +import static cn.iocoder.mall.redis.core.RedisKeyDefine.KeyTypeEnum.STRING; + +/** + * Redis Key 枚举类 + * + * 通过将项目中的 Key 枚举在该类中,方便统一管理。 + */ +public interface RedisKeyConstants { + + /** + * {@link OAuth2AccessTokenDO} 的缓存 + * + * key 的 format 的参数是 [{@link OAuth2AccessTokenDO#getId()}] + */ + RedisKeyDefine OAUTH2_ACCESS_TOKEN = new RedisKeyDefine("oauth2_access_token:%s", STRING, OAuth2AccessTokenDO.class, Duration.ofHours(2)); + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/redis/dao/OAuth2AccessTokenRedisDAO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/redis/dao/OAuth2AccessTokenRedisDAO.java new file mode 100644 index 00000000..64c77e6c --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/redis/dao/OAuth2AccessTokenRedisDAO.java @@ -0,0 +1,36 @@ +package cn.iocoder.mall.systemservice.dal.redis.dao; + +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO; +import com.alibaba.fastjson.JSON; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Repository; + +import static cn.iocoder.mall.systemservice.dal.redis.RedisKeyConstants.OAUTH2_ACCESS_TOKEN; + +@Repository +public class OAuth2AccessTokenRedisDAO { + + @Autowired + private StringRedisTemplate redisTemplate; + + public OAuth2AccessTokenDO get(String accessToken) { + String redisKey = formatKey(accessToken); + return JSON.parseObject(redisTemplate.opsForValue().get(redisKey), OAuth2AccessTokenDO.class); + } + + public void set(OAuth2AccessTokenDO accessTokenDO) { + String redisKey = formatKey(accessTokenDO.getId()); + redisTemplate.opsForValue().set(redisKey, JSON.toJSONString(accessTokenDO), OAUTH2_ACCESS_TOKEN.getTimeout()); + } + + public void delete(String accessToken) { + String redisKey = formatKey(accessToken); + redisTemplate.delete(redisKey); + } + + private static String formatKey(String accessToken) { + return String.format(OAUTH2_ACCESS_TOKEN.getKeyTemplate(), accessToken); + } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/admin/AdminManager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/admin/AdminManager.java index a5d63d88..f6faf02f 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/admin/AdminManager.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/admin/AdminManager.java @@ -10,9 +10,10 @@ import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminPageDTO; import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminUpdateDTO; import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminVerifyPasswordDTO; import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; import cn.iocoder.mall.systemservice.service.admin.AdminService; import cn.iocoder.mall.systemservice.service.admin.bo.AdminBO; -import cn.iocoder.mall.systemservice.service.oauth.OAuth2Service; +import cn.iocoder.mall.systemservice.service.oauth.OAuth2ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,7 +24,7 @@ public class AdminManager { @Autowired private AdminService adminService; @Autowired - private OAuth2Service oauth2Service; + private OAuth2ServiceImpl oauth2Service; public AdminVO verifyPassword(AdminVerifyPasswordDTO verifyPasswordDTO) { AdminBO adminBO = adminService.verifyPassword(verifyPasswordDTO.getUsername(), @@ -43,7 +44,7 @@ public class AdminManager { // 如果修改密码,或者禁用管理员 if (StringUtils.hasText(updateDTO.getPassword()) || AdminStatusEnum.INACTIVE.getStatus().equals(updateDTO.getStatus())) { - oauth2Service.removeToken(updateDTO.getId(), UserTypeEnum.ADMIN.getValue()); + oauth2Service.removeToken(new OAuth2RemoveTokenByUserReqDTO().setUserId(updateDTO.getId()).setUserType(UserTypeEnum.ADMIN.getValue())); } } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/oauth/OAuth2Manager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/oauth/OAuth2Manager.java deleted file mode 100644 index 373390d2..00000000 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/oauth/OAuth2Manager.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.mall.systemservice.manager.oauth; - -import cn.iocoder.mall.systemservice.convert.oauth.OAuth2Convert; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; -import cn.iocoder.mall.systemservice.service.oauth.OAuth2Service; -import cn.iocoder.mall.systemservice.service.oauth.bo.OAuth2AccessTokenBO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; - -/** - * OAuth2.0 Manager - */ -@Service -@Validated -public class OAuth2Manager { - - @Autowired - private OAuth2Service oauth2Service; - - public OAuth2AccessTokenRespDTO createAccessToken(@Valid OAuth2CreateAccessTokenReqDTO createAccessTokenDTO) { - OAuth2AccessTokenBO accessTokenBO = oauth2Service.createAccessToken(createAccessTokenDTO.getUserId(), - createAccessTokenDTO.getUserType(), createAccessTokenDTO.getCreateIp()); - return OAuth2Convert.INSTANCE.convert(accessTokenBO); - } - - public OAuth2AccessTokenRespDTO checkAccessToken(String accessToken) { - OAuth2AccessTokenBO accessTokenBO = oauth2Service.checkAccessToken(accessToken); - return OAuth2Convert.INSTANCE.convert(accessTokenBO); - } - - public OAuth2AccessTokenRespDTO refreshAccessToken(@Valid OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO) { - OAuth2AccessTokenBO accessTokenBO = oauth2Service.refreshAccessToken(refreshAccessTokenDTO.getRefreshToken(), - refreshAccessTokenDTO.getCreateIp()); - return OAuth2Convert.INSTANCE.convert(accessTokenBO); - } - - public void removeToken(@Valid OAuth2RemoveTokenByUserReqDTO removeTokenDTO) { - oauth2Service.removeToken(removeTokenDTO.getUserId(), removeTokenDTO.getUserType()); - } - -} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2RpcImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2RpcImpl.java index 1f90685f..f585bc97 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2RpcImpl.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/oauth/OAuth2RpcImpl.java @@ -1,40 +1,40 @@ package cn.iocoder.mall.systemservice.rpc.oauth; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.systemservice.manager.oauth.OAuth2Manager; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO; -import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; -import org.apache.dubbo.config.annotation.Service; +import cn.iocoder.mall.systemservice.service.oauth.OAuth2Service; +import org.apache.dubbo.config.annotation.DubboService; import org.springframework.beans.factory.annotation.Autowired; import static cn.iocoder.common.framework.vo.CommonResult.success; -@Service(version = "${dubbo.provider.OAuth2Rpc.version}") +@DubboService public class OAuth2RpcImpl implements OAuth2Rpc { @Autowired - private OAuth2Manager oauth2Manager; + private OAuth2Service oAuth2Service; @Override public CommonResult createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO) { - return success(oauth2Manager.createAccessToken(createAccessTokenDTO)); + return success(oAuth2Service.createAccessToken(createAccessTokenDTO)); } @Override public CommonResult checkAccessToken(String accessToken) { - return success(oauth2Manager.checkAccessToken(accessToken)); + return success(oAuth2Service.checkAccessToken(accessToken)); } @Override public CommonResult refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO) { - return success(oauth2Manager.refreshAccessToken(refreshAccessTokenDTO)); + return success(oAuth2Service.refreshAccessToken(refreshAccessTokenDTO)); } @Override public CommonResult removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO) { - oauth2Manager.removeToken(removeTokenDTO); + oAuth2Service.removeToken(removeTokenDTO); return success(true); } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2Service.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2Service.java index 5c7167f0..5477b56e 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2Service.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2Service.java @@ -1,118 +1,21 @@ package cn.iocoder.mall.systemservice.service.oauth; -import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; -import cn.iocoder.common.framework.util.StringUtils; -import cn.iocoder.mall.systemservice.convert.oauth.OAuth2Convert; -import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO; -import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2RefreshTokenDO; -import cn.iocoder.mall.systemservice.dal.mysql.mapper.oauth.OAuth2AccessTokenMapper; -import cn.iocoder.mall.systemservice.dal.mysql.mapper.oauth.OAuth2RefreshTokenMapper; -import cn.iocoder.mall.systemservice.service.oauth.bo.OAuth2AccessTokenBO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Date; - -import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; /** - * OAuth2.0 Service + * OAuth2.0 Service 接口 */ -@Service -public class OAuth2Service { +public interface OAuth2Service { - /** - * 访问令牌过期时间,单位:毫秒 - */ - @Value("${modules.oauth2-service.access-token-expire-time-millis}") - private int accessTokenExpireTimeMillis; - /** - * 刷新令牌过期时间,单位:毫秒 - */ - @Value("${modules.oauth2-service.refresh-token-expire-time-millis}") - private int refreshTokenExpireTimeMillis; + OAuth2AccessTokenRespDTO createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO); - @Autowired - private OAuth2AccessTokenMapper oauth2AccessTokenMapper; - @Autowired - private OAuth2RefreshTokenMapper oauth2RefreshTokenMapper; + OAuth2AccessTokenRespDTO checkAccessToken(String accessToken); - @Transactional - public OAuth2AccessTokenBO createAccessToken(Integer userId, Integer userType, String createIp) { - // 创建刷新令牌 + 访问令牌 - OAuth2RefreshTokenDO refreshTokenDO = createOAuth2RefreshToken(userId, userType, createIp); - OAuth2AccessTokenDO accessTokenDO = createOAuth2AccessToken(refreshTokenDO, createIp); - // 返回访问令牌 - return OAuth2Convert.INSTANCE.convert(accessTokenDO); - } + OAuth2AccessTokenRespDTO refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO); - @Transactional - public OAuth2AccessTokenBO checkAccessToken(String accessToken) { - OAuth2AccessTokenDO accessTokenDO = oauth2AccessTokenMapper.selectById(accessToken); - if (accessTokenDO == null) { // 不存在 - throw ServiceExceptionUtil.exception(OAUTH2_ACCESS_TOKEN_NOT_FOUND); - } - if (accessTokenDO.getExpiresTime().getTime() < System.currentTimeMillis()) { // 已过期 - throw ServiceExceptionUtil.exception(OAUTH2_ACCESS_TOKEN_TOKEN_EXPIRED); - } - // 返回访问令牌 - return OAuth2Convert.INSTANCE.convert(accessTokenDO); - } - - @Transactional - public OAuth2AccessTokenBO refreshAccessToken(String refreshToken, String createIp) { - OAuth2RefreshTokenDO refreshTokenDO = oauth2RefreshTokenMapper.selectById(refreshToken); - // 校验刷新令牌是否合法 - if (refreshTokenDO == null) { // 不存在 - throw ServiceExceptionUtil.exception(OAUTH2_REFRESH_TOKEN_NOT_FOUND); - } - if (refreshTokenDO.getExpiresTime().getTime() < System.currentTimeMillis()) { // 已过期 - throw ServiceExceptionUtil.exception(OAUTH_REFRESH_TOKEN_EXPIRED); - } - // 标记 refreshToken 对应的 accessToken 都不合法 - // 这块的实现,参考了 Spring Security OAuth2 的代码 - oauth2AccessTokenMapper.deleteByRefreshToken(refreshToken); - // 创建访问令牌 - OAuth2AccessTokenDO oauth2AccessTokenDO = createOAuth2AccessToken(refreshTokenDO, createIp); - // 返回访问令牌 - return OAuth2Convert.INSTANCE.convert(oauth2AccessTokenDO); - } - - @Transactional - public void removeToken(Integer userId, Integer userType) { - oauth2AccessTokenMapper.deleteByUserIdAndUserType(userId, userType); - oauth2RefreshTokenMapper.deleteByUserIdAndUserType(userId, userType); - } - - private OAuth2AccessTokenDO createOAuth2AccessToken(OAuth2RefreshTokenDO refreshTokenDO, String createIp) { - OAuth2AccessTokenDO accessToken = new OAuth2AccessTokenDO() - .setId(generateAccessToken()) - .setUserId(refreshTokenDO.getUserId()).setUserType(refreshTokenDO.getUserType()) - .setRefreshToken(refreshTokenDO.getId()) - .setExpiresTime(new Date(System.currentTimeMillis() + accessTokenExpireTimeMillis)) - .setCreateIp(createIp); - oauth2AccessTokenMapper.insert(accessToken); - return accessToken; - } - - private OAuth2RefreshTokenDO createOAuth2RefreshToken(Integer userId, Integer userType, String createIp) { - OAuth2RefreshTokenDO refreshToken = new OAuth2RefreshTokenDO() - .setId(generateRefreshToken()) - .setUserId(userId).setUserType(userType) - .setExpiresTime(new Date(System.currentTimeMillis() + refreshTokenExpireTimeMillis)) - .setCreateIp(createIp); - oauth2RefreshTokenMapper.insert(refreshToken); - return refreshToken; - } - - private String generateAccessToken() { - return StringUtils.uuid(true); - } - - private String generateRefreshToken() { - return StringUtils.uuid(true); - } + void removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO); } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2ServiceImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2ServiceImpl.java new file mode 100644 index 00000000..1ad28216 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2ServiceImpl.java @@ -0,0 +1,161 @@ +package cn.iocoder.mall.systemservice.service.oauth; + +import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; +import cn.iocoder.common.framework.util.StringUtils; +import cn.iocoder.mall.systemservice.config.SystemBizProperties; +import cn.iocoder.mall.systemservice.convert.oauth.OAuth2Convert; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2RefreshTokenDO; +import cn.iocoder.mall.systemservice.dal.mysql.mapper.oauth.OAuth2AccessTokenMapper; +import cn.iocoder.mall.systemservice.dal.mysql.mapper.oauth.OAuth2RefreshTokenMapper; +import cn.iocoder.mall.systemservice.dal.redis.dao.OAuth2AccessTokenRedisDAO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO; +import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.*; + +/** + * OAuth2.0 Service 实现类 + */ +@Service +public class OAuth2ServiceImpl implements OAuth2Service { + + @Autowired + private SystemBizProperties systemBizProperties; + + @Autowired + private OAuth2AccessTokenMapper oauth2AccessTokenMapper; + @Autowired + private OAuth2RefreshTokenMapper oauth2RefreshTokenMapper; + + @Autowired + private OAuth2AccessTokenRedisDAO oauth2AccessTokenRedisDAO; + + @Override + @Transactional + public OAuth2AccessTokenRespDTO createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO) { + // 创建刷新令牌 + 访问令牌 + OAuth2RefreshTokenDO refreshTokenDO = createOAuth2RefreshToken(createAccessTokenDTO.getUserId(), + createAccessTokenDTO.getUserType(), createAccessTokenDTO.getCreateIp()); + OAuth2AccessTokenDO accessTokenDO = createOAuth2AccessToken(refreshTokenDO, createAccessTokenDTO.getCreateIp()); + // 返回访问令牌 + return OAuth2Convert.INSTANCE.convert(accessTokenDO); + } + + @Override + @Transactional + public OAuth2AccessTokenRespDTO checkAccessToken(String accessToken) { + OAuth2AccessTokenDO accessTokenDO = this.getOAuth2AccessToken(accessToken); + if (accessTokenDO == null) { // 不存在 + throw ServiceExceptionUtil.exception(OAUTH2_ACCESS_TOKEN_NOT_FOUND); + } + if (accessTokenDO.getExpiresTime().getTime() < System.currentTimeMillis()) { // 已过期 + throw ServiceExceptionUtil.exception(OAUTH2_ACCESS_TOKEN_TOKEN_EXPIRED); + } + // 返回访问令牌 + return OAuth2Convert.INSTANCE.convert(accessTokenDO); + } + + @Override + @Transactional + public OAuth2AccessTokenRespDTO refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO) { + OAuth2RefreshTokenDO refreshTokenDO = oauth2RefreshTokenMapper.selectById(refreshAccessTokenDTO.getRefreshToken()); + // 校验刷新令牌是否合法 + if (refreshTokenDO == null) { // 不存在 + throw ServiceExceptionUtil.exception(OAUTH2_REFRESH_TOKEN_NOT_FOUND); + } + if (refreshTokenDO.getExpiresTime().getTime() < System.currentTimeMillis()) { // 已过期 + throw ServiceExceptionUtil.exception(OAUTH_REFRESH_TOKEN_EXPIRED); + } + + // 标记 refreshToken 对应的 accessToken 都不合法 + // 这块的实现,参考了 Spring Security OAuth2 的代码 + List accessTokenDOs = oauth2AccessTokenMapper.selectListByRefreshToken(refreshAccessTokenDTO.getRefreshToken()); + accessTokenDOs.forEach(accessTokenDO -> deleteOAuth2AccessToken(accessTokenDO.getId())); + + // 创建访问令牌 + OAuth2AccessTokenDO oauth2AccessTokenDO = createOAuth2AccessToken(refreshTokenDO, refreshAccessTokenDTO.getCreateIp()); + // 返回访问令牌 + return OAuth2Convert.INSTANCE.convert(oauth2AccessTokenDO); + } + + @Override + @Transactional + public void removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO) { + // 删除 Access Token + OAuth2AccessTokenDO accessTokenDO = oauth2AccessTokenMapper.selectByUserIdAndUserType( + removeTokenDTO.getUserId(), removeTokenDTO.getUserType()); + if (accessTokenDO != null) { + this.deleteOAuth2AccessToken(accessTokenDO.getId()); + } + + // 删除 Refresh Token + oauth2RefreshTokenMapper.deleteByUserIdAndUserType(removeTokenDTO.getUserId(), removeTokenDTO.getUserType()); + } + + private OAuth2AccessTokenDO createOAuth2AccessToken(OAuth2RefreshTokenDO refreshTokenDO, String createIp) { + OAuth2AccessTokenDO accessToken = new OAuth2AccessTokenDO() + .setId(generateAccessToken()) + .setUserId(refreshTokenDO.getUserId()).setUserType(refreshTokenDO.getUserType()) + .setRefreshToken(refreshTokenDO.getId()) + .setExpiresTime(new Date(System.currentTimeMillis() + systemBizProperties.getAccessTokenExpireTimeMillis())) + .setCreateIp(createIp); + oauth2AccessTokenMapper.insert(accessToken); + return accessToken; + } + + private OAuth2RefreshTokenDO createOAuth2RefreshToken(Integer userId, Integer userType, String createIp) { + OAuth2RefreshTokenDO refreshToken = new OAuth2RefreshTokenDO() + .setId(generateRefreshToken()) + .setUserId(userId).setUserType(userType) + .setExpiresTime(new Date(System.currentTimeMillis() + systemBizProperties.getRefreshTokenExpireTimeMillis())) + .setCreateIp(createIp); + oauth2RefreshTokenMapper.insert(refreshToken); + return refreshToken; + } + + private OAuth2AccessTokenDO getOAuth2AccessToken(String accessToken) { + // 优先从 Redis 中获取 + OAuth2AccessTokenDO accessTokenDO = oauth2AccessTokenRedisDAO.get(accessToken); + if (accessTokenDO != null) { + return accessTokenDO; + } + + // 获取不到,从 MySQL 中获取 + accessTokenDO = oauth2AccessTokenMapper.selectById(accessToken); + // 如果在 MySQL 存在,则往 Redis 中写入 + if (accessTokenDO != null) { + oauth2AccessTokenRedisDAO.set(accessTokenDO); + } + return accessTokenDO; + } + + /** + * 删除 accessToken 的 MySQL 与 Redis 的数据 + * + * @param accessToken 访问令牌 + */ + private void deleteOAuth2AccessToken(String accessToken) { + // 删除 MySQL + oauth2AccessTokenMapper.deleteById(accessToken); + // 删除 Redis + oauth2AccessTokenRedisDAO.delete(accessToken); + } + + private static String generateAccessToken() { + return StringUtils.uuid(true); + } + + private static String generateRefreshToken() { + return StringUtils.uuid(true); + } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/bo/OAuth2AccessTokenBO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/bo/OAuth2AccessTokenBO.java deleted file mode 100644 index c76db62b..00000000 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/oauth/bo/OAuth2AccessTokenBO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.mall.systemservice.service.oauth.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * OAuth2.0 访问令牌 BO - */ -@Data -@Accessors(chain = true) -public class OAuth2AccessTokenBO { - - /** - * 访问令牌 - */ - private String accessToken; - /** - * 刷新令牌 - */ - private String refreshToken; - /** - * 用户编号 - */ - private Integer userId; - /** - * 用户类型 - */ - private Integer userType; - /** - * 过期时间 - */ - private Date expiresTime; - -} diff --git a/system-service-project/system-service-app/src/main/resources/application.properties b/system-service-project/system-service-app/src/main/resources/application.properties deleted file mode 100644 index 2d05e65c..00000000 --- a/system-service-project/system-service-app/src/main/resources/application.properties +++ /dev/null @@ -1,4 +0,0 @@ -##################### 业务模块 ##################### -## OAuth2CodeService -modules.oauth2-service.access-token-expire-time-millis = 2880000 -modules.oauth2-service.refresh-token-expire-time-millis = 43200000 diff --git a/system-service-project/system-service-app/src/main/resources/application.yaml b/system-service-project/system-service-app/src/main/resources/application.yaml index e12bddac..d4a9ef24 100644 --- a/system-service-project/system-service-app/src/main/resources/application.yaml +++ b/system-service-project/system-service-app/src/main/resources/application.yaml @@ -35,8 +35,6 @@ dubbo: provider: filter: -exception validation: true # 开启 Provider 参数校验 - OAuth2Rpc: - version: 1.0.0 AdminRpc: version: 1.0.0 ResourceRpc: @@ -72,3 +70,8 @@ mall: error-code: group: ${spring.application.name} constants-class: cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants + +# 业务配置 +biz: + access-token-expire-time-millis: 2880000 + refresh-token-expire-time-millis: 43200000 diff --git a/moved/product/product-service-api/pom.xml b/system-service-project/system-service-integration-test/pom.xml similarity index 50% rename from moved/product/product-service-api/pom.xml rename to system-service-project/system-service-integration-test/pom.xml index 663b24a9..74a5f998 100644 --- a/moved/product/product-service-api/pom.xml +++ b/system-service-project/system-service-integration-test/pom.xml @@ -3,35 +3,26 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - product + system-service-project cn.iocoder.mall 1.0-SNAPSHOT 4.0.0 - product-service-api + system-service-integration-test - cn.iocoder.mall - common-framework + system-service-app 1.0-SNAPSHOT - + - org.mapstruct - mapstruct - - - org.mapstruct - mapstruct-jdk8 - - - - org.projectlombok - lombok + org.springframework.boot + spring-boot-starter-test + test diff --git a/system-service-project/system-service-integration-test/src/test/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2ServiceImplTest.java b/system-service-project/system-service-integration-test/src/test/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2ServiceImplTest.java new file mode 100644 index 00000000..e00c9018 --- /dev/null +++ b/system-service-project/system-service-integration-test/src/test/java/cn/iocoder/mall/systemservice/service/oauth/OAuth2ServiceImplTest.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.systemservice.service.oauth; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class OAuth2ServiceImplTest { + + @Autowired + private OAuth2ServiceImpl oauth2Service; + + @Test + public void testCheckAccessToken() { + oauth2Service.checkAccessToken("yunai"); + } + +} diff --git a/system-service-project/system-service-integration-test/src/test/java/cn/iocoder/mall/systemservice/service/package-info.java b/system-service-project/system-service-integration-test/src/test/java/cn/iocoder/mall/systemservice/service/package-info.java new file mode 100644 index 00000000..960445f3 --- /dev/null +++ b/system-service-project/system-service-integration-test/src/test/java/cn/iocoder/mall/systemservice/service/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.mall.systemservice.service; diff --git a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/config/TradeBizProperties.java b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/config/TradeBizProperties.java index 98ea388f..13396032 100644 --- a/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/config/TradeBizProperties.java +++ b/trade-service-project/trade-service-app/src/main/java/cn/iocoder/mall/tradeservice/config/TradeBizProperties.java @@ -7,6 +7,9 @@ import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotNull; +/** + * 交易服务的业务配置项 + */ @Component @ConfigurationProperties("biz") @Validated