diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 7cd5e77a..b7a67402 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -29,6 +29,12 @@ spring-web + + + org.apache.shiro + shiro-core + + com.github.pagehelper @@ -78,7 +84,7 @@ - + javax.servlet javax.servlet-api diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java index 52f09fcb..3b6f098c 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java @@ -1,6 +1,13 @@ package com.ruoyi.common.utils.security; +import java.beans.BeanInfo; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.subject.Subject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.ruoyi.common.constant.PermissionConstants; import com.ruoyi.common.utils.MessageUtils; @@ -11,6 +18,8 @@ import com.ruoyi.common.utils.MessageUtils; */ public class PermissionUtils { + private static final Logger log = LoggerFactory.getLogger(PermissionUtils.class); + /** * 查看数据的权限 */ @@ -74,4 +83,36 @@ public class PermissionUtils } return msg; } + + /** + * 返回用户属性值 + * + * @param property 属性名称 + * @return 用户属性值 + */ + public static Object getPrincipalProperty(String property) + { + Subject subject = SecurityUtils.getSubject(); + if (subject != null) + { + Object principal = subject.getPrincipal(); + try + { + BeanInfo bi = Introspector.getBeanInfo(principal.getClass()); + for (PropertyDescriptor pd : bi.getPropertyDescriptors()) + { + if (pd.getName().equals(property) == true) + { + return pd.getReadMethod().invoke(principal, (Object[]) null); + } + } + } + catch (Exception e) + { + log.error("Error reading property [{}] from principal of type [{}]", property, + principal.getClass().getName()); + } + } + return null; + } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java index 17a793af..0123ddb1 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java @@ -2,6 +2,7 @@ package com.ruoyi.framework.web.service; import org.apache.shiro.SecurityUtils; import org.springframework.stereotype.Service; +import com.ruoyi.common.utils.security.PermissionUtils; /** * RuoYi首创 js调用 thymeleaf 实现按钮权限可见性 @@ -43,4 +44,14 @@ public class PermissionService return SecurityUtils.getSubject().hasRole(role); } + /** + * 返回用户属性值 + * + * @param property 属性名称 + * @return 用户属性值 + */ + public Object getPrincipalProperty(String property) + { + return PermissionUtils.getPrincipalProperty(property); + } } diff --git a/ruoyi-generator/pom.xml b/ruoyi-generator/pom.xml index f9f49f35..4d80dced 100644 --- a/ruoyi-generator/pom.xml +++ b/ruoyi-generator/pom.xml @@ -17,12 +17,6 @@ - - - org.apache.shiro - shiro-core - - org.apache.velocity diff --git a/ruoyi-quartz/pom.xml b/ruoyi-quartz/pom.xml index 0ecbc0e3..4abca0a6 100644 --- a/ruoyi-quartz/pom.xml +++ b/ruoyi-quartz/pom.xml @@ -17,12 +17,6 @@ - - - org.apache.shiro - shiro-core - - org.quartz-scheduler diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/add.html b/ruoyi-quartz/src/main/resources/templates/monitor/job/add.html index 819fa57a..7333254a 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/add.html +++ b/ruoyi-quartz/src/main/resources/templates/monitor/job/add.html @@ -6,6 +6,7 @@
+
diff --git a/ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html b/ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html index da0dfc90..67911460 100644 --- a/ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html +++ b/ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html @@ -7,6 +7,7 @@
+