1. 访问令牌,增加 Redis 作为缓存

2. 删除多余的 order 代码
This commit is contained in:
YunaiV 2020-12-05 23:13:39 +08:00
parent 03fde3699b
commit 9fb182e21a
47 changed files with 326 additions and 2220 deletions

View File

@ -119,7 +119,7 @@ TODO 此处应有一个架构图的装逼 JPG 图。
| `pay-service-project` | 支付 RPC 服务 | 随机 | | | `pay-service-project` | 支付 RPC 服务 | 随机 | |
| `trade-service-project` | 交易 RPC 服务 | 随机 | | | `trade-service-project` | 交易 RPC 服务 | 随机 | |
| `product-service-project` | 商品 RPC 服务 | 随机 | | | `product-service-project` | 商品 RPC 服务 | 随机 | |
| `search-service-project` | 搜索å RPC 服务 | 随机 | | | `search-service-project` | 搜索 RPC 服务 | 随机 | |
------- -------

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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<LogisticsDetail> 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;
}
}

View File

@ -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> 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<LogisticsDetail> 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;
}
}

View File

@ -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<OrderItem> 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;
}
}

View File

@ -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<OrderReturn> 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;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<OrderCommentMerchantReplyBO> orderCommentMerchantReplyBOS;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<OrderCommentItem> 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;
}
}

View File

@ -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;
}

View File

@ -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<OrderCommentReplayItem> 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;
}
}

View File

@ -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<OrderCommentStateInfoItem> 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;
}
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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<LogisticsDetail> 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;
}
}

View File

@ -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> 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<LogisticsDetail> 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;
}
}

View File

@ -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<OrderItem> 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;
}
}

View File

@ -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<OrderReturn> 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;
}
}

View File

@ -16,36 +16,6 @@ import org.springframework.web.bind.annotation.RestController;
@Api(description = "用户订单") // TODO FROM 芋艿 to 小范description 已经废弃啦 @Api(description = "用户订单") // TODO FROM 芋艿 to 小范description 已经废弃啦
public class UsersOrderController { public class UsersOrderController {
// @PostMapping("create_order_from_cart")
// @RequiresLogin
// @ApiOperation("创建订单购物车")
// public CommonResult<OrderCreateBO> 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<CartItemBO> 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<OrderCreateBO> 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") // @PostMapping("confirm_receiving")
// @RequiresLogin // @RequiresLogin

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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">
<parent>
<artifactId>onemall</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>product</artifactId>
<name>product</name>
<packaging>pom</packaging>
<modules>
<module>product-rpc-api</module>
<module>product-rpc</module>
<module>product-rest</module>
<module>product-biz</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-dependencies</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View File

@ -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;
}

View File

@ -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;
}

View File

@ -1,106 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
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">
<parent>
<artifactId>product</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>product-start</artifactId>
<dependencies>
<!-- Mall 相关 -->
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>product-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>product-service-impl</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-mybatis</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</dependency>
<!-- 服务保障相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- 监控 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<!-- 测试相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot-starter-security</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 提供给 mapstruct 使用 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!-- 打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,5 +1,6 @@
### /user-address/get-default 成功 ### /user-address/get-default 成功
GET {{shop-api-base-url}}/user-address/get-default GET {{shop-api-base-url}}/user-address/get-default
Authorization: Bearer {{user-access-token}} Authorization: Bearer {{user-access-token}}
dubbo-tag: {{dubboTag}}
### ###

View File

@ -14,6 +14,7 @@
<modules> <modules>
<module>system-service-api</module> <module>system-service-api</module>
<module>system-service-app</module> <module>system-service-app</module>
<module>system-service-integration-test</module>
</modules> </modules>
<dependencyManagement> <dependencyManagement>

View File

@ -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;
}

View File

@ -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.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO; 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.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -13,8 +12,6 @@ public interface OAuth2Convert {
OAuth2Convert INSTANCE = Mappers.getMapper(OAuth2Convert.class); OAuth2Convert INSTANCE = Mappers.getMapper(OAuth2Convert.class);
@Mapping(source = "id", target = "accessToken") @Mapping(source = "id", target = "accessToken")
OAuth2AccessTokenBO convert(OAuth2AccessTokenDO bean); OAuth2AccessTokenRespDTO convert(OAuth2AccessTokenDO bean);
OAuth2AccessTokenRespDTO convert(OAuth2AccessTokenBO bean);
} }

View File

@ -5,9 +5,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public interface OAuth2AccessTokenMapper extends BaseMapper<OAuth2AccessTokenDO> { public interface OAuth2AccessTokenMapper extends BaseMapper<OAuth2AccessTokenDO> {
default OAuth2AccessTokenDO selectByUserIdAndUserType(Integer userId, Integer userType) {
return selectOne(new QueryWrapper<OAuth2AccessTokenDO>()
.eq("user_id", userId).eq("user_type", userType));
}
default int deleteByUserIdAndUserType(Integer userId, Integer userType) { default int deleteByUserIdAndUserType(Integer userId, Integer userType) {
return delete(new QueryWrapper<OAuth2AccessTokenDO>() return delete(new QueryWrapper<OAuth2AccessTokenDO>()
.eq("user_id", userId).eq("user_type", userType)); .eq("user_id", userId).eq("user_type", userType));
@ -17,4 +24,8 @@ public interface OAuth2AccessTokenMapper extends BaseMapper<OAuth2AccessTokenDO>
return delete(new QueryWrapper<OAuth2AccessTokenDO>().eq("refresh_token", refreshToken)); return delete(new QueryWrapper<OAuth2AccessTokenDO>().eq("refresh_token", refreshToken));
} }
default List<OAuth2AccessTokenDO> selectListByRefreshToken(String refreshToken) {
return selectList(new QueryWrapper<OAuth2AccessTokenDO>().eq("refresh_token", refreshToken));
}
} }

View File

@ -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));
}

View File

@ -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);
}
}

View File

@ -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.AdminUpdateDTO;
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminVerifyPasswordDTO; import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminVerifyPasswordDTO;
import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO; 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.AdminService;
import cn.iocoder.mall.systemservice.service.admin.bo.AdminBO; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -23,7 +24,7 @@ public class AdminManager {
@Autowired @Autowired
private AdminService adminService; private AdminService adminService;
@Autowired @Autowired
private OAuth2Service oauth2Service; private OAuth2ServiceImpl oauth2Service;
public AdminVO verifyPassword(AdminVerifyPasswordDTO verifyPasswordDTO) { public AdminVO verifyPassword(AdminVerifyPasswordDTO verifyPasswordDTO) {
AdminBO adminBO = adminService.verifyPassword(verifyPasswordDTO.getUsername(), AdminBO adminBO = adminService.verifyPassword(verifyPasswordDTO.getUsername(),
@ -43,7 +44,7 @@ public class AdminManager {
// 如果修改密码或者禁用管理员 // 如果修改密码或者禁用管理员
if (StringUtils.hasText(updateDTO.getPassword()) if (StringUtils.hasText(updateDTO.getPassword())
|| AdminStatusEnum.INACTIVE.getStatus().equals(updateDTO.getStatus())) { || AdminStatusEnum.INACTIVE.getStatus().equals(updateDTO.getStatus())) {
oauth2Service.removeToken(updateDTO.getId(), UserTypeEnum.ADMIN.getValue()); oauth2Service.removeToken(new OAuth2RemoveTokenByUserReqDTO().setUserId(updateDTO.getId()).setUserType(UserTypeEnum.ADMIN.getValue()));
} }
} }

View File

@ -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());
}
}

View File

@ -1,40 +1,40 @@
package cn.iocoder.mall.systemservice.rpc.oauth; package cn.iocoder.mall.systemservice.rpc.oauth;
import cn.iocoder.common.framework.vo.CommonResult; 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.OAuth2CreateAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO; 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 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 org.springframework.beans.factory.annotation.Autowired;
import static cn.iocoder.common.framework.vo.CommonResult.success; import static cn.iocoder.common.framework.vo.CommonResult.success;
@Service(version = "${dubbo.provider.OAuth2Rpc.version}") @DubboService
public class OAuth2RpcImpl implements OAuth2Rpc { public class OAuth2RpcImpl implements OAuth2Rpc {
@Autowired @Autowired
private OAuth2Manager oauth2Manager; private OAuth2Service oAuth2Service;
@Override @Override
public CommonResult<OAuth2AccessTokenRespDTO> createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO) { public CommonResult<OAuth2AccessTokenRespDTO> createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO) {
return success(oauth2Manager.createAccessToken(createAccessTokenDTO)); return success(oAuth2Service.createAccessToken(createAccessTokenDTO));
} }
@Override @Override
public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(String accessToken) { public CommonResult<OAuth2AccessTokenRespDTO> checkAccessToken(String accessToken) {
return success(oauth2Manager.checkAccessToken(accessToken)); return success(oAuth2Service.checkAccessToken(accessToken));
} }
@Override @Override
public CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO) { public CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO) {
return success(oauth2Manager.refreshAccessToken(refreshAccessTokenDTO)); return success(oAuth2Service.refreshAccessToken(refreshAccessTokenDTO));
} }
@Override @Override
public CommonResult<Boolean> removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO) { public CommonResult<Boolean> removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO) {
oauth2Manager.removeToken(removeTokenDTO); oAuth2Service.removeToken(removeTokenDTO);
return success(true); return success(true);
} }

View File

@ -1,118 +1,21 @@
package cn.iocoder.mall.systemservice.service.oauth; package cn.iocoder.mall.systemservice.service.oauth;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
import cn.iocoder.common.framework.util.StringUtils; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.convert.oauth.OAuth2Convert; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.oauth.OAuth2AccessTokenDO; import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RemoveTokenByUserReqDTO;
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.*;
/** /**
* OAuth2.0 Service * OAuth2.0 Service 接口
*/ */
@Service public interface OAuth2Service {
public class OAuth2Service {
/** OAuth2AccessTokenRespDTO createAccessToken(OAuth2CreateAccessTokenReqDTO createAccessTokenDTO);
* 访问令牌过期时间单位毫秒
*/
@Value("${modules.oauth2-service.access-token-expire-time-millis}")
private int accessTokenExpireTimeMillis;
/**
* 刷新令牌过期时间单位毫秒
*/
@Value("${modules.oauth2-service.refresh-token-expire-time-millis}")
private int refreshTokenExpireTimeMillis;
@Autowired OAuth2AccessTokenRespDTO checkAccessToken(String accessToken);
private OAuth2AccessTokenMapper oauth2AccessTokenMapper;
@Autowired
private OAuth2RefreshTokenMapper oauth2RefreshTokenMapper;
@Transactional OAuth2AccessTokenRespDTO refreshAccessToken(OAuth2RefreshAccessTokenReqDTO refreshAccessTokenDTO);
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);
}
@Transactional void removeToken(OAuth2RemoveTokenByUserReqDTO removeTokenDTO);
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);
}
} }

View File

@ -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<OAuth2AccessTokenDO> 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);
}
}

View File

@ -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;
}

View File

@ -1,4 +0,0 @@
##################### 业务模块 #####################
## OAuth2CodeService
modules.oauth2-service.access-token-expire-time-millis = 2880000
modules.oauth2-service.refresh-token-expire-time-millis = 43200000

View File

@ -35,8 +35,6 @@ dubbo:
provider: provider:
filter: -exception filter: -exception
validation: true # 开启 Provider 参数校验 validation: true # 开启 Provider 参数校验
OAuth2Rpc:
version: 1.0.0
AdminRpc: AdminRpc:
version: 1.0.0 version: 1.0.0
ResourceRpc: ResourceRpc:
@ -72,3 +70,8 @@ mall:
error-code: error-code:
group: ${spring.application.name} group: ${spring.application.name}
constants-class: cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants constants-class: cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants
# 业务配置
biz:
access-token-expire-time-millis: 2880000
refresh-token-expire-time-millis: 43200000

View File

@ -3,35 +3,26 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>product</artifactId> <artifactId>system-service-project</artifactId>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>product-service-api</artifactId> <artifactId>system-service-integration-test</artifactId>
<dependencies> <dependencies>
<!-- Mall 相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId> <artifactId>system-service-app</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- 工具类相关 --> <!-- Test 相关 -->
<dependency> <dependency>
<groupId>org.mapstruct</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher --> <artifactId>spring-boot-starter-test</artifactId>
</dependency> <scope>test</scope>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -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");
}
}

View File

@ -0,0 +1 @@
package cn.iocoder.mall.systemservice.service;

View File

@ -7,6 +7,9 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
/**
* 交易服务的业务配置项
*/
@Component @Component
@ConfigurationProperties("biz") @ConfigurationProperties("biz")
@Validated @Validated