From 258dcbb57aeb2084040c3ceb9dcb4d63ff99f5d7 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 26 Apr 2022 09:01:33 +0800 Subject: [PATCH] npe --- .../common/controller/DemandDataController.java | 5 ++++- .../renren/modules/security/user/SecurityUser.java | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/controller/DemandDataController.java b/renren-admin/src/main/java/io/renren/common/controller/DemandDataController.java index 1268f35a..671377e0 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/DemandDataController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/DemandDataController.java @@ -13,6 +13,7 @@ import io.renren.modules.activiti.service.ActProcessService; import io.renren.modules.activiti.service.ActRunningService; import io.renren.modules.demanData.dto.TDemandDataDTO; import io.renren.modules.demanData.service.TDemandDataService; +import io.renren.modules.security.user.SecurityUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.codehaus.jackson.map.ObjectMapper; @@ -29,7 +30,7 @@ import java.util.Map; @Api(tags = "能力需求") @RestController -@RequestMapping("/demand/center") +@RequestMapping("/demand_v2/center") public class DemandDataController { private static Logger logger = LoggerFactory.getLogger(ResourceMountController.class); @@ -58,6 +59,8 @@ public class DemandDataController { return new Result().error("联系管理员添加流程:" + key); } + logger.info(SecurityUser.getUser().toString()); + logger.info("---------------------------------------------------"); logger.info(JSONObject.toJSONString(tDemandDataDTO)); logger.info("####################################################"); diff --git a/renren-admin/src/main/java/io/renren/modules/security/user/SecurityUser.java b/renren-admin/src/main/java/io/renren/modules/security/user/SecurityUser.java index 3879dc26..f79d6583 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/user/SecurityUser.java +++ b/renren-admin/src/main/java/io/renren/modules/security/user/SecurityUser.java @@ -2,17 +2,20 @@ package io.renren.modules.security.user; import org.apache.shiro.SecurityUtils; import org.apache.shiro.subject.Subject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * 用户 - * */ public class SecurityUser { + private static Logger logger = LoggerFactory.getLogger(SecurityUser.class); public static Subject getSubject() { try { return SecurityUtils.getSubject(); - }catch (Exception e){ + } catch (Exception e) { + logger.info("获取用户失败:" + e.getMessage()); return null; } } @@ -22,12 +25,12 @@ public class SecurityUser { */ public static UserDetail getUser() { Subject subject = getSubject(); - if(subject == null){ + if (subject == null) { return new UserDetail(); } - UserDetail user = (UserDetail)subject.getPrincipal(); - if(user == null){ + UserDetail user = (UserDetail) subject.getPrincipal(); + if (user == null) { return new UserDetail(); }