update m2pool 新增注销账号功能
This commit is contained in:
@@ -78,7 +78,7 @@ public class WebsocketChannelInterceptor implements ChannelInterceptor {
|
||||
//获取链接建立时的请求头信息
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
|
||||
if (accessor.getCommand() == StompCommand.CONNECT ) {
|
||||
System.out.println("yyb-开始链接"+new Date());
|
||||
System.out.println("开始链接"+new Date());
|
||||
StompHeaderAccessor mha = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
if(mha == null){
|
||||
throw new MessageDeliveryException(ExceptionEnum.fromCode(ExceptionEnum.SET_PRINCIPAL_FAIL));
|
||||
@@ -92,7 +92,7 @@ public class WebsocketChannelInterceptor implements ChannelInterceptor {
|
||||
ipLimit(accessor,type,email);
|
||||
//链接请求头中用户信息存入stomp中
|
||||
mha.setUser(new StompPrincipal(email,type,true));
|
||||
System.out.println("yyb-链接成功"+new Date());
|
||||
System.out.println("链接成功"+new Date());
|
||||
}
|
||||
if (accessor.getCommand() == StompCommand.SUBSCRIBE) {
|
||||
LOGGER.info("------------websocket subscribe message");
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.m2pool.file.service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 文件上传接口
|
||||
* 接口
|
||||
*
|
||||
* @author dy
|
||||
*/
|
||||
|
||||
@@ -39,6 +39,8 @@ public interface PoolMapper {
|
||||
public List<PowerLineDto> getHourPoolPowerList(@Param("table") String table);
|
||||
public List<PowerLineDto> getHourNetPowerList(@Param("table") String table);
|
||||
|
||||
BigDecimal getCurrentCoinPrice(@Param("table") String table);
|
||||
|
||||
public List<BlockInfoDto> getGRSBlockInfoList();
|
||||
|
||||
public List<BlockInfoDto> getMonaBlockInfoList();
|
||||
|
||||
@@ -22,6 +22,9 @@ import com.m2pool.pool.utils.EnumUtils;
|
||||
import com.m2pool.pool.utils.NodeRpc;
|
||||
import com.m2pool.pool.utils.PowerUnitUtils;
|
||||
import com.m2pool.pool.vo.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -33,7 +36,6 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -41,6 +43,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2024/6/14 14:29
|
||||
* @Author dy
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PoolServiceImpl implements PoolService {
|
||||
|
||||
@@ -182,6 +185,7 @@ public class PoolServiceImpl implements PoolService {
|
||||
public AjaxResult getPoolPower(CoinVo vo) {
|
||||
|
||||
Pools pool = (Pools) EnumUtils.get(Pools.class, vo.getCoin());
|
||||
|
||||
if(StringUtils.isNull(pool)){
|
||||
return AjaxResult.error("参数错误,未能根据当前参数获取到数据");
|
||||
}
|
||||
@@ -189,13 +193,12 @@ public class PoolServiceImpl implements PoolService {
|
||||
if(StringUtils.isBlank(vo.getInterval())){
|
||||
return AjaxResult.error("缺失参数:interval");
|
||||
}
|
||||
|
||||
PageHelper.clearPage();
|
||||
List<PowerLineDto> priceList = poolMapper.getHourPoolPowerList(pool.getCoin());
|
||||
|
||||
int scale = PoolProfitScale.getScaleByCoin(pool.getCoin());
|
||||
PowerLineDto powerLineDto = priceList.stream()
|
||||
.filter(e -> e.getDate().after(DateUtils.toDate(LocalDateTime.now().toLocalDate().atStartOfDay())))
|
||||
.max(Comparator.comparing(PowerLineDto::getPrice)).orElse(new PowerLineDto());
|
||||
|
||||
BigDecimal currentCoinPrice = poolMapper.getCurrentCoinPrice(pool.getCoin());
|
||||
|
||||
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
|
||||
// 获取当前日期
|
||||
@@ -221,19 +224,17 @@ public class PoolServiceImpl implements PoolService {
|
||||
//数据补零
|
||||
list = fillMissingOnlineData(list,oneDayAgo,currentDate,powerUnit.getUnit(),30);
|
||||
//通过全网算力接口 获取到的时间段价格补充到矿池算力接口的价格中
|
||||
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
||||
list.forEach(e -> priceList.stream().anyMatch(p ->{
|
||||
if( p.getDate().equals(e.getDate())){
|
||||
e.setPrice(p.getPrice());
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
|
||||
List<PowerLineDto> collect = list.stream().peek(e -> {
|
||||
if (e.getPrice() == 0) {
|
||||
e.setPrice(powerLineDto.getPrice());
|
||||
e.setPrice(currentCoinPrice.doubleValue());
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return AjaxResult.success(collect);
|
||||
}else if ("1d".equals(vo.getInterval())){
|
||||
|
||||
@@ -268,7 +269,7 @@ public class PoolServiceImpl implements PoolService {
|
||||
list = changeUnit(powerUnit, list, pool,BigDecimal.valueOf(1000 * 1000));
|
||||
|
||||
list = fillMissingOnlineData(list,oneMonthAgo,currentDate,powerUnit.getUnit(),24*60);
|
||||
list.stream().forEach(e -> priceList.stream().anyMatch(p ->{
|
||||
list.forEach(e -> priceList.stream().anyMatch(p ->{
|
||||
if( p.getDate().equals(e.getDate())){
|
||||
e.setPrice(p.getPrice());
|
||||
}
|
||||
@@ -276,7 +277,7 @@ public class PoolServiceImpl implements PoolService {
|
||||
}));
|
||||
List<PowerLineDto> collect = list.stream().peek(e -> {
|
||||
if (e.getPrice() == 0) {
|
||||
e.setPrice(powerLineDto.getPrice());
|
||||
e.setPrice(currentCoinPrice.doubleValue());
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
return AjaxResult.success(collect);
|
||||
@@ -423,7 +424,7 @@ public class PoolServiceImpl implements PoolService {
|
||||
List<PowerLineDto> list = poolMapper.getHourNetPowerList(pool.getCoin());
|
||||
|
||||
PowerLineDto powerLineDto = list.stream()
|
||||
.max(Comparator.comparing(PowerLineDto::getPrice)).orElse(new PowerLineDto());
|
||||
.max(Comparator.comparing(PowerLineDto::getDate)).orElse(new PowerLineDto());
|
||||
|
||||
list = list.stream().peek(e -> {
|
||||
if (e.getPrice() == 0) {
|
||||
@@ -541,7 +542,7 @@ public class PoolServiceImpl implements PoolService {
|
||||
}
|
||||
else {
|
||||
BlockInfo info = redisService.getCacheObject(pool.getCoin() + "_block");
|
||||
System.out.println("yyb-redis key"+ pool.getCoin() + "_block" +"查询结果"+ info);
|
||||
System.out.println("redis key"+ pool.getCoin() + "_block" +"查询结果"+ info);
|
||||
if(StringUtils.isNull(info)){
|
||||
if(!"enx".equals(pool.getCoin()) && !"alph".equals(pool.getCoin())){
|
||||
//
|
||||
@@ -736,7 +737,7 @@ public class PoolServiceImpl implements PoolService {
|
||||
|
||||
|
||||
List<MinerDataDto> list = poolMapper.getHourMinerDataList(vo.getCoin()+"_mhsv2",nowStr);
|
||||
if(list.size() > 0){
|
||||
if(!list.isEmpty()){
|
||||
List<MinerDataDto> offlineList = new ArrayList<>();
|
||||
list.stream().forEach(e -> {
|
||||
if(StringUtils.isNotNull(e.getMhs())){
|
||||
|
||||
@@ -504,7 +504,7 @@ public class NodeRpc{
|
||||
JSONObject jsonObject = JSON.parseObject(result);
|
||||
JSONObject jsonObject1 = JSON.parseObject(result1);
|
||||
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
|
||||
System.out.println("yyb-全网算力grs"+netPower);
|
||||
System.out.println("全网算力grs"+netPower);
|
||||
long height = jsonObject.getLongValue("height");
|
||||
blockInfo.setHeight(height);
|
||||
|
||||
@@ -589,7 +589,7 @@ public class NodeRpc{
|
||||
|
||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
|
||||
System.out.println("yyb-全网算力mona"+netPower);
|
||||
System.out.println("全网算力mona"+netPower);
|
||||
if(StringUtils.isNotNull(difficulty)){
|
||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
@@ -669,7 +669,7 @@ public class NodeRpc{
|
||||
|
||||
BigDecimal difficulty = jsonObject.getBigDecimal("difficulty");
|
||||
BigDecimal netPower = jsonObject1.getBigDecimal("networkhashps");
|
||||
System.out.println("yyb-全网算力rxd"+netPower);
|
||||
System.out.println("全网算力rxd"+netPower);
|
||||
if(StringUtils.isNotNull(difficulty)){
|
||||
blockInfo.setDifficulty(difficulty.setScale(2,BigDecimal.ROUND_HALF_UP));
|
||||
//NodeConstant constant = (NodeConstant) EnumUtils.get(NodeConstant.class, coin);
|
||||
@@ -1039,7 +1039,6 @@ public class NodeRpc{
|
||||
qBlockInfo.setPower(qNetwork);
|
||||
map.put("dgbq",qBlockInfo);
|
||||
}
|
||||
System.out.println("存储的数据"+map);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,3 +75,8 @@ myenv:
|
||||
path: /var/www/html/web_test
|
||||
img: /img
|
||||
filepath: /home/ubuntu/web
|
||||
|
||||
#mybatis:
|
||||
# configuration:
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
|
||||
@@ -62,13 +62,13 @@
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
|
||||
|
||||
|
||||
|
||||
</configuration>
|
||||
|
||||
@@ -375,11 +375,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="getHourPoolPowerList" resultType="com.m2pool.pool.dto.PowerLineDto">
|
||||
select
|
||||
p.date `date`,
|
||||
COALESCE(p.value,0) price,
|
||||
COALESCE(np.value,0) pv
|
||||
COALESCE(p.value,0) price
|
||||
from
|
||||
${table}_price p
|
||||
left join ${table}_net_power np on p.date = np.date
|
||||
where p.date >= DATE_SUB(NOW(), INTERVAL 35 DAY)
|
||||
</select>
|
||||
|
||||
<select id="getHourNetPowerList" resultType="com.m2pool.pool.dto.PowerLineDto">
|
||||
@@ -1048,6 +1047,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{i.user}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getCurrentCoinPrice" resultType="java.math.BigDecimal">
|
||||
select `value` from ${table}_price order by id DESC LIMIT 1;
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.m2pool.system.controller;
|
||||
|
||||
import com.m2pool.common.core.Result.R;
|
||||
import com.m2pool.common.core.constant.UserConstants;
|
||||
import com.m2pool.common.core.utils.DateUtils;
|
||||
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.log.annotation.Log;
|
||||
import com.m2pool.common.log.enums.BusinessType;
|
||||
import com.m2pool.common.security.annotation.InnerAuth;
|
||||
import com.m2pool.common.security.annotation.RequiresLogin;
|
||||
import com.m2pool.common.security.annotation.RequiresPermissions;
|
||||
import com.m2pool.common.security.utils.SecurityUtils;
|
||||
import com.m2pool.system.api.entity.SysRole;
|
||||
@@ -237,4 +237,11 @@ public class SysUserController extends BaseController {
|
||||
}
|
||||
return R.success(list);
|
||||
}
|
||||
|
||||
@RequiresLogin
|
||||
@PostMapping("/closeAccount")
|
||||
@ApiOperation(value = "用户注销")
|
||||
public AjaxResult closeAccount(@RequestBody SysUser sysUser){
|
||||
return toAjax(userService.closeAccount(sysUser));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,4 +135,12 @@ public interface SysUserMapper {
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> getCSList();
|
||||
|
||||
|
||||
/**
|
||||
* 关闭用户
|
||||
* @param closeAccountVo
|
||||
* @return
|
||||
*/
|
||||
boolean closeUser(SysUser sysUser);
|
||||
}
|
||||
|
||||
@@ -173,4 +173,11 @@ public interface SysUserService {
|
||||
* @return 结果
|
||||
*/
|
||||
public List<SysUser> getCSList();
|
||||
|
||||
|
||||
/**
|
||||
* 注销用户
|
||||
* @return 结果
|
||||
*/
|
||||
boolean closeAccount(SysUser sysUser);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ 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.entity.SysRole;
|
||||
import com.m2pool.system.api.entity.SysUser;
|
||||
import com.m2pool.system.api.entity.SysUserLeveDate;
|
||||
import com.m2pool.system.api.entity.*;
|
||||
import com.m2pool.system.entity.GoogleInfo;
|
||||
import com.m2pool.system.entity.SysUserRole;
|
||||
import com.m2pool.system.mapper.SysRoleMapper;
|
||||
@@ -444,5 +442,8 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean closeAccount(SysUser sysUser) {
|
||||
return userMapper.closeUser(sysUser);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,5 +207,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="resetPwdByEmail" parameterType="com.m2pool.system.api.entity.SysUser">
|
||||
update sys_user set password = #{password} where email = #{email}
|
||||
</update>
|
||||
<update id="closeUser">
|
||||
update sys_user
|
||||
<set>
|
||||
<if test="delFlag != null">delFlag = #{delFlag},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user