修改网关调用问题
This commit is contained in:
parent
e2254eaca2
commit
70c5bf42b8
13
pom.xml
13
pom.xml
|
|
@ -32,6 +32,7 @@
|
||||||
<springdoc.version>2.3.0</springdoc.version>
|
<springdoc.version>2.3.0</springdoc.version>
|
||||||
<commons-lang3.version>3.14.0</commons-lang3.version>
|
<commons-lang3.version>3.14.0</commons-lang3.version>
|
||||||
<junit-jupiter.version>5.9.3</junit-jupiter.version>
|
<junit-jupiter.version>5.9.3</junit-jupiter.version>
|
||||||
|
<loadbalancer.version>4.0.4</loadbalancer.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
@ -70,6 +71,12 @@
|
||||||
<version>${mybatis-plus.version}</version>
|
<version>${mybatis-plus.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
|
<version>${loadbalancer.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- JJWT -->
|
<!-- JJWT -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
|
@ -225,6 +232,12 @@
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
|
<version>${loadbalancer.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.core.userdetails.User;
|
import org.springframework.security.core.userdetails.User;
|
||||||
|
import com.tacit.common.utils.AesPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
|
|
@ -59,4 +61,9 @@ public class SecurityConfig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PasswordEncoder passwordEncoder() {
|
||||||
|
return new AesPasswordEncoder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.tacit.admin.service.UserService;
|
||||||
import com.tacit.common.entity.ResponseResult;
|
import com.tacit.common.entity.ResponseResult;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -15,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
@Tag(name = "认证管理", description = "登录注册相关接口")
|
@Tag(name = "认证管理", description = "登录注册相关接口")
|
||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@Operation(summary = "用户登录", description = "用户登录获取JWT令牌")
|
@Operation(summary = "用户登录", description = "用户登录获取JWT令牌")
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.tacit.admin.service.UserService;
|
||||||
import com.tacit.common.entity.ResponseResult;
|
import com.tacit.common.entity.ResponseResult;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||||
@Tag(name = "用户管理", description = "用户管理相关接口")
|
@Tag(name = "用户管理", description = "用户管理相关接口")
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@Operation(summary = "获取所有用户", description = "获取系统中所有用户列表")
|
@Operation(summary = "获取所有用户", description = "获取系统中所有用户列表")
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import com.tacit.admin.entity.dto.RegisterRequest;
|
||||||
import com.tacit.admin.mapper.UserMapper;
|
import com.tacit.admin.mapper.UserMapper;
|
||||||
import com.tacit.admin.service.UserService;
|
import com.tacit.admin.service.UserService;
|
||||||
import com.tacit.common.utils.JwtUtils;
|
import com.tacit.common.utils.JwtUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -20,10 +20,10 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -76,7 +76,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new RuntimeException("用户名或密码错误");
|
throw new RuntimeException("用户名或密码错误");
|
||||||
}
|
}
|
||||||
|
System.out.println(passwordEncoder.encode("admin123"));
|
||||||
// 验证密码
|
// 验证密码
|
||||||
if (!passwordEncoder.matches(loginRequest.getPassword(), user.getPassword())) {
|
if (!passwordEncoder.matches(loginRequest.getPassword(), user.getPassword())) {
|
||||||
throw new RuntimeException("用户名或密码错误");
|
throw new RuntimeException("用户名或密码错误");
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.tacit.common.entity.ResponseResult;
|
||||||
import com.tacit.common.feign.AdminFeignClient;
|
import com.tacit.common.feign.AdminFeignClient;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
@ -21,10 +21,10 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@Tag(name = "认证管理", description = "用户认证相关接口")
|
@Tag(name = "认证管理", description = "用户认证相关接口")
|
||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private AdminFeignClient adminFeignClient;
|
private AdminFeignClient adminFeignClient;
|
||||||
|
|
||||||
@Operation(summary = "用户登录", description = "用户登录接口")
|
@Operation(summary = "用户登录", description = "用户登录接口")
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.tacit.app.service.UserService;
|
||||||
import com.tacit.common.entity.ResponseResult;
|
import com.tacit.common.entity.ResponseResult;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
@Tag(name = "用户管理", description = "用户相关接口")
|
@Tag(name = "用户管理", description = "用户相关接口")
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@Operation(summary = "获取用户信息", description = "根据用户ID获取用户信息")
|
@Operation(summary = "获取用户信息", description = "根据用户ID获取用户信息")
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import com.tacit.app.service.UserService;
|
||||||
import com.tacit.common.constant.CommonConstant;
|
import com.tacit.common.constant.CommonConstant;
|
||||||
import com.tacit.common.exception.BusinessException;
|
import com.tacit.common.exception.BusinessException;
|
||||||
import com.tacit.common.utils.JwtUtils;
|
import com.tacit.common.utils.JwtUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -21,10 +21,10 @@ import java.util.Map;
|
||||||
@Service
|
@Service
|
||||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -63,12 +63,6 @@
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring Cloud LoadBalancer - 用于 Gateway 的 lb:// 协议 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,4 @@ public class SecurityConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue