diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SpuController.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SpuController.java index 70019c8e6..fd70edb75 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SpuController.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SpuController.java @@ -44,7 +44,7 @@ public class SpuController { } @ApiOperation(value = "获取秒杀商品列表") - @GetMapping("/seckilling_list") + @GetMapping("/seckillList") public Result> listSeckillingSpu() { List list = spuService.listSeckillingSpu(); return Result.success(list); diff --git a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuServiceImpl.java b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuServiceImpl.java index 803aa6e33..4721237c0 100644 --- a/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuServiceImpl.java +++ b/mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsSpuServiceImpl.java @@ -162,8 +162,8 @@ public class PmsSpuServiceImpl extends ServiceImpl impleme } // 添加用户浏览历史记录 - Long loginUserId = SecurityUtils.getMemberId(); - if (loginUserId != null) { + Long memberId = SecurityUtils.getMemberId(); + if (memberId != null) { ProductHistoryVO vo = new ProductHistoryVO(); vo.setId(goodsInfo.getId()); vo.setName(goodsInfo.getName()); diff --git a/youlai-common/common-security/src/main/java/com/youlai/common/security/util/SecurityUtils.java b/youlai-common/common-security/src/main/java/com/youlai/common/security/util/SecurityUtils.java index d67b9eed9..4544b8414 100644 --- a/youlai-common/common-security/src/main/java/com/youlai/common/security/util/SecurityUtils.java +++ b/youlai-common/common-security/src/main/java/com/youlai/common/security/util/SecurityUtils.java @@ -70,7 +70,7 @@ public class SecurityUtils { */ public static Set getRoles() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (authentication!=null && CollectionUtil.isNotEmpty(authentication.getAuthorities())) { + if (authentication != null && CollectionUtil.isNotEmpty(authentication.getAuthorities())) { Set roles = authentication.getAuthorities() .stream() .map(item -> StrUtil.removePrefix(item.getAuthority(), "ROLE_")) @@ -111,8 +111,13 @@ public class SecurityUtils { public static Map getTokenAttributes() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - JwtAuthenticationToken jwtAuthenticationToken = (JwtAuthenticationToken) authentication; - Map tokenAttributes = jwtAuthenticationToken.getTokenAttributes(); - return tokenAttributes; + if (authentication != null) { + if (authentication instanceof JwtAuthenticationToken) { + JwtAuthenticationToken jwtAuthenticationToken = (JwtAuthenticationToken) authentication; + Map tokenAttributes = jwtAuthenticationToken.getTokenAttributes(); + return tokenAttributes; + } + } + return Collections.EMPTY_MAP; } }