mirror of
https://github.com/suyiiyii/SIMS.git
synced 2025-06-05 13:36:12 +08:00
拦截器ok
This commit is contained in:
parent
efeabfc238
commit
c5358cd33e
@ -19,7 +19,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
|
|||||||
protected void addInterceptors(InterceptorRegistry registry) {
|
protected void addInterceptors(InterceptorRegistry registry) {
|
||||||
registry.addInterceptor(jwtInterceptor())
|
registry.addInterceptor(jwtInterceptor())
|
||||||
.addPathPatterns("/**")
|
.addPathPatterns("/**")
|
||||||
.excludePathPatterns("/login"); // 排除不需要验证的路径
|
.excludePathPatterns("/user/login"); // 排除不需要验证的路径
|
||||||
super.addInterceptors(registry);
|
super.addInterceptors(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class JwtInterceptor implements HandlerInterceptor {
|
|||||||
throw new ServiceException("401", "请登录");
|
throw new ServiceException("401", "请登录");
|
||||||
}
|
}
|
||||||
|
|
||||||
User user = userMapper.selectByUserId(Integer.parseInt(userId));
|
User user = userMapper.selectById(Integer.parseInt(userId));
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new ServiceException("401", "请登录");
|
throw new ServiceException("401", "请登录");
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,13 @@ public interface UserMapper extends BaseMapper<User> {
|
|||||||
@Select("SELECT id, user_id, username, password, name, email, `group` from user WHERE user_id = #{userId}")
|
@Select("SELECT id, user_id, username, password, name, email, `group` from user WHERE user_id = #{userId}")
|
||||||
User selectByUserId(Integer userId);
|
User selectByUserId(Integer userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据iD查询用户信息
|
||||||
|
* @param
|
||||||
|
* @return 用户对象
|
||||||
|
*/
|
||||||
|
@Select("SELECT id, user_id, username, password, name, email, `group` from user WHERE id = #{Id}")
|
||||||
|
User selectById(Integer Id);
|
||||||
/**
|
/**
|
||||||
* 查询所有用户信息
|
* 查询所有用户信息
|
||||||
* @return 用户列表
|
* @return 用户列表
|
||||||
|
Loading…
x
Reference in New Issue
Block a user