Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
c49b808f
Commit
c49b808f
authored
Apr 18, 2022
by
伍思炜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复漏洞
parent
d3606687
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
1 deletions
+128
-1
common/src/main/java/com/winsun/outSideSystem/IntelligenceSendOrders.java
+0
-0
service-manager/src/main/java/com/winsun/aop/AuthorityAspect.java
+127
-0
service-manager/src/main/java/com/winsun/utils/TreeNodeData.java
+1
-1
No files found.
common/src/main/java/com/winsun/outSideSystem/IntelligenceSendOrders.java
View file @
c49b808f
This diff is collapsed.
Click to expand it.
service-manager/src/main/java/com/winsun/aop/AuthorityAspect.java
0 → 100644
View file @
c49b808f
package
com
.
winsun
.
aop
;
import
com.alibaba.fastjson.JSONObject
;
import
com.winsun.auth.core.common.model.ResponseData
;
import
com.winsun.auth.core.shiro.ShiroUser
;
import
com.winsun.auth.core.support.HttpKit
;
import
com.winsun.auth.model.common.Menu
;
import
com.winsun.interfaces.PermissionVerification
;
import
com.winsun.mapper.SysUserMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
/**
* 基于服务层的权限切面
*
* @author Cocowwy
* @create 2021-11-11-13:59
*/
@Aspect
@Component
@Slf4j
public
class
AuthorityAspect
{
@Autowired
private
StringRedisTemplate
stringRedisTemplate
;
@Autowired
private
SysUserMapper
sysUserMapper
;
private
final
static
String
PERMISSION_VERIFICATION
=
"permissionVerification:"
;
private
final
static
Integer
CACHE_TIME
=
60
;
/**
* 对接口进行权限校验
*/
@Pointcut
(
"@annotation(com.winsun.interfaces.PermissionVerification)"
)
private
void
pointcut
()
{
}
@Around
(
"pointcut()"
)
public
Object
around
(
ProceedingJoinPoint
joinPoint
)
throws
Throwable
{
MethodSignature
signature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
PermissionVerification
permissionVerification
=
signature
.
getMethod
().
getDeclaredAnnotation
(
PermissionVerification
.
class
);
if
(
permissionVerification
!=
null
)
{
return
apiIdempotent
(
joinPoint
,
signature
);
}
Object
proceed
=
joinPoint
.
proceed
();
return
proceed
;
}
public
Object
apiIdempotent
(
ProceedingJoinPoint
joinPoint
,
MethodSignature
signature
)
throws
Throwable
{
ShiroUser
user
=
getShiroUser
();
/*if (user.getRoleNames().stream().anyMatch(roleName -> StringUtils.equalsAny(roleName, "超级管理员"))) {
Object proceed = joinPoint.proceed();
return proceed;
}*/
PermissionVerification
permissionVerification
=
signature
.
getMethod
().
getDeclaredAnnotation
(
PermissionVerification
.
class
);
if
(
""
.
equals
(
permissionVerification
.
value
()[
0
])
||
user
==
null
)
{
log
.
error
(
"无权限"
);
return
false
;
}
List
<
Integer
>
roleList
=
user
.
getRoleList
();
if
(
roleList
.
size
()
==
0
)
{
log
.
error
(
"无权限"
);
return
false
;
}
String
key
=
PERMISSION_VERIFICATION
+
getHttpServletRequest
().
getHeader
(
"Authorization"
);
String
[]
values
=
permissionVerification
.
value
();
String
s
=
stringRedisTemplate
.
opsForValue
().
get
(
key
);
List
<
Menu
>
roleMenu
=
null
;
if
(
StringUtils
.
isNotBlank
(
s
))
{
roleMenu
=
JSONObject
.
parseArray
(
s
,
Menu
.
class
);
}
else
{
roleMenu
=
sysUserMapper
.
getRoleMenu
(
roleList
);
stringRedisTemplate
.
opsForValue
().
set
(
key
,
JSONObject
.
toJSONString
(
roleMenu
),
CACHE_TIME
,
TimeUnit
.
SECONDS
);
}
if
(
roleMenu
==
null
||
roleMenu
.
isEmpty
())
{
return
false
;
}
for
(
String
value
:
values
)
{
for
(
Menu
menu
:
roleMenu
)
{
if
(
menu
==
null
||
StringUtils
.
isBlank
(
menu
.
getUrl
()))
{
continue
;
}
if
(
StringUtils
.
equals
(
menu
.
getUrl
(),
value
))
{
Object
proceed
=
joinPoint
.
proceed
();
return
proceed
;
}
}
}
return
ResponseData
.
error
(
"无权限"
);
}
protected
ShiroUser
getShiroUser
()
{
HttpServletRequest
httpServletRequest
=
this
.
getHttpServletRequest
();
Object
Attr
=
httpServletRequest
.
getAttribute
(
"user"
);
ShiroUser
user
=
(
ShiroUser
)
JSONObject
.
parseObject
(
Attr
.
toString
(),
ShiroUser
.
class
);
return
user
;
}
protected
HttpServletRequest
getHttpServletRequest
()
{
return
HttpKit
.
getRequest
();
}
}
service-manager/src/main/java/com/winsun/utils/TreeNodeData.java
View file @
c49b808f
...
@@ -75,7 +75,7 @@ public class TreeNodeData {
...
@@ -75,7 +75,7 @@ public class TreeNodeData {
TreeNode
treeNode7
=
new
TreeNode
(
7
,
"区域"
,
"order_region"
,
treeNode
);
TreeNode
treeNode7
=
new
TreeNode
(
7
,
"区域"
,
"order_region"
,
treeNode
);
TreeNode
treeNode8
=
new
TreeNode
(
8
,
"客户姓名"
,
"orderName"
,
treeNode
);
TreeNode
treeNode8
=
new
TreeNode
(
8
,
"客户姓名"
,
"orderName"
,
treeNode
);
TreeNode
treeNode9
=
new
TreeNode
(
9
,
"联系电话"
,
"orderPhone"
,
treeNode
);
TreeNode
treeNode9
=
new
TreeNode
(
9
,
"联系电话"
,
"orderPhone"
,
treeNode
);
TreeNode
treeNode10
=
new
TreeNode
(
10
,
"订单状态"
,
"status"
,
treeNode
);
TreeNode
treeNode10
=
new
TreeNode
(
10
,
"订单状态"
,
"
order_
status"
,
treeNode
);
TreeNode
treeNode11
=
new
TreeNode
(
11
,
"备注"
,
"order_customer_remarks"
,
treeNode
);
TreeNode
treeNode11
=
new
TreeNode
(
11
,
"备注"
,
"order_customer_remarks"
,
treeNode
);
TreeNode
treeNode12
=
new
TreeNode
(
12
,
"创建时间"
,
"orderDate"
,
treeNode
);
TreeNode
treeNode12
=
new
TreeNode
(
12
,
"创建时间"
,
"orderDate"
,
treeNode
);
TreeNode
treeNode13
=
new
TreeNode
(
13
,
"支付平台"
,
"ipay"
,
treeNode
);
TreeNode
treeNode13
=
new
TreeNode
(
13
,
"支付平台"
,
"ipay"
,
treeNode
);
...
...
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