update 聊天室遗漏队列添加,dgb系列幸运值全网报块数问题
This commit is contained in:
parent
779aaca109
commit
b6b26e591f
|
@ -1,6 +1,8 @@
|
||||||
package com.m2pool.system.api.model;
|
package com.m2pool.system.api.model;
|
||||||
|
|
||||||
import com.m2pool.system.api.entity.SysUser;
|
import com.m2pool.system.api.entity.SysUser;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -12,35 +14,45 @@ import java.util.Set;
|
||||||
* @Author dy
|
* @Author dy
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@ApiModel(description = "登录用户信息")
|
||||||
public class LoginUser implements Serializable {
|
public class LoginUser implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 用户唯一标识 */
|
/** 用户唯一标识 */
|
||||||
|
@ApiModelProperty(value = "用户唯一标识")
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
/** 用户名id */
|
/** 用户名id */
|
||||||
|
@ApiModelProperty(value = "用户名id")
|
||||||
private Long userid;
|
private Long userid;
|
||||||
|
|
||||||
/** 用户名 */
|
/** 用户名 */
|
||||||
|
@ApiModelProperty(value = "用户名")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/** 登录时间 */
|
/** 登录时间 */
|
||||||
|
@ApiModelProperty(value = "登录时间")
|
||||||
private Long loginTime;
|
private Long loginTime;
|
||||||
|
|
||||||
/** 过期时间 */
|
/** 过期时间 */
|
||||||
|
@ApiModelProperty(value = "过期时间")
|
||||||
private Long expireTime;
|
private Long expireTime;
|
||||||
|
|
||||||
/** 登录IP地址 */
|
/** 登录IP地址 */
|
||||||
|
@ApiModelProperty(value = "登录IP地址")
|
||||||
private String ipaddr;
|
private String ipaddr;
|
||||||
|
|
||||||
/** 权限列表 */
|
/** 权限列表 */
|
||||||
|
@ApiModelProperty(value = "权限列表")
|
||||||
private Set<String> permissions;
|
private Set<String> permissions;
|
||||||
|
|
||||||
/** 角色列表 */
|
/** 角色列表 */
|
||||||
|
@ApiModelProperty(value = "角色列表")
|
||||||
private Set<String> roles;
|
private Set<String> roles;
|
||||||
|
|
||||||
/** 用户信息 */
|
/** 用户信息 */
|
||||||
|
@ApiModelProperty(value = "用户详情信息对象")
|
||||||
private SysUser sysUser;
|
private SysUser sysUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,6 +50,19 @@ public class TokenController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台管理系统登录
|
||||||
|
* @param loginManageBody
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("managerLogin")
|
||||||
|
@ApiOperation(value = "后台管理系统登录")
|
||||||
|
public R<Map<String,Object>> managerLogin(@RequestBody @Valid LoginManageBody loginManageBody)
|
||||||
|
{
|
||||||
|
return sysLoginService.managerLogin(loginManageBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("registerCode")
|
@PostMapping("registerCode")
|
||||||
public R<?> emailCode(@Validated @RequestBody GetEmailCodeEntity entity)
|
public R<?> emailCode(@Validated @RequestBody GetEmailCodeEntity entity)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,11 @@ import com.m2pool.system.api.model.LoginUser;
|
||||||
import org.apache.ibatis.annotations.Update;
|
import org.apache.ibatis.annotations.Update;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,6 +236,86 @@ public class SysLoginService {
|
||||||
return R.success(tokenService.createToken(userInfo));
|
return R.success(tokenService.createToken(userInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public R<Map<String,Object>> managerLogin(LoginManageBody loginManageBody){
|
||||||
|
//邮箱
|
||||||
|
String email = loginManageBody.getUserName();
|
||||||
|
|
||||||
|
//String password= loginBody.getPassword();
|
||||||
|
String password="";
|
||||||
|
|
||||||
|
try {
|
||||||
|
password = RsaUtils.decryptByPrivateKey(loginManageBody.getPassword());
|
||||||
|
password = StringUtils.clean(password);
|
||||||
|
}catch (Exception e){
|
||||||
|
return R.fail(401,"加密密码传参有误");
|
||||||
|
}
|
||||||
|
// 用户名或密码为空 错误
|
||||||
|
if (StringUtils.isAnyBlank(email, password))
|
||||||
|
{
|
||||||
|
recordLogininfor(email, Constants.LOGIN_FAIL, "邮箱/密码必须填写");
|
||||||
|
throw new ServiceException("邮箱/密码必须填写");
|
||||||
|
}
|
||||||
|
if(!StringUtils.isBlank(email)){
|
||||||
|
if(!email.matches(EMAIL_REGEX)){
|
||||||
|
throw new ServiceException("邮箱格式错误");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
throw new ServiceException("邮箱为必填项");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 密码如果不在指定范围内 错误
|
||||||
|
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||||
|
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
||||||
|
{
|
||||||
|
recordLogininfor(email, Constants.LOGIN_FAIL, "用户密码不在指定范围");
|
||||||
|
throw new ServiceException("用户密码不在指定范围");
|
||||||
|
}
|
||||||
|
// 查询用户信息
|
||||||
|
R<LoginUser> userResult = remoteUserService.getUserInfo(email, SecurityConstants.INNER);
|
||||||
|
|
||||||
|
if (R.FAIL == userResult.getCode())
|
||||||
|
{
|
||||||
|
throw new ServiceException(userResult.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNull(userResult.getData()))
|
||||||
|
{
|
||||||
|
recordLogininfor(email, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||||
|
throw new ServiceException("登录用户:" + email + " 不存在");
|
||||||
|
}
|
||||||
|
LoginUser userInfo = userResult.getData();
|
||||||
|
SysUser user = userResult.getData().getSysUser();
|
||||||
|
Set<String> roles = userInfo.getRoles();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
|
||||||
|
{
|
||||||
|
recordLogininfor(email, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||||
|
throw new ServiceException("对不起,您的账号:" + email + " 已被删除");
|
||||||
|
}
|
||||||
|
if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
||||||
|
{
|
||||||
|
recordLogininfor(email, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
||||||
|
throw new ServiceException("对不起,您的账号:" + email + " 已停用");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!SecurityUtils.matchesPassword(password, user.getPassword())){
|
||||||
|
throw new ServiceException("密码错误,请重新输入");
|
||||||
|
}
|
||||||
|
|
||||||
|
//必须是管理员才能登录
|
||||||
|
if(!roles.contains("3")){
|
||||||
|
recordLogininfor(email, Constants.LOGIN_FAIL, "对不起,您的账号没有权限不能登录后台管理");
|
||||||
|
throw new ServiceException("对不起,您的账号:" + email + " 没有权限不能登录后台管理");
|
||||||
|
}
|
||||||
|
|
||||||
|
recordLogininfor(email, Constants.LOGIN_SUCCESS, "后台管理系统用户登录成功");
|
||||||
|
|
||||||
|
return R.success(tokenService.createToken(userInfo));
|
||||||
|
}
|
||||||
|
|
||||||
public void logout(String loginName)
|
public void logout(String loginName)
|
||||||
{
|
{
|
||||||
recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
recordLogininfor(loginName, Constants.LOGOUT, "退出成功");
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class WebSocketBrokerConfig implements WebSocketMessageBrokerConfigurer {
|
||||||
@Override
|
@Override
|
||||||
public void configureMessageBroker(MessageBrokerRegistry config) {
|
public void configureMessageBroker(MessageBrokerRegistry config) {
|
||||||
|
|
||||||
config.enableSimpleBroker(Destination.TOPIC, Destination.QUEUE_USER,Destination.QUEUE_CUSTOMER)
|
config.enableSimpleBroker(Destination.TOPIC, Destination.QUEUE_USER,Destination.QUEUE_CUSTOMER,Destination.QUEUE_CLOSE_ROOM)
|
||||||
.setHeartbeatValue(new long[] {10000, 10000})
|
.setHeartbeatValue(new long[] {10000, 10000})
|
||||||
.setTaskScheduler(new DefaultManagedTaskScheduler());
|
.setTaskScheduler(new DefaultManagedTaskScheduler());
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class Destination {
|
||||||
/**
|
/**
|
||||||
* 聊天室关闭 路径
|
* 聊天室关闭 路径
|
||||||
*/
|
*/
|
||||||
public static final String QUEUE_CLOSE_ROOM = "/close/room/";
|
public static final String QUEUE_CLOSE_ROOM = "/queue/close/room/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stomp 默认群发 目的地
|
* stomp 默认群发 目的地
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class CommonMessageConvert implements MessageConverter {
|
||||||
if (message.getPayload() instanceof byte[]) {
|
if (message.getPayload() instanceof byte[]) {
|
||||||
try {
|
try {
|
||||||
String textPayload = new String((byte[]) message.getPayload(), StandardCharsets.UTF_8);
|
String textPayload = new String((byte[]) message.getPayload(), StandardCharsets.UTF_8);
|
||||||
|
System.out.println("发送者发送到服务器的消息:"+textPayload);
|
||||||
return JsonUtil.convertString2Object(textPayload,targetClass);
|
return JsonUtil.convertString2Object(textPayload,targetClass);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new MessageDeliveryException( "消息格式错误");
|
throw new MessageDeliveryException( "消息格式错误");
|
||||||
|
@ -46,8 +47,8 @@ public class CommonMessageConvert implements MessageConverter {
|
||||||
@Override
|
@Override
|
||||||
public Message<?> toMessage(Object payload, MessageHeaders headers) {
|
public Message<?> toMessage(Object payload, MessageHeaders headers) {
|
||||||
String str = JsonUtil.toJson(payload);
|
String str = JsonUtil.toJson(payload);
|
||||||
|
System.out.println("发送给接受者的消息:"+payload);
|
||||||
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
|
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
|
||||||
System.out.println("发送给前端的消息"+new GenericMessage<>(bytes, headers));
|
|
||||||
return new GenericMessage<>(bytes, headers);
|
return new GenericMessage<>(bytes, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,12 +42,14 @@ public class WebSocketEventListener implements ApplicationListener<SessionDiscon
|
||||||
StompPrincipal user = (StompPrincipal) event.getUser();
|
StompPrincipal user = (StompPrincipal) event.getUser();
|
||||||
Message<byte[]> message = event.getMessage();
|
Message<byte[]> message = event.getMessage();
|
||||||
StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
|
StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
|
||||||
if (user != null && accessor.getCommand() == StompCommand.DISCONNECT && TOURIST.equals(user.getType())) {
|
LOGGER.info("用户{}断开链接:用户类型{},消息类型{}",user.getName(), user.getType(), accessor.getCommand());
|
||||||
|
if (accessor.getCommand() == StompCommand.DISCONNECT && TOURIST.equals(user.getType())) {
|
||||||
//游客断开链接,通知客服删除游客聊天室
|
//游客断开链接,通知客服删除游客聊天室
|
||||||
stompService.customerCloseRoom(user.getName());
|
stompService.customerCloseRoom(user.getName());
|
||||||
// 删除数据库中游客数据
|
// 删除数据库中游客数据
|
||||||
chatRoomMapper.delete(new LambdaUpdateWrapper<ChatRoom>().eq(ChatRoom::getUserOneEmail, user.getName()));
|
int delete = chatRoomMapper.delete(new LambdaUpdateWrapper<ChatRoom>().eq(ChatRoom::getUserOneEmail, user.getName()));
|
||||||
chatMessageMapper.delete(new LambdaUpdateWrapper<ChatMessage>().eq(ChatMessage::getSendEmail, user.getName()));
|
int delete1 = chatMessageMapper.delete(new LambdaUpdateWrapper<ChatMessage>().eq(ChatMessage::getSendEmail, user.getName()));
|
||||||
|
LOGGER.info("删除游客聊天室个数:{},消息个数{}", delete,delete1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,11 +47,15 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
||||||
if(StringUtils.isEmpty(email)){
|
if(StringUtils.isEmpty(email)){
|
||||||
return R.fail("查询失败,用户标识或邮箱不能为空");
|
return R.fail("查询失败,用户标识或邮箱不能为空");
|
||||||
}
|
}
|
||||||
|
if(roomId == null){
|
||||||
|
return R.fail("查询聊天消息失败,聊天室ID不能为空");
|
||||||
|
}
|
||||||
|
//判断当前消息是否是七天内消息
|
||||||
if(id != null && id != 0){
|
if(id != null && id != 0){
|
||||||
chatMessage = chatMessageMapper.selectById(id);
|
chatMessage = chatMessageMapper.selectById(id);
|
||||||
}else{
|
}else{
|
||||||
chatMessage = chatMessageMapper.selectOne(new LambdaQueryWrapper<ChatMessage>()
|
chatMessage = chatMessageMapper.selectOne(new LambdaQueryWrapper<ChatMessage>()
|
||||||
.eq(ChatMessage::getRoomId, roomId).last("LIMIT 1"));
|
.eq(ChatMessage::getRoomId, roomId).orderByDesc(ChatMessage::getId).last("LIMIT 1"));
|
||||||
}
|
}
|
||||||
List<ChatMessageDto> recentlyMessage;
|
List<ChatMessageDto> recentlyMessage;
|
||||||
if(chatMessage != null){
|
if(chatMessage != null){
|
||||||
|
|
|
@ -24,6 +24,7 @@ import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static com.alibaba.nacos.client.utils.EnvUtil.LOGGER;
|
||||||
import static com.m2pool.chat.constant.UserType.CUSTOMER;
|
import static com.m2pool.chat.constant.UserType.CUSTOMER;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -177,13 +178,13 @@ public class StompServiceImpl implements StompService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于客服关闭断线客服端聊天室接口
|
* 用于客服关闭断线客服端聊天室接口
|
||||||
* @param roomId 游客与客服聊天室id, 实际为游客邮箱
|
* @param userName 游客邮箱
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public void customerCloseRoom(String roomId){
|
public void customerCloseRoom(String userName){
|
||||||
messagingTemplate.convertAndSendToUser(
|
messagingTemplate.convertAndSendToUser(
|
||||||
webSocketConfig.getDefaultCustomerEmail(),
|
webSocketConfig.getDefaultCustomerEmail(),
|
||||||
Destination.QUEUE + Destination.QUEUE_CLOSE_ROOM + webSocketConfig.getDefaultCustomerEmail(),roomId);
|
Destination.QUEUE_CLOSE_ROOM + webSocketConfig.getDefaultCustomerEmail(),userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -98,14 +98,8 @@ public class PoolServiceImpl implements PoolService {
|
||||||
|
|
||||||
dto.setTotalDifficulty(PowerUnitUtils.difficultyFormat(info.getDifficulty()));
|
dto.setTotalDifficulty(PowerUnitUtils.difficultyFormat(info.getDifficulty()));
|
||||||
|
|
||||||
BigDecimal netPower;
|
|
||||||
if(pool.getBlockTime() != 0){
|
|
||||||
netPower = BigDecimal.valueOf(info.getDifficulty().longValue() * 2 ^ 32 / pool.getBlockTime());
|
|
||||||
}else{
|
|
||||||
netPower = info.getPower();
|
|
||||||
}
|
|
||||||
//全网算力 调用转换工具 动态转换为数值+单位
|
//全网算力 调用转换工具 动态转换为数值+单位
|
||||||
dto.setTotalPower(PowerUnitUtils.powerFormat(netPower,pool.getCoin()));
|
dto.setTotalPower(PowerUnitUtils.powerFormat(info.getPower(),pool.getCoin()));
|
||||||
//System.out.println("dto"+dto);
|
//System.out.println("dto"+dto);
|
||||||
}else {
|
}else {
|
||||||
System.out.println("未能从节点获取到信息");
|
System.out.println("未能从节点获取到信息");
|
||||||
|
@ -113,6 +107,7 @@ public class PoolServiceImpl implements PoolService {
|
||||||
|
|
||||||
BigDecimal price = redisService.getCacheObject(pool.getCoin() + "_price");
|
BigDecimal price = redisService.getCacheObject(pool.getCoin() + "_price");
|
||||||
dto.setPrice(price.toEngineeringString()+ " USD");
|
dto.setPrice(price.toEngineeringString()+ " USD");
|
||||||
|
dto.setHeight(info.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
//从enums中拿币种名、页面显示名、币种对应算法
|
//从enums中拿币种名、页面显示名、币种对应算法
|
||||||
|
@ -120,6 +115,7 @@ public class PoolServiceImpl implements PoolService {
|
||||||
dto.setName(pool.getName());
|
dto.setName(pool.getName());
|
||||||
dto.setAlgorithm(pool.getAlgorithm());
|
dto.setAlgorithm(pool.getAlgorithm());
|
||||||
|
|
||||||
|
|
||||||
//从池子算力统计表pool_stats拿对应矿池算力 30m
|
//从池子算力统计表pool_stats拿对应矿池算力 30m
|
||||||
//从实时表拿24h
|
//从实时表拿24h
|
||||||
double mhs = Convert.toDouble(poolMapper.getNowPoolDailyPower(pool.getMhs()+"_realv2"),0.0) * pool.getFac();
|
double mhs = Convert.toDouble(poolMapper.getNowPoolDailyPower(pool.getMhs()+"_realv2"),0.0) * pool.getFac();
|
||||||
|
|
|
@ -30,7 +30,6 @@ public class NodeRpc{
|
||||||
public static String getResult(String coin,String method,String[] params) {
|
public static String getResult(String coin,String method,String[] params) {
|
||||||
|
|
||||||
NodeConfig config = (NodeConfig) EnumUtils.get(NodeConfig.class, coin);
|
NodeConfig config = (NodeConfig) EnumUtils.get(NodeConfig.class, coin);
|
||||||
System.out.println("----------执行rpc接口调用");
|
|
||||||
String uri ="http://"+config.getIp()+":"+config.getHost();
|
String uri ="http://"+config.getIp()+":"+config.getHost();
|
||||||
|
|
||||||
String auth =config.getUser()+":"+config.getPwd();
|
String auth =config.getUser()+":"+config.getPwd();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<module>m2pool-file</module>
|
<module>m2pool-file</module>
|
||||||
<module>m2pool-oapi</module>
|
<module>m2pool-oapi</module>
|
||||||
<module>m2pool-chat</module>
|
<module>m2pool-chat</module>
|
||||||
|
<module>m2pool-manage</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue