Compare commits
3 Commits
3f926a3023
...
42028b6eab
Author | SHA1 | Date | |
---|---|---|---|
42028b6eab | |||
281b04554e | |||
7b12848d0f |
|
@ -163,7 +163,7 @@ public class UserInfoController {
|
|||
@Operation(summary = "小程序用户重置密码(外部)", description = "参数:小程序用户密码重置请求体,权限:管理员(boss, admin),方法名:userInfoMiniOuterResetPwd")
|
||||
// @SysLog(title = "用户管理", content = "小程序用户重置密码(外部)")
|
||||
public BaseResponse<Boolean> userInfoMiniOuterResetPwd(@Valid @RequestBody UserInfoResetRequest userInfoResetRequest) {
|
||||
userInfoService.userInfoMiniResetPwd(userInfoResetRequest);
|
||||
userInfoService.userInfoMiniResetPwd(userInfoResetRequest, false);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class UserInfoController {
|
|||
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
|
||||
// @SysLog(title = "用户管理", content = "小程序用户重置密码(内部)")
|
||||
public BaseResponse<Boolean> userInfoMiniInnerResetPwd(@Valid @RequestBody UserInfoResetRequest userInfoResetRequest) {
|
||||
userInfoService.userInfoMiniResetPwd(userInfoResetRequest);
|
||||
userInfoService.userInfoMiniResetPwd(userInfoResetRequest, true);
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ public class UserInfoResetRequest implements Serializable {
|
|||
@Schema(description = "密码(建议加密存储)", example = "qingcheng")
|
||||
private String userPassword;
|
||||
|
||||
|
||||
/**
|
||||
* 确认密码
|
||||
*/
|
||||
|
@ -47,6 +46,11 @@ public class UserInfoResetRequest implements Serializable {
|
|||
@Schema(description = "确认密码(建议加密存储)", example = "qingcheng")
|
||||
private String userConfirmPassword;
|
||||
|
||||
/**
|
||||
* token(内部重置使用)
|
||||
*/
|
||||
@Schema(description = "token(内部重置使用)", example = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTY5MjE5MzE5NywiZXhwIjoxNjkyMTk3Nzk3fQ.Q_5Y5Z")
|
||||
private String sourceToken;
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -79,8 +79,6 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo>
|
|||
String fileType = FileUtil.getSuffix(fileName);
|
||||
// 获取view值
|
||||
String view = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
||||
// 获取文件路径
|
||||
String filePath = String.format("%s-%s", biz, fileName);
|
||||
// 获取文件大小
|
||||
Double fileSize = multipartFile.getSize() / 1024.0;
|
||||
fileSize = Double.valueOf(String.format("%.2f", fileSize));
|
||||
|
@ -91,7 +89,7 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo>
|
|||
LambdaQueryWrapper<FileInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(FileInfo::getHashValue, hashValue);
|
||||
FileInfo fileInfo = this.getOne(lambdaQueryWrapper);
|
||||
if (fileInfo != null) return fileInfo.getFileView();
|
||||
if (fileInfo != null) return biz + "-" + fileInfo.getFileView();
|
||||
// 保存文件
|
||||
fileInfo = FileInfo.builder()
|
||||
.name(fileName)
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.greenorange.promotion.model.dto.userInfo.*;
|
||||
import com.greenorange.promotion.model.entity.UserInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -48,7 +49,7 @@ public interface UserInfoService extends IService<UserInfo> {
|
|||
/**
|
||||
* 小程序用户重置密码
|
||||
*/
|
||||
void userInfoMiniResetPwd(UserInfoResetRequest userInfoResetRequest);
|
||||
String userInfoMiniResetPwd(UserInfoResetRequest userInfoResetRequest, boolean isInner);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.greenorange.promotion.service.userInfo.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
|
@ -29,6 +30,7 @@ import com.greenorange.promotion.utils.RegexUtils;
|
|||
import com.greenorange.promotion.utils.SendSmsUtil;
|
||||
import com.greenorange.promotion.utils.SqlUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -251,7 +253,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
|||
* 小程序用户重置密码
|
||||
*/
|
||||
@Override
|
||||
public void userInfoMiniResetPwd(UserInfoResetRequest userInfoResetRequest) {
|
||||
public String userInfoMiniResetPwd(UserInfoResetRequest userInfoResetRequest, boolean isInner) {
|
||||
String phoneNumber = userInfoResetRequest.getPhoneNumber();
|
||||
ThrowUtils.throwIf(RegexUtils.isPhoneInvalid(phoneNumber), ErrorCode.PARAMS_ERROR, "手机号格式无效");
|
||||
|
||||
|
@ -270,6 +272,22 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
|||
LambdaUpdateWrapper<UserInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(UserInfo::getPhoneNumber, phoneNumber).set(UserInfo::getUserPassword, userPassword);
|
||||
this.update(lambdaUpdateWrapper);
|
||||
|
||||
String token = "密码重置成功";
|
||||
if (isInner) {
|
||||
Map<String, String> payload = new HashMap<>();
|
||||
payload.put("userAccount", phoneNumber);
|
||||
payload.put("userPassword", userPassword);
|
||||
token = jwtUtils.generateToken(payload);
|
||||
// 获取token的过期时间
|
||||
String sourceToken = userInfoResetRequest.getSourceToken();
|
||||
DecodedJWT decodedJWT = jwtUtils.verify(sourceToken);
|
||||
long expirationTime = decodedJWT.getExpiresAt().getTime() - System.currentTimeMillis();
|
||||
// 将token存入Redis黑名单,并设置过期时间与token一致
|
||||
redisTemplate.opsForValue().set(sourceToken, sourceToken, expirationTime, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
// 更新token
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user