正在显示
1 个修改的文件
包含
14 行增加
和
16 行删除
@@ -14,6 +14,7 @@ import com.tianbo.warehouse.model.USERS; | @@ -14,6 +14,7 @@ import com.tianbo.warehouse.model.USERS; | ||
14 | import com.tianbo.warehouse.service.PermissionService; | 14 | import com.tianbo.warehouse.service.PermissionService; |
15 | import com.tianbo.warehouse.util.RedisUtils; | 15 | import com.tianbo.warehouse.util.RedisUtils; |
16 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
17 | +import org.apache.commons.lang.StringUtils; | ||
17 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
18 | import org.springframework.data.redis.core.RedisTemplate; | 19 | import org.springframework.data.redis.core.RedisTemplate; |
19 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
@@ -180,7 +181,7 @@ public class PermissionServiceImp implements PermissionService { | @@ -180,7 +181,7 @@ public class PermissionServiceImp implements PermissionService { | ||
180 | } | 181 | } |
181 | /** 批量删除 | 182 | /** 批量删除 |
182 | * | 183 | * |
183 | - * @param permissionId | 184 | + * @param permissionIds |
184 | * @return | 185 | * @return |
185 | */ | 186 | */ |
186 | @RedisCacheDelTarget(cacheKey = "com.tianbo.warehouse.service.imp.PermissionServiceImp") | 187 | @RedisCacheDelTarget(cacheKey = "com.tianbo.warehouse.service.imp.PermissionServiceImp") |
@@ -237,26 +238,23 @@ public class PermissionServiceImp implements PermissionService { | @@ -237,26 +238,23 @@ public class PermissionServiceImp implements PermissionService { | ||
237 | if(token != null && token.startsWith("Bearer ")) { | 238 | if(token != null && token.startsWith("Bearer ")) { |
238 | token = token.substring(7); // 7 是 "Bearer " 的长度 | 239 | token = token.substring(7); // 7 是 "Bearer " 的长度 |
239 | String userJsonStr = redisUtils.get(token); | 240 | String userJsonStr = redisUtils.get(token); |
240 | - USERS user = JSONObject.parseObject(userJsonStr, USERS.class); | ||
241 | - PERMISSION result = user.getPermissions().stream() | ||
242 | - .filter(permission -> "转关运抵申报申报".equals(permission.getName()) || url.equals(permission.getUrl())) | ||
243 | - .findFirst() | ||
244 | - .orElse(null); | ||
245 | - // 输出查询结果 | ||
246 | - if (result != null) { | ||
247 | - System.out.println("匹配到对应权限"); | ||
248 | - return true; | ||
249 | - } else { | ||
250 | - return false; | 241 | + if (StringUtils.isNotEmpty(userJsonStr)) { |
242 | + USERS user = JSONObject.parseObject(userJsonStr, USERS.class); | ||
243 | + PERMISSION result = user.getPermissions().stream() | ||
244 | + .filter(permission -> name.equals(permission.getName()) || url.equals(permission.getUrl())) | ||
245 | + .findFirst() | ||
246 | + .orElse(null); | ||
247 | + // 输出查询结果 | ||
248 | + if (result != null) { | ||
249 | + System.out.println("匹配到对应权限"); | ||
250 | + return true; | ||
251 | + } | ||
251 | } | 252 | } |
252 | - | ||
253 | - } else { | ||
254 | - // 处理未包含Bearer前缀的情况 | ||
255 | - return false; | ||
256 | } | 253 | } |
257 | }catch (Exception e){ | 254 | }catch (Exception e){ |
258 | return false; | 255 | return false; |
259 | } | 256 | } |
257 | + return false; | ||
260 | } | 258 | } |
261 | 259 | ||
262 | } | 260 | } |
-
请 注册 或 登录 后发表评论