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
977f9d13
Commit
977f9d13
authored
Mar 15, 2022
by
罗承锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限测试
parent
92e3ca66
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
0 deletions
+106
-0
service-manager/src/main/java/com/winsun/intercept/AuthConfigurationSupport.java
+32
-0
service-manager/src/main/java/com/winsun/intercept/AuthIntercept.java
+74
-0
No files found.
service-manager/src/main/java/com/winsun/intercept/AuthConfigurationSupport.java
0 → 100644
View file @
977f9d13
package
com
.
winsun
.
intercept
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author chengfengluo
* @date 2022-03-15 14:58
*/
@Slf4j
@Configuration
public
class
AuthConfigurationSupport
extends
WebMvcConfigurationSupport
{
@Autowired
private
AuthIntercept
authIntercept
;
@Override
protected
void
addInterceptors
(
InterceptorRegistry
registry
)
{
log
.
info
(
"配置拦截中"
);
List
<
String
>
s
=
new
ArrayList
<>();
s
.
add
(
"/login"
);
s
.
add
(
"/getPhoneCode"
);
registry
.
addInterceptor
(
authIntercept
).
excludePathPatterns
(
s
);
super
.
addInterceptors
(
registry
);
}
}
service-manager/src/main/java/com/winsun/intercept/AuthIntercept.java
0 → 100644
View file @
977f9d13
package
com
.
winsun
.
intercept
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.netflix.discovery.converters.Auto
;
import
com.winsun.auth.core.shiro.ShiroUser
;
import
com.winsun.item.core.shiro.ShiroKit
;
import
com.winsun.mapper.SysUserMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Map
;
/**
* @author chengfengluo
* @date 2022-03-15 14:47
*/
@Slf4j
@Component
public
class
AuthIntercept
extends
HandlerInterceptorAdapter
{
@Autowired
private
SysUserMapper
sysUserMapper
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
try
{
ShiroUser
user
=
ShiroKit
.
getUser
();
if
(
user
!=
null
)
{
log
.
info
(
"请求测试:"
+
JSON
.
toJSONString
(
user
));
}
else
{
log
.
error
(
"错误"
);
}
Integer
integer
=
sysUserMapper
.
selectCount
(
new
EntityWrapper
<>());
log
.
info
(
"总数:"
+
integer
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
super
.
preHandle
(
request
,
response
,
handler
);
}
@Override
public
void
postHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
ModelAndView
modelAndView
)
throws
Exception
{
try
{
ShiroUser
user
=
ShiroKit
.
getUser
();
if
(
user
!=
null
)
{
log
.
info
(
JSON
.
toJSONString
(
user
));
}
else
{
log
.
error
(
"错误"
);
}
Integer
integer
=
sysUserMapper
.
selectCount
(
new
EntityWrapper
<>());
log
.
info
(
"总数:"
+
integer
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
Map
<
String
,
Object
>
model
=
modelAndView
.
getModel
();
log
.
info
(
"结束信息: {}"
,
JSONObject
.
toJSONString
(
model
));
super
.
postHandle
(
request
,
response
,
handler
,
modelAndView
);
}
}
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