| | |
| | | package org.dromara.web.controller; |
| | | |
| | | import cn.dev33.satoken.annotation.SaIgnore; |
| | | import cn.dev33.satoken.exception.NotLoginException; |
| | | import cn.hutool.core.codec.Base64; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | 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.sse.dto.SseMessageDto; |
| | | import org.dromara.common.sse.utils.SseMessageUtils; |
| | | import org.dromara.common.tenant.helper.TenantHelper; |
| | | import org.dromara.common.websocket.dto.WebSocketMessageDto; |
| | | import org.dromara.common.websocket.utils.WebSocketUtils; |
| | | import org.dromara.system.domain.bo.SysTenantBo; |
| | | import org.dromara.system.domain.vo.SysClientVo; |
| | | import org.dromara.system.domain.vo.SysTenantVo; |
| | |
| | | |
| | | Long userId = LoginHelper.getUserId(); |
| | | scheduledExecutorService.schedule(() -> { |
| | | WebSocketMessageDto dto = new WebSocketMessageDto(); |
| | | SseMessageDto dto = new SseMessageDto(); |
| | | dto.setMessage("欢迎登录RuoYi-Vue-Plus后台管理系统"); |
| | | dto.setSessionKeys(List.of(userId)); |
| | | WebSocketUtils.publishMessage(dto); |
| | | }, 3, TimeUnit.SECONDS); |
| | | dto.setUserIds(List.of(userId)); |
| | | SseMessageUtils.publishMessage(dto); |
| | | }, 5, TimeUnit.SECONDS); |
| | | return R.ok(loginVo); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/tenant/list") |
| | | public R<LoginTenantVo> tenantList(HttpServletRequest request) throws Exception { |
| | | // 返回对象 |
| | | LoginTenantVo result = new LoginTenantVo(); |
| | | boolean enable = TenantHelper.isEnable(); |
| | | result.setTenantEnabled(enable); |
| | | // 如果未开启租户这直接返回 |
| | | if (!enable) { |
| | | return R.ok(result); |
| | | } |
| | | |
| | | List<SysTenantVo> tenantList = tenantService.queryList(new SysTenantBo()); |
| | | List<TenantListVo> voList = MapstructUtils.convert(tenantList, TenantListVo.class); |
| | | try { |
| | | // 如果只超管返回所有租户 |
| | | if (LoginHelper.isSuperAdmin()) { |
| | | result.setVoList(voList); |
| | | return R.ok(result); |
| | | } |
| | | } catch (NotLoginException ignored) { |
| | | } |
| | | |
| | | // 获取域名 |
| | | String host; |
| | | String referer = request.getHeader("referer"); |
| | |
| | | // 根据域名进行筛选 |
| | | List<TenantListVo> list = StreamUtils.filter(voList, vo -> |
| | | StringUtils.equals(vo.getDomain(), host)); |
| | | // 返回对象 |
| | | LoginTenantVo vo = new LoginTenantVo(); |
| | | vo.setVoList(CollUtil.isNotEmpty(list) ? list : voList); |
| | | vo.setTenantEnabled(TenantHelper.isEnable()); |
| | | return R.ok(vo); |
| | | result.setVoList(CollUtil.isNotEmpty(list) ? list : voList); |
| | | return R.ok(result); |
| | | } |
| | | |
| | | } |