mirror of https://gitee.com/stylefeng/roses
【7.0.4】【c】增加个人秘钥字段
parent
8f4045285a
commit
4c5626298f
|
@ -64,4 +64,16 @@ public class CustomerInfoController {
|
|||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置个人秘钥
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/7/20 10:44
|
||||
*/
|
||||
@PostResource(name = "重置个人秘钥", path = "/customerInfo/resetPersonalSecret", requiredPermission = false)
|
||||
public ResponseData resetPersonalSecret() {
|
||||
String secret = customerService.updateSecret();
|
||||
return new SuccessResponseData(secret);
|
||||
}
|
||||
|
||||
}
|
|
@ -120,6 +120,13 @@ public class Customer extends BaseEntity {
|
|||
@ChineseDescription("用户状态:1-启用,2-禁用")
|
||||
private Integer statusFlag;
|
||||
|
||||
/**
|
||||
* 用户秘钥,用在调用会员校验等
|
||||
*/
|
||||
@TableField("secret_key")
|
||||
@ChineseDescription("用户秘钥")
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* 会员截止日期,到期时间
|
||||
*/
|
||||
|
|
|
@ -123,4 +123,12 @@ public interface CustomerService extends IService<Customer>, CustomerApi {
|
|||
*/
|
||||
void updateAvatar(CustomerInfoRequest customerInfoRequest);
|
||||
|
||||
/**
|
||||
* 重置个人秘钥
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/7/20 10:44
|
||||
*/
|
||||
String updateSecret();
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.SessionManagerApi;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander;
|
||||
|
@ -48,6 +49,7 @@ import cn.stylefeng.roses.kernel.security.api.expander.SecurityConfigExpander;
|
|||
import cn.stylefeng.roses.kernel.validator.api.exception.enums.ValidatorExceptionEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -357,6 +359,23 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|||
customerInfoCacheOperatorApi.remove(String.valueOf(customer.getCustomerId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String updateSecret() {
|
||||
// 获取当前登录用户
|
||||
Long userId = LoginContext.me().getLoginUser().getUserId();
|
||||
|
||||
// 重新生成秘钥
|
||||
String uuid = IdWorker.get32UUID();
|
||||
|
||||
// 更新用户秘钥
|
||||
LambdaUpdateWrapper<Customer> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.set(Customer::getSecretKey, uuid);
|
||||
wrapper.eq(Customer::getCustomerId, userId);
|
||||
this.update(wrapper);
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomerInfo getCustomerInfoById(Long customerId) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue