From 2eb22db32df3847191890f362d61944d7dc82592 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Tue, 12 Apr 2022 14:22:48 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=907.2.2=E3=80=91=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=A7=98=E9=92=A5=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CustomerServiceImpl.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/impl/CustomerServiceImpl.java b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/impl/CustomerServiceImpl.java index bffe8852b..c85ee84db 100644 --- a/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/impl/CustomerServiceImpl.java +++ b/kernel-s-customer/customer-business/src/main/java/cn/stylefeng/roses/kernel/customer/modular/service/impl/CustomerServiceImpl.java @@ -2,6 +2,7 @@ package cn.stylefeng.roses.kernel.customer.modular.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.convert.Convert; +import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; @@ -376,18 +377,6 @@ public class CustomerServiceImpl extends ServiceImpl i public String updateSecret() { // 获取当前登录用户 Long userId = LoginContext.me().getLoginUser().getUserId(); - - // 查看当前用户是否有秘钥 - Customer customer = this.getById(userId); - if (StrUtil.isEmpty(customer.getSecretKey())) { - throw new CustomerException(CustomerExceptionEnum.NO_SECRET); - } - - // 判断秘钥是否过期 - if (customer.getMemberExpireTime().before(new Date())) { - throw new CustomerException(CustomerExceptionEnum.SECRET_EXPIRED); - } - return this.createOrUpdateCustomerSecret(userId); } @@ -400,9 +389,13 @@ public class CustomerServiceImpl extends ServiceImpl i // 重新生成秘钥 String randomString = RandomUtil.randomString(32); + // 秘钥过期时间24个月 + Date memberExpireTime = DateUtil.offset(new Date(), DateField.MONTH, 24); + // 更新用户秘钥 LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.set(Customer::getSecretKey, randomString); + wrapper.set(Customer::getMemberExpireTime, memberExpireTime); wrapper.eq(Customer::getCustomerId, customerId); this.update(wrapper);