update m2pool 新增注销账号功能

This commit is contained in:
yyb
2025-12-31 10:01:46 +08:00
parent d5af03e5a4
commit c791d4fc17
10 changed files with 18 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ package com.m2pool.system.api;
import com.m2pool.common.core.Result.R;
import com.m2pool.common.core.constant.SecurityConstants;
import com.m2pool.common.core.constant.ServiceNameConstants;
import com.m2pool.system.api.entity.CloseAccountVo;
import com.m2pool.system.api.entity.SysUser;
import com.m2pool.system.api.entity.SysUserLeveDate;
import com.m2pool.system.api.factory.RemoteUserFallbackFactory;
@@ -82,7 +83,7 @@ public interface RemoteUserService {
* @return 结果
*/
@PostMapping("/user/profile/checkGoogleCode")
public R<Boolean> checkGoogleCode(@RequestBody Long code, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
public R<Boolean> checkGoogleCode(@RequestBody CloseAccountVo closeAccountVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 获取客服列表

View File

@@ -2,6 +2,7 @@ package com.m2pool.system.api.factory;
import com.m2pool.common.core.Result.R;
import com.m2pool.system.api.RemoteUserService;
import com.m2pool.system.api.entity.CloseAccountVo;
import com.m2pool.system.api.entity.SysUser;
import com.m2pool.system.api.entity.SysUserLeveDate;
import com.m2pool.system.api.model.LoginUser;
@@ -60,7 +61,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
}
@Override
public R<Boolean> checkGoogleCode(Long code, String source) {
public R<Boolean> checkGoogleCode(CloseAccountVo closeAccountVo, String source) {
return R.fail("谷歌验证器校验失败:" + cause.getMessage());
}

View File

@@ -99,12 +99,11 @@ public class TokenController {
/**
* 关闭注销账户
* 注销账户
* @param closeAccountVo
* @return
*/
@PostMapping("/closeAccount")
@RequiresLogin
@ApiOperation(value = "用户注销")
public R<?> closeAccount(@RequestBody @Valid CloseAccountVo closeAccountVo){
return sysLoginService.closeAccount(closeAccountVo);

View File

@@ -578,6 +578,7 @@ public class SysLoginService {
throw new ServiceException("邮箱为必填项");
}
String closeAccountKey = RedisTransKey.getCloseAccountKey(email);
System.out.println("redis 的 key"+closeAccountKey);
//校验谷歌验证码和邮箱验证码
if(redisService.hasKey(closeAccountKey)){
Object o = redisService.getCacheObject(closeAccountKey);//user:emailCode:email
@@ -591,8 +592,8 @@ public class SysLoginService {
}else {
throw new ServiceException("验证码未获取或已过期,请重新获取验证码");
}
R<Boolean> booleanR1 = remoteUserService.checkGoogleCode(closeAccountVo.getGCode(), SecurityConstants.INNER);
if(!booleanR1.getData()){
R<Boolean> booleanR1 = remoteUserService.checkGoogleCode(closeAccountVo, SecurityConstants.INNER);
if((booleanR1 != null && booleanR1.getData() == null) || !booleanR1.getData()){
throw new ServiceException("谷歌验证码错误");
}

View File

@@ -572,6 +572,7 @@ public class MaliServiceImpl implements MailService {
//判断用户是不是恶意刷邮箱,在规定时间内进行的
String closeAccountKey = RedisTransKey.getCloseAccountKey(email);
System.out.println("redis 的 key"+closeAccountKey);
if (redisService.hasKey(closeAccountKey)) {
Object o = redisService.getCacheObject(closeAccountKey);//user:updatePwdCode:email
@@ -602,7 +603,7 @@ public class MaliServiceImpl implements MailService {
);
sendCloseAccountMailMessage(email, emailCodeEntity.getEmailCode());
}
return R.success("请求成功,修改密码验证码已经发送至用户邮箱");
return R.success("请求成功,注销账户邮箱验证码发送成功");
}
@Override

View File

@@ -10,6 +10,7 @@ import com.m2pool.common.security.annotation.InnerAuth;
import com.m2pool.common.security.annotation.RequiresLogin;
import com.m2pool.common.security.service.TokenService;
import com.m2pool.common.security.utils.SecurityUtils;
import com.m2pool.system.api.entity.CloseAccountVo;
import com.m2pool.system.api.entity.SysRole;
import com.m2pool.system.api.entity.SysUser;
import com.m2pool.system.api.entity.SysUserLeveDate;
@@ -200,8 +201,8 @@ public class SysProfileController extends BaseController
@InnerAuth
@ApiOperation(value = "谷歌安全验证码验证")
@PostMapping("/checkGoogleCode")
public R<Boolean> checkGoogleCode(@RequestBody Long code){
return R.success(userService.checkGoogleCode(code));
public R<Boolean> checkGoogleCode(@RequestBody CloseAccountVo closeAccountVo){
return R.success(userService.checkGoogleCode(closeAccountVo.getGCode(),closeAccountVo.getUserEmail()));
}
}

View File

@@ -238,7 +238,6 @@ public class SysUserController extends BaseController {
return R.success(list);
}
@RequiresLogin
@PostMapping("/closeAccount")
@ApiOperation(value = "用户注销")
public AjaxResult closeAccount(@RequestBody SysUser sysUser){

View File

@@ -166,7 +166,7 @@ public interface SysUserService {
* @return 结果
* @param code
*/
public boolean checkGoogleCode(Long code);
public boolean checkGoogleCode(long code,String username);
/**
* 查询所有聊天客服

View File

@@ -381,9 +381,9 @@ public class SysUserServiceImpl implements SysUserService {
}
@Override
public boolean checkGoogleCode(Long code) {
String username = SecurityUtils.getUsername();
public boolean checkGoogleCode(long code,String username) {
System.out.println("用户名:"+username);
//谷歌验证码校验
GoogleInfo info = userMapper.getGoogleInfoByEmail(username);
if(StringUtils.isNull(info)){
@@ -403,7 +403,7 @@ public class SysUserServiceImpl implements SysUserService {
if(GoogleAuthenticator.checkCode(info.getSecret(), code, System.currentTimeMillis())){
return true;
}else {
throw new ServiceException("验证码错误");
throw new ServiceException("谷歌验证码错误");
}
}

View File

@@ -210,7 +210,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="closeUser">
update sys_user
<set>
<if test="delFlag != null">delFlag = #{delFlag},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
update_time = sysdate()
</set>
where user_id = #{userId}