Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yaru
fgqyxxlr
Commits
f96113d5
Commit
f96113d5
authored
May 15, 2019
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增getPrincipalProperty方法,用于前端及其他模块获取当前用户信息
parent
bddb5024
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
13 deletions
+61
-13
ruoyi-common/pom.xml
+7
-1
ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java
+41
-0
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java
+11
-0
ruoyi-generator/pom.xml
+0
-6
ruoyi-quartz/pom.xml
+0
-6
ruoyi-quartz/src/main/resources/templates/monitor/job/add.html
+1
-0
ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html
+1
-0
No files found.
ruoyi-common/pom.xml
View file @
f96113d5
...
...
@@ -29,6 +29,12 @@
<artifactId>
spring-web
</artifactId>
</dependency>
<!--Shiro核心框架 -->
<dependency>
<groupId>
org.apache.shiro
</groupId>
<artifactId>
shiro-core
</artifactId>
</dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>
com.github.pagehelper
</groupId>
...
...
@@ -78,7 +84,7 @@
</dependency>
<!-- servlet包 -->
<dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
</dependency>
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/security/PermissionUtils.java
View file @
f96113d5
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
;
}
}
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java
View file @
f96113d5
...
...
@@ -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
);
}
}
ruoyi-generator/pom.xml
View file @
f96113d5
...
...
@@ -17,12 +17,6 @@
<dependencies>
<!--Shiro核心框架 -->
<dependency>
<groupId>
org.apache.shiro
</groupId>
<artifactId>
shiro-core
</artifactId>
</dependency>
<!--velocity代码生成使用模板 -->
<dependency>
<groupId>
org.apache.velocity
</groupId>
...
...
ruoyi-quartz/pom.xml
View file @
f96113d5
...
...
@@ -17,12 +17,6 @@
<dependencies>
<!--Shiro核心框架 -->
<dependency>
<groupId>
org.apache.shiro
</groupId>
<artifactId>
shiro-core
</artifactId>
</dependency>
<!-- 定时任务 -->
<dependency>
<groupId>
org.quartz-scheduler
</groupId>
...
...
ruoyi-quartz/src/main/resources/templates/monitor/job/add.html
View file @
f96113d5
...
...
@@ -6,6 +6,7 @@
<body
class=
"white-bg"
>
<div
class=
"wrapper wrapper-content animated fadeInRight ibox-content"
>
<form
class=
"form-horizontal m"
id=
"form-job-add"
>
<input
type=
"hidden"
name=
"createBy"
th:value=
"${@permission.getPrincipalProperty('loginName')}"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
任务名称:
</label>
<div
class=
"col-sm-8"
>
...
...
ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html
View file @
f96113d5
...
...
@@ -7,6 +7,7 @@
<div
class=
"wrapper wrapper-content animated fadeInRight ibox-content"
>
<form
class=
"form-horizontal m"
id=
"form-job-edit"
th:object=
"${job}"
>
<input
id=
"jobId"
name=
"jobId"
type=
"hidden"
th:field=
"*{jobId}"
/>
<input
type=
"hidden"
name=
"updateBy"
th:value=
"${@permission.getPrincipalProperty('loginName')}"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
任务名称:
</label>
<div
class=
"col-sm-8"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment