【7.0.4】【c】增加个人秘钥字段

pull/22/head
fengshuonan 2021-07-20 10:49:29 +08:00
parent 8f4045285a
commit 4c5626298f
4 changed files with 46 additions and 0 deletions

View File

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

View File

@ -120,6 +120,13 @@ public class Customer extends BaseEntity {
@ChineseDescription("用户状态1-启用2-禁用")
private Integer statusFlag;
/**
*
*/
@TableField("secret_key")
@ChineseDescription("用户秘钥")
private String secretKey;
/**
*
*/

View File

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

View File

@ -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) {