Commit 07d4a7b6 by 韦华德

更新

parent bbe87011
...@@ -15,7 +15,8 @@ public class WebMvcConfig implements WebMvcConfigurer { ...@@ -15,7 +15,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(apiInterceptor) registry.addInterceptor(apiInterceptor)
.addPathPatterns("/single/**") .addPathPatterns("/single/**")
// .excludePathPatterns("/xxxx/**") .excludePathPatterns("/single/auth/login")
.excludePathPatterns("/single/user/login")
; ;
} }
......
...@@ -10,8 +10,10 @@ import com.zq.common.config.security.SecurityProperties; ...@@ -10,8 +10,10 @@ import com.zq.common.config.security.SecurityProperties;
import com.zq.common.context.ContextUtils; import com.zq.common.context.ContextUtils;
import com.zq.common.vo.ApiTokenVo; import com.zq.common.vo.ApiTokenVo;
import com.zq.common.vo.ResultVo; import com.zq.common.vo.ResultVo;
import com.zq.single.vo.UserInfoVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
...@@ -32,10 +34,13 @@ public class ApiInterceptor implements HandlerInterceptor { ...@@ -32,10 +34,13 @@ public class ApiInterceptor implements HandlerInterceptor {
log.debug("{}请求URI: {}", ip, request.getRequestURL()); log.debug("{}请求URI: {}", ip, request.getRequestURL());
String token = request.getHeader(properties.getHeader()); String token = request.getHeader(properties.getHeader());
ApiTokenVo tokenVo = redisUtils.getObj(BaseCacheKeys.appTokenKey(token), ApiTokenVo.class); if (StringUtils.isNotBlank(token)) {
token= token.replace(properties.getTokenStartWith(), "");
}
UserInfoVo tokenVo = (UserInfoVo) redisUtils.getObj(BaseCacheKeys.appTokenKey(token), ApiTokenVo.class);
if (tokenVo == null) { if (tokenVo == null) {
response.setStatus(HttpStatus.HTTP_UNAUTHORIZED); response.setStatus(HttpStatus.HTTP_UNAUTHORIZED);
ServletUtil.write(response, JSONUtil.toJsonStr(ResultVo.fail(401, "认证失败")), ContentType.JSON.getValue()); ServletUtil.write(response, JSONUtil.toJsonStr(ResultVo.fail(401, "Unauthorized")), ContentType.JSON.getValue());
return false; return false;
} }
......
...@@ -115,7 +115,6 @@ public class SysUserController { ...@@ -115,7 +115,6 @@ public class SysUserController {
userToken.setUsername(thisUser.getUsername()); userToken.setUsername(thisUser.getUsername());
String token = ApiTokenUtils.createToken(userToken, BaseCacheKeys.APP_TOKEN_EXPIRE_MINUTES); String token = ApiTokenUtils.createToken(userToken, BaseCacheKeys.APP_TOKEN_EXPIRE_MINUTES);
response.setHeader(properties.getHeader(), token); response.setHeader(properties.getHeader(), token);
String s= BaseCacheKeys.appTokenKey(token);
redisUtils.setObj(BaseCacheKeys.appTokenKey(token), userToken, BaseCacheKeys.APP_TOKEN_EXPIRE_MINUTES); redisUtils.setObj(BaseCacheKeys.appTokenKey(token), userToken, BaseCacheKeys.APP_TOKEN_EXPIRE_MINUTES);
return ResultVo.success(); return ResultVo.success();
...@@ -133,13 +132,17 @@ public class SysUserController { ...@@ -133,13 +132,17 @@ public class SysUserController {
@ApiOperation("单点登录用户管理列表") @ApiOperation("单点登录用户管理列表")
@PostMapping("/manageList") @PostMapping("/manageList")
public ResultVo manageList(@RequestBody SysUser sysUser) { public ResultVo manageList(@RequestBody SysUser sysUser) {
SysUser thisUser=sysUserService.getById(sysUser.getUserId()); LambdaQueryWrapper<SysUser> lambdaQueryWrapper=new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SysUser::getUsername,sysUser.getUsername());
List<SysUser> users=sysUserService.list(lambdaQueryWrapper);
AssertUtils.isTrue(users!=null && users.size()>0, "服务器繁忙请稍后再试");
SysUser thisUser=users.get(0);
if(!thisUser.getIsAdmin()){ if(!thisUser.getIsAdmin()){
return ResultVo.fail("不是管理员"); return ResultVo.fail("不是管理员");
} }
LambdaQueryWrapper<SysUser> lambdaQueryWrapper=new LambdaQueryWrapper<>();
List<SysUser> userList=sysUserService.list(lambdaQueryWrapper.eq(SysUser::getEnabled,1L)); List<SysUser> userList=sysUserService.list();
// AssertUtils.isTrue(blind > 0, "服务器繁忙请稍后再试");
return ResultVo.success(userList); return ResultVo.success(userList);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment