From 9bfa420a764f19750cbd91df897fc6ae6fd0f1cc Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期一, 09 八月 2021 09:55:50 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev --- ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java | 34 ++++++++++++++++++++++++++++++++-- 1 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java index bdcc9eb..1a20d60 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java @@ -9,11 +9,41 @@ /** * 瀹夊叏鏈嶅姟宸ュ叿绫� - * + * * @author ruoyi */ public class SecurityUtils { + /** + * 鐢ㄦ埛ID + **/ + public static Long getUserId() + { + try + { + return getLoginUser().getUserId(); + } + catch (Exception e) + { + throw new CustomException("鑾峰彇鐢ㄦ埛ID寮傚父", HttpStatus.UNAUTHORIZED); + } + } + + /** + * 鑾峰彇閮ㄩ棬ID + **/ + public static Long getDeptId() + { + try + { + return getLoginUser().getDeptId(); + } + catch (Exception e) + { + throw new CustomException("鑾峰彇閮ㄩ棬ID寮傚父", HttpStatus.UNAUTHORIZED); + } + } + /** * 鑾峰彇鐢ㄦ埛璐︽埛 **/ @@ -79,7 +109,7 @@ /** * 鏄惁涓虹鐞嗗憳 - * + * * @param userId 鐢ㄦ埛ID * @return 缁撴灉 */ -- Gitblit v1.9.3