Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
02062f31
Commit
02062f31
authored
Mar 13, 2020
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
通用http工具类
parent
ab992f48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
3 deletions
+59
-3
ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java
...src/main/java/com/ruoyi/common/utils/http/HttpHelper.java
+56
-0
ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
...yi/framework/interceptor/impl/SameUrlDataInterceptor.java
+3
-3
No files found.
ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java
0 → 100644
View file @
02062f31
package
com.ruoyi.common.utils.http
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.nio.charset.Charset
;
import
javax.servlet.ServletRequest
;
import
org.apache.commons.lang.exception.ExceptionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* 通用http工具封装
*
* @author ruoyi
*/
public
class
HttpHelper
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
HttpHelper
.
class
);
public
static
String
getBodyString
(
ServletRequest
request
)
{
StringBuilder
sb
=
new
StringBuilder
();
BufferedReader
reader
=
null
;
try
(
InputStream
inputStream
=
request
.
getInputStream
())
{
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
,
Charset
.
forName
(
"UTF-8"
)));
String
line
=
""
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
sb
.
append
(
line
);
}
}
catch
(
IOException
e
)
{
LOGGER
.
warn
(
"getBodyString出现问题!"
);
}
finally
{
if
(
reader
!=
null
)
{
try
{
reader
.
close
();
}
catch
(
IOException
e
)
{
LOGGER
.
error
(
ExceptionUtils
.
getFullStackTrace
(
e
));
}
}
}
return
sb
.
toString
();
}
}
ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
View file @
02062f31
...
...
@@ -26,7 +26,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
public
final
String
REPEAT_TIME
=
"repeatTime"
;
public
final
String
SESSION
_REPEAT_KEY
=
"repeatData"
;
public
final
String
CACHE
_REPEAT_KEY
=
"repeatData"
;
@Autowired
private
RedisCache
redisCache
;
...
...
@@ -62,7 +62,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
// 请求地址(作为存放session的key值)
String
url
=
request
.
getRequestURI
();
Object
sessionObj
=
redisCache
.
getCacheObject
(
SESSION
_REPEAT_KEY
);
Object
sessionObj
=
redisCache
.
getCacheObject
(
CACHE
_REPEAT_KEY
);
if
(
sessionObj
!=
null
)
{
Map
<
String
,
Object
>
sessionMap
=
(
Map
<
String
,
Object
>)
sessionObj
;
...
...
@@ -77,7 +77,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
}
Map
<
String
,
Object
>
cacheMap
=
new
HashMap
<
String
,
Object
>();
cacheMap
.
put
(
url
,
nowDataMap
);
redisCache
.
setCacheObject
(
SESSION
_REPEAT_KEY
,
cacheMap
,
intervalTime
,
TimeUnit
.
SECONDS
);
redisCache
.
setCacheObject
(
CACHE
_REPEAT_KEY
,
cacheMap
,
intervalTime
,
TimeUnit
.
SECONDS
);
return
false
;
}
...
...
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