update 优化 websocket 模块减少日志输出 增加登录推送

This commit is contained in:
疯狂的狮子Li
2023-11-02 13:56:39 +08:00
parent c5bc6a97c9
commit 51feaf7b99
3 changed files with 15 additions and 10 deletions

View File

@ -17,10 +17,12 @@ import org.dromara.common.core.domain.model.RegisterBody;
import org.dromara.common.core.domain.model.SocialLoginBody;
import org.dromara.common.core.utils.*;
import org.dromara.common.json.utils.JsonUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.social.config.properties.SocialLoginConfigProperties;
import org.dromara.common.social.config.properties.SocialProperties;
import org.dromara.common.social.utils.SocialUtils;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.common.websocket.utils.WebSocketUtils;
import org.dromara.system.domain.SysClient;
import org.dromara.system.domain.bo.SysTenantBo;
import org.dromara.system.domain.vo.SysTenantVo;
@ -39,6 +41,8 @@ import org.springframework.web.bind.annotation.*;
import java.net.URL;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* 认证
@ -60,6 +64,7 @@ public class AuthController {
private final ISysTenantService tenantService;
private final ISysSocialService socialUserService;
private final ISysClientService clientService;
private final ScheduledExecutorService scheduledExecutorService;
/**
@ -86,7 +91,13 @@ public class AuthController {
// 校验租户
loginService.checkTenant(loginBody.getTenantId());
// 登录
return R.ok(IAuthStrategy.login(body, client, grantType));
LoginVo loginVo = IAuthStrategy.login(body, client, grantType);
Long userId = LoginHelper.getUserId();
scheduledExecutorService.schedule(() -> {
WebSocketUtils.sendMessage(userId, "欢迎登录RuoYi-Vue-Plus后台管理系统");
}, 3, TimeUnit.SECONDS);
return R.ok(loginVo);
}
/**
@ -181,7 +192,7 @@ public class AuthController {
}
// 根据域名进行筛选
List<TenantListVo> list = StreamUtils.filter(voList, vo ->
StringUtils.equals(vo.getDomain(), host));
StringUtils.equals(vo.getDomain(), host));
// 返回对象
LoginTenantVo vo = new LoginTenantVo();
vo.setVoList(CollUtil.isNotEmpty(list) ? list : voList);