gateway tomcat去除
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package org.xyzh.system.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -15,15 +20,22 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.xyzh.api.auth.service.AuthService;
|
||||
import org.xyzh.api.system.service.GuestService;
|
||||
import org.xyzh.api.system.service.ModulePermissionService;
|
||||
import org.xyzh.api.system.vo.PermissionVO;
|
||||
import org.xyzh.common.core.domain.LoginDomain;
|
||||
import org.xyzh.common.core.domain.LoginParam;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.page.PageRequest;
|
||||
import org.xyzh.common.dto.sys.TbGuestDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysPermissionDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysUserDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysUserInfoDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysUserRoleDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysViewDTO;
|
||||
import org.xyzh.common.utils.id.IdUtil;
|
||||
import org.xyzh.common.utils.validation.ValidationUtils;
|
||||
import org.xyzh.common.auth.utils.JwtTokenUtil;
|
||||
import org.xyzh.common.redis.service.RedisService;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -48,6 +60,15 @@ public class GuestController {
|
||||
@DubboReference(version = "1.0.0", group = "auth", timeout = 5000, check = false, retries = 0)
|
||||
private AuthService authService;
|
||||
|
||||
@DubboReference(version = "1.0.0", group = "system", timeout = 5000, check = false, retries = 0)
|
||||
private ModulePermissionService modulePermissionService;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
|
||||
@PostMapping
|
||||
public ResultDomain<TbGuestDTO> createGuest(TbGuestDTO guest) {
|
||||
@@ -191,8 +212,53 @@ public class GuestController {
|
||||
userInfoDTO.setUsername(guest.getName());
|
||||
loginDomain.setUserInfo(userInfoDTO);
|
||||
|
||||
// 设置角色信息
|
||||
List<TbSysUserRoleDTO> userRoles = new ArrayList<>();
|
||||
TbSysUserRoleDTO userRole = new TbSysUserRoleDTO();
|
||||
userRole.setUserId(guest.getUserId());
|
||||
userRole.setRoleId("role_guest");
|
||||
userRole.setDeptId("dept_root");
|
||||
userRoles.add(userRole);
|
||||
loginDomain.setUserRoles(userRoles);
|
||||
|
||||
// 获取用户权限信息
|
||||
List<TbSysPermissionDTO> userPermissions = new ArrayList<>();
|
||||
List<TbSysViewDTO> userViews = new ArrayList<>();
|
||||
|
||||
ResultDomain<PermissionVO> permissionsResult = modulePermissionService.getUserPermissions(guest.getUserId());
|
||||
if (permissionsResult.getSuccess() && permissionsResult.getDataList() != null) {
|
||||
for (PermissionVO permission : permissionsResult.getDataList()) {
|
||||
if (permission.getPermissionId() != null) {
|
||||
TbSysPermissionDTO permissionDTO = PermissionVO.toPermissionDTO(permission);
|
||||
if (permissionDTO != null) {
|
||||
userPermissions.add(permissionDTO);
|
||||
}
|
||||
}
|
||||
if (permission.getViewId() != null) {
|
||||
TbSysViewDTO viewDTO = PermissionVO.toViewDTO(permission);
|
||||
if (viewDTO != null) {
|
||||
userViews.add(viewDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
loginDomain.setUserPermissions(userPermissions);
|
||||
loginDomain.setUserViews(userViews);
|
||||
|
||||
loginDomain.setLoginType("wechat_miniprogram");
|
||||
|
||||
// 生成 JWT Token
|
||||
String token = jwtTokenUtil.generateToken(loginDomain);
|
||||
loginDomain.setToken(token);
|
||||
|
||||
// 将登录信息存储到 Redis(24小时有效期)
|
||||
String loginKey = "login:token:" + token;
|
||||
redisService.set(loginKey, JSON.toJSONString(loginDomain), 24, TimeUnit.HOURS);
|
||||
|
||||
// 存储用户登录状态
|
||||
String userLoginKey = "login:user:" + guest.getUserId();
|
||||
redisService.set(userLoginKey, token, 24, TimeUnit.HOURS);
|
||||
|
||||
return loginDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@ import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.page.PageDomain;
|
||||
import org.xyzh.common.core.page.PageRequest;
|
||||
import org.xyzh.common.dto.sys.TbGuestDTO;
|
||||
import org.xyzh.common.dto.sys.TbSysUserRoleDTO;
|
||||
import org.xyzh.system.mapper.user.TbGuestMapper;
|
||||
import org.xyzh.system.mapper.user.TbSysUserRoleMapper;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,10 +38,22 @@ public class GuestServiceImpl implements GuestService{
|
||||
@Autowired
|
||||
private TbGuestMapper guestMapper;
|
||||
|
||||
@Autowired
|
||||
private TbSysUserRoleMapper userRoleMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResultDomain<TbGuestDTO> createGuest(TbGuestDTO guest) {
|
||||
guestMapper.insertGuest(guest);
|
||||
|
||||
// 绑定访客角色(role_guest)
|
||||
TbSysUserRoleDTO userRole = new TbSysUserRoleDTO();
|
||||
userRole.setUserId(guest.getUserId());
|
||||
userRole.setRoleId("role_guest");
|
||||
userRole.setDeptId("dept_root");
|
||||
userRole.setCreateTime(new Date());
|
||||
userRoleMapper.insertUserRole(userRole);
|
||||
|
||||
return ResultDomain.success("创建成功",guest);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,35 +4,34 @@ server:
|
||||
servlet:
|
||||
context-path: /urban-lifeline/system
|
||||
# ================== Auth ====================
|
||||
urban-lifeline:
|
||||
auth:
|
||||
enabled: true
|
||||
auth:
|
||||
enabled: true
|
||||
gateway-mode: true
|
||||
# 认证接口:可以按服务自定义
|
||||
login-path: /urban-lifeline/auth/login
|
||||
logout-path: /urban-lifeline/auth/logout
|
||||
captcha-path: /urban-lifeline/auth/captcha
|
||||
refresh-path: /urban-lifeline/auth/refresh
|
||||
|
||||
# 认证接口:可以按服务自定义
|
||||
login-path: /urban-lifeline/auth/login
|
||||
logout-path: /urban-lifeline/auth/logout
|
||||
captcha-path: /urban-lifeline/auth/captcha
|
||||
refresh-path: /urban-lifeline/auth/refresh
|
||||
# 通用白名单(非认证接口)
|
||||
whitelist:
|
||||
# Swagger/OpenAPI 文档相关(建议不带 context-path)
|
||||
- /swagger-ui/**
|
||||
- /swagger-ui.html
|
||||
- /v3/api-docs/**
|
||||
- /webjars/**
|
||||
|
||||
# 通用白名单(非认证接口)
|
||||
whitelist:
|
||||
# Swagger/OpenAPI 文档相关(建议不带 context-path)
|
||||
- /swagger-ui/**
|
||||
- /swagger-ui.html
|
||||
- /v3/api-docs/**
|
||||
- /webjars/**
|
||||
# 静态资源
|
||||
- /favicon.ico
|
||||
- /error
|
||||
|
||||
# 静态资源
|
||||
- /favicon.ico
|
||||
- /error
|
||||
|
||||
# 健康检查
|
||||
- /actuator/health
|
||||
- /actuator/info
|
||||
|
||||
# 其他需要放行的路径
|
||||
# - /public/**
|
||||
# - /api/public/**
|
||||
# 健康检查
|
||||
- /actuator/health
|
||||
- /actuator/info
|
||||
|
||||
# 其他需要放行的路径
|
||||
# - /public/**
|
||||
# - /api/public/**
|
||||
|
||||
|
||||
# ================== Security ==================
|
||||
|
||||
@@ -4,35 +4,35 @@ server:
|
||||
# servlet:
|
||||
# context-path: /urban-lifeline/system # 微服务架构下,context-path由Gateway管理
|
||||
# ================== Auth ====================
|
||||
urban-lifeline:
|
||||
auth:
|
||||
enabled: true
|
||||
|
||||
# 认证接口:可以按服务自定义
|
||||
login-path: /urban-lifeline/auth/login
|
||||
logout-path: /urban-lifeline/auth/logout
|
||||
captcha-path: /urban-lifeline/auth/captcha
|
||||
refresh-path: /urban-lifeline/auth/refresh
|
||||
auth:
|
||||
enabled: true
|
||||
gateway-mode: true
|
||||
# 认证接口:可以按服务自定义
|
||||
login-path: /urban-lifeline/auth/login
|
||||
logout-path: /urban-lifeline/auth/logout
|
||||
captcha-path: /urban-lifeline/auth/captcha
|
||||
refresh-path: /urban-lifeline/auth/refresh
|
||||
|
||||
# 通用白名单(非认证接口)
|
||||
whitelist:
|
||||
# Swagger/OpenAPI 文档相关(建议不带 context-path)
|
||||
- /swagger-ui/**
|
||||
- /swagger-ui.html
|
||||
- /v3/api-docs/**
|
||||
- /webjars/**
|
||||
# 通用白名单(非认证接口)
|
||||
whitelist:
|
||||
# Swagger/OpenAPI 文档相关(建议不带 context-path)
|
||||
- /swagger-ui/**
|
||||
- /swagger-ui.html
|
||||
- /v3/api-docs/**
|
||||
- /webjars/**
|
||||
|
||||
# 静态资源
|
||||
- /favicon.ico
|
||||
- /error
|
||||
# 静态资源
|
||||
- /favicon.ico
|
||||
- /error
|
||||
|
||||
# 健康检查
|
||||
- /actuator/health
|
||||
- /actuator/info
|
||||
|
||||
# 其他需要放行的路径
|
||||
# - /public/**
|
||||
# - /api/public/**
|
||||
# 健康检查
|
||||
- /actuator/health
|
||||
- /actuator/info
|
||||
|
||||
# 其他需要放行的路径
|
||||
# - /public/**
|
||||
# - /api/public/**
|
||||
|
||||
security:
|
||||
aes:
|
||||
|
||||
Reference in New Issue
Block a user