update m2pool 注销账号删除api,只读页,挖矿账号等信息实现
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.m2pool.pool.controller;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.m2pool.common.core.Result.R;
|
||||
import com.m2pool.common.core.utils.StringUtils;
|
||||
import com.m2pool.common.core.web.Result.AjaxResult;
|
||||
import com.m2pool.common.core.web.controller.BaseController;
|
||||
import com.m2pool.common.core.web.page.TableDataInfo;
|
||||
import com.m2pool.common.security.annotation.InnerAuth;
|
||||
import com.m2pool.common.security.annotation.RequiresLogin;
|
||||
import com.m2pool.pool.dto.UserApiDto;
|
||||
import com.m2pool.pool.service.GoogleAuthService;
|
||||
@@ -12,6 +14,7 @@ import com.m2pool.pool.service.MinerAccountService;
|
||||
import com.m2pool.pool.service.UserMinserService;
|
||||
import com.m2pool.pool.vo.*;
|
||||
import com.m2pool.system.api.RemoteUserService;
|
||||
import com.m2pool.system.api.entity.CloseAccountVo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -243,4 +246,12 @@ public class UserController extends BaseController {
|
||||
return umService.deleteApi(vo);
|
||||
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@PostMapping("/deleteUserDataAndPutTemporaryTable")
|
||||
@ApiOperation(value = "用户注销--删除用户(邮箱)对应相关信息并存入临时表")
|
||||
public R<?> deleteUserDataAndPutTemporaryTable(){
|
||||
return umService.deleteUserDataAndPutTemporaryTable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.m2pool.pool.dto.*;
|
||||
import com.m2pool.pool.entity.M2File;
|
||||
import com.m2pool.pool.entity.Ticket;
|
||||
import com.m2pool.pool.vo.*;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -154,5 +155,32 @@ public interface TicketMapper {
|
||||
*/
|
||||
public boolean insertRespon(@Param("vo") ResponTicketVo vo, @Param("name") String name);
|
||||
|
||||
/**
|
||||
* 将ticket表数据写入ticket_temporary临时表
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public boolean insertTicketToTemporary(@Param("list") List<Integer> list);
|
||||
|
||||
/**
|
||||
* 将ticket_supplement表数据写入ticket_supplement_temporary临时表
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public boolean insertTicketSupplementToTemporary(@Param("list") List<Integer> list);
|
||||
|
||||
/**
|
||||
* 删除ticket表数据
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteTicket(@Param("email") String email);
|
||||
|
||||
/**
|
||||
* 删除ticket_supplement表数据
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteTicketSupplement(@Param("email") String email);
|
||||
|
||||
}
|
||||
|
||||
@@ -111,4 +111,48 @@ public interface UserAccountMapper {
|
||||
|
||||
|
||||
List<UserAccountDto> getUserMinerByUserEmail(@Param("email") String email);
|
||||
|
||||
/**
|
||||
* 逻辑删除用户挖矿账户,将status改为11
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
boolean deleteUserAccount(@Param("username") String username);
|
||||
|
||||
/**
|
||||
* 删除用户账户余额,先根据username查询user_miner_account的id,然后根据这些id匹配ma_id删除
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
boolean deleteUserBalance(@Param("username") String username);
|
||||
|
||||
|
||||
/**
|
||||
* 删除用户只读页面
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
boolean deleteReadOnlyPage(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 将用户只读页面数据写入临时表
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
boolean insertReadOnlyPageToTemporary(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 将用户API数据写入临时表
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
boolean insertApiToTemporary(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 删除用户API
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
boolean deleteApi(@Param("ids") List<Long> ids);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.m2pool.pool.service;
|
||||
|
||||
|
||||
import com.m2pool.common.core.Result.R;
|
||||
import com.m2pool.common.core.web.Result.AjaxResult;
|
||||
import com.m2pool.pool.dto.UserApiDto;
|
||||
import com.m2pool.pool.vo.*;
|
||||
@@ -57,4 +58,10 @@ public interface UserMinserService {
|
||||
//public AjaxResult getMinerPower(MinerVo com.m2pool.chat.vo);
|
||||
//
|
||||
//public AjaxResult getMinerPowerDistribution(MinerVo com.m2pool.chat.vo);
|
||||
|
||||
/**
|
||||
* 用户注销--删除用户(邮箱)对应相关信息并存入临时表
|
||||
* return
|
||||
*/
|
||||
R<?> deleteUserDataAndPutTemporaryTable();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.m2pool.pool.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.m2pool.common.core.Result.R;
|
||||
import com.m2pool.common.core.constant.CacheConstants;
|
||||
import com.m2pool.common.core.text.Convert;
|
||||
import com.m2pool.common.core.utils.ServletUtils;
|
||||
@@ -18,6 +19,7 @@ import com.m2pool.pool.entity.*;
|
||||
import com.m2pool.pool.enums.PoolAmount;
|
||||
import com.m2pool.pool.enums.Pools;
|
||||
import com.m2pool.pool.mapper.GoogleAuthMapper;
|
||||
import com.m2pool.pool.mapper.TicketMapper;
|
||||
import com.m2pool.pool.mapper.UserAccountMapper;
|
||||
import com.m2pool.pool.service.UserMinserService;
|
||||
import com.m2pool.pool.utils.EnumUtils;
|
||||
@@ -29,6 +31,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
|
||||
@@ -56,7 +59,8 @@ public class UserMinerServiceImpl implements UserMinserService {
|
||||
|
||||
@Autowired
|
||||
private GoogleAuthMapper googleAuthMapper;
|
||||
|
||||
@Autowired
|
||||
private TicketMapper ticketMapper;
|
||||
|
||||
@Value("${myenv.domain}")
|
||||
private String domain;
|
||||
@@ -760,4 +764,40 @@ public class UserMinerServiceImpl implements UserMinserService {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public R<?> deleteUserDataAndPutTemporaryTable() {
|
||||
String username = SecurityUtils.getUsername();
|
||||
//删除挖矿账户
|
||||
uaMapper.deleteUserAccount(username);
|
||||
uaMapper.deleteUserBalance(username);
|
||||
//删除只读页面
|
||||
List<UserReadOnlyPageInfo> readOnlyPagelist = uaMapper.getPageListByUser(username);
|
||||
List<Long> readOnlyPageIds = readOnlyPagelist.stream().map(UserReadOnlyPageInfo::getId).collect(Collectors.toList());
|
||||
if (!readOnlyPageIds.isEmpty()){
|
||||
uaMapper.insertReadOnlyPageToTemporary(readOnlyPageIds);
|
||||
uaMapper.deleteReadOnlyPage(readOnlyPageIds);
|
||||
}
|
||||
|
||||
//删除API
|
||||
List<UserApi> apiList = uaMapper.getAPIListByUser(username);
|
||||
List<Long> apiIds = apiList.stream().map(UserApi::getId).collect(Collectors.toList());
|
||||
if (!apiIds.isEmpty()){
|
||||
uaMapper.insertApiToTemporary(apiIds);
|
||||
uaMapper.deleteApi(apiIds);
|
||||
}
|
||||
|
||||
//删除工单 + 工单补充内容
|
||||
List<PrivateTicketListDto> ticketList = ticketMapper.getPrivateTicketList(new PrivateTicketListVo(), username);
|
||||
List<Integer> ticketIds = ticketList.stream().map(PrivateTicketListDto::getId).collect(Collectors.toList());
|
||||
if (!ticketIds.isEmpty()) {
|
||||
ticketMapper.insertTicketToTemporary(ticketIds);
|
||||
ticketMapper.insertTicketSupplementToTemporary(ticketIds);
|
||||
|
||||
ticketMapper.deleteTicketSupplement(username);
|
||||
ticketMapper.deleteTicket(username);
|
||||
}
|
||||
return R.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -289,4 +289,50 @@
|
||||
#{vo.url},#{vo.fileName},#{vo.userName},#{vo.fileType},sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 将ticket表数据写入ticket_temporary临时表 -->
|
||||
<insert id="insertTicketToTemporary">
|
||||
INSERT INTO ticket_temporary (
|
||||
id, email, `desc`, create_time, status, update_time
|
||||
)
|
||||
SELECT
|
||||
id, email, `desc`, create_time, status, update_time
|
||||
FROM
|
||||
ticket
|
||||
WHERE
|
||||
id IN
|
||||
<foreach collection="list" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 将ticket_supplement表数据写入ticket_supplement_temporary临时表 -->
|
||||
<insert id="insertTicketSupplementToTemporary">
|
||||
INSERT INTO ticket_supplement_temporary (
|
||||
id, ticket_id, content, files, video_file, image_file, audio_file, create_time
|
||||
)
|
||||
SELECT
|
||||
id, ticket_id, content, files, video_file, image_file, audio_file, create_time
|
||||
FROM
|
||||
ticket_supplement
|
||||
WHERE
|
||||
ticket_id IN
|
||||
<foreach collection="list" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 删除ticket_supplement表数据 -->
|
||||
<delete id="deleteTicketSupplement">
|
||||
DELETE FROM ticket_supplement
|
||||
WHERE
|
||||
ticket_id IN (SELECT id FROM ticket WHERE email = #{email})
|
||||
</delete>
|
||||
|
||||
<!-- 删除ticket表数据 -->
|
||||
<delete id="deleteTicket">
|
||||
DELETE FROM ticket
|
||||
WHERE
|
||||
email = #{email}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -143,6 +143,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
<select id="getAccountByUserAndMinerAccount" resultType="com.m2pool.pool.dto.UserAccountDto">
|
||||
select
|
||||
`user`,
|
||||
@@ -331,6 +332,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and status = 0
|
||||
</select>
|
||||
|
||||
<!-- 逻辑删除用户挖矿账户,将status改为11 -->
|
||||
<update id="deleteUserAccount">
|
||||
UPDATE user_miner_account
|
||||
SET status = 11
|
||||
WHERE `user` = #{username}
|
||||
</update>
|
||||
|
||||
<!-- 删除用户账户余额,先根据username查询user_miner_account的id,然后根据这些id匹配ma_id删除 -->
|
||||
<update id="deleteUserBalance">
|
||||
UPDATE user_account_balance
|
||||
SET status = 99
|
||||
WHERE ma_id IN (
|
||||
SELECT id FROM user_miner_account WHERE `user` = #{username}
|
||||
)
|
||||
</update>
|
||||
|
||||
<delete id="deleteReadOnlyPage">
|
||||
DELETE FROM user_page_info
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 将用户只读页面数据写入临时表 -->
|
||||
<insert id="insertReadOnlyPageToTemporary">
|
||||
INSERT INTO user_page_info_temporary (
|
||||
id, `user`, account, coin, url_key, config, remark, create_time, update_time, lang
|
||||
)
|
||||
SELECT
|
||||
id, `user`, account, coin, url_key, config, remark, create_time, update_time, lang
|
||||
FROM
|
||||
user_page_info
|
||||
WHERE
|
||||
id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 将用户API数据写入临时表 -->
|
||||
<insert id="insertApiToTemporary">
|
||||
INSERT INTO user_api_temporary (
|
||||
id, `user`, api_key, api_ip, perms
|
||||
)
|
||||
SELECT
|
||||
id, `user`, api_key, api_ip, perms
|
||||
FROM
|
||||
user_api
|
||||
WHERE
|
||||
id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 删除用户API -->
|
||||
<delete id="deleteApi">
|
||||
DELETE FROM user_api
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -240,6 +240,7 @@ public class SysUserController extends BaseController {
|
||||
return R.success(list);
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@PostMapping("/closeAccount")
|
||||
@ApiOperation(value = "用户注销")
|
||||
public AjaxResult closeAccount(@RequestBody SysUser sysUser){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.m2pool.system.service.impl;
|
||||
|
||||
import com.m2pool.common.core.Result.R;
|
||||
import com.m2pool.common.core.constant.UserConstants;
|
||||
import com.m2pool.common.core.exception.ServiceException;
|
||||
import com.m2pool.common.core.utils.GoogleAuthenticator;
|
||||
@@ -8,6 +9,8 @@ import com.m2pool.common.core.utils.StringUtils;
|
||||
import com.m2pool.common.core.web.Result.AjaxResult;
|
||||
import com.m2pool.common.datascope.annotation.DataScope;
|
||||
import com.m2pool.common.security.utils.SecurityUtils;
|
||||
import com.m2pool.system.api.RemotePoolService;
|
||||
import com.m2pool.system.api.RemoteUserService;
|
||||
import com.m2pool.system.api.entity.*;
|
||||
import com.m2pool.system.entity.GoogleInfo;
|
||||
import com.m2pool.system.entity.SysUserRole;
|
||||
@@ -23,6 +26,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -53,6 +57,9 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
@Autowired
|
||||
private SysUserLevelMapper userLevelMapper;
|
||||
|
||||
@Resource
|
||||
private RemotePoolService remotePoolService;
|
||||
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
@@ -442,8 +449,15 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean closeAccount(SysUser sysUser) {
|
||||
//删除用户相关信息
|
||||
R<Boolean> booleanR = remotePoolService.deleteUserDataAndPutTemporaryTable();
|
||||
if (R.FAIL == booleanR.getCode()){
|
||||
throw new ServiceException("服务器请求失败请稍后再试");
|
||||
}
|
||||
return userMapper.closeUser(sysUser);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user