Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JeeSpringCloud
Commits
7fa8137a
Commit
7fa8137a
authored
Oct 22, 2018
by
HuangBingGui
Browse files
no commit message
parent
6c859da2
Changes
202
Hide whitespace changes
Inline
Side-by-side
JeeSpringCloud/src/main/java/com/jeespring/common/redis/RedisUtils.java
View file @
7fa8137a
...
...
@@ -52,17 +52,19 @@ public class RedisUtils {
private
StringRedisTemplate
stringRedisTemplate
;
public
static
String
getExpire
(){
if
(
expireTime
!=
null
)
return
String
.
valueOf
(
expireTime
/
60
)+
"分钟"
;
else
if
(
expireTime
!=
null
)
{
return
String
.
valueOf
(
expireTime
/
60
)
+
"分钟"
;
}
else
{
return
"0分钟"
;
}
}
public
static
String
getExpireShiro
(){
if
(
expireTimeShiro
!=
null
)
return
String
.
valueOf
(
expireTimeShiro
/
60
)+
"分钟"
;
else
if
(
expireTimeShiro
!=
null
)
{
return
String
.
valueOf
(
expireTimeShiro
/
60
)
+
"分钟"
;
}
else
{
return
"0分钟"
;
}
}
public
static
String
getKey
(
String
className
,
String
keyName
,
String
keyId
){
...
...
@@ -147,10 +149,13 @@ public class RedisUtils {
return
;
}
try
{
if
(
pattern
==
null
)
pattern
=
""
;
if
(
pattern
==
null
)
{
pattern
=
""
;
}
Set
<
String
>
keys
=
getKyes
(
pattern
);
if
(
keys
.
size
()
>
0
)
if
(
keys
.
size
()
>
0
)
{
redisTemplate
.
delete
(
keys
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"RedisUtils removePattern:"
+
RUN_MESSAGE
+
e
.
getMessage
(),
RUN_MESSAGE
+
e
.
getMessage
());
}
...
...
@@ -162,7 +167,9 @@ public class RedisUtils {
return
;
}
try
{
if
(
pattern
==
null
)
pattern
=
""
;
if
(
pattern
==
null
)
{
pattern
=
""
;
}
Set
<
String
>
keys
=
getKyesShiroReids
(
pattern
);
if
(
keys
.
size
()
>
0
){
stringRedisTemplate
.
delete
(
keys
);
...
...
@@ -203,10 +210,11 @@ public class RedisUtils {
Iterator
<
String
>
it
=
keys
.
iterator
();
while
(
it
.
hasNext
())
{
String
tr
=
it
.
next
();
if
(
tr
.
contains
(
SHIRO_REDIS
))
if
(
tr
.
contains
(
SHIRO_REDIS
))
{
keysnew
.
add
(
tr
);
else
if
(
tr
.
contains
(
SHIRO_REDIS_OBJECT
))
}
else
if
(
tr
.
contains
(
SHIRO_REDIS_OBJECT
))
{
keysnew
.
add
(
tr
.
substring
(
8
));
}
}
return
keysnew
;
}
catch
(
Exception
e
)
{
...
...
@@ -284,10 +292,11 @@ public class RedisUtils {
if
(!
run
())
{
return
false
;
}
boolean
retuslt
=
false
;
try
{
if
(
key
.
contains
(
SHIRO_REDIS
))
retuslt
=
stringRedisTemplate
.
hasKey
(
key
);
else
retuslt
=
redisTemplate
.
hasKey
(
key
);
if
(
key
.
contains
(
SHIRO_REDIS
))
{
retuslt
=
stringRedisTemplate
.
hasKey
(
key
);
}
else
{
retuslt
=
redisTemplate
.
hasKey
(
key
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"RedisUtils exists:"
+
RUN_MESSAGE
+
e
.
getMessage
(),
RUN_MESSAGE
+
e
.
getMessage
());
}
...
...
@@ -399,8 +408,9 @@ public class RedisUtils {
}
private
boolean
listFlush
(){
if
(
Global
.
getConfig
(
"spring.redis.listFlush"
)==
"true"
)
if
(
Global
.
getConfig
(
"spring.redis.listFlush"
)==
"true"
)
{
return
true
;
}
return
false
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/common/security/Digests.java
View file @
7fa8137a
...
...
@@ -132,14 +132,16 @@ public class Digests {
char
[]
charArray
=
inStr
.
toCharArray
();
byte
[]
byteArray
=
new
byte
[
charArray
.
length
];
for
(
int
i
=
0
;
i
<
charArray
.
length
;
i
++)
byteArray
[
i
]
=
(
byte
)
charArray
[
i
];
for
(
int
i
=
0
;
i
<
charArray
.
length
;
i
++)
{
byteArray
[
i
]
=
(
byte
)
charArray
[
i
];
}
byte
[]
md5Bytes
=
md5
.
digest
(
byteArray
);
StringBuffer
hexValue
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
md5Bytes
.
length
;
i
++){
int
val
=
((
int
)
md5Bytes
[
i
])
&
0xff
;
if
(
val
<
16
)
hexValue
.
append
(
"0"
);
if
(
val
<
16
)
{
hexValue
.
append
(
"0"
);
}
hexValue
.
append
(
Integer
.
toHexString
(
val
));
}
return
hexValue
.
toString
();
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/security/MD5Tools.java
View file @
7fa8137a
...
...
@@ -15,8 +15,8 @@ public class MD5Tools
{
public
final
static
String
MD5
(
String
pwd
)
{
//用于加密的字符
char
md5String
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
char
[]
md5String
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
try
{
//使用平台的默认字符集将此 String 编码为 byte序列,并将结果存储到一个新的 byte数组中
byte
[]
btInput
=
pwd
.
getBytes
();
...
...
@@ -32,7 +32,7 @@ public class MD5Tools
// 把密文转换成十六进制的字符串形式
int
j
=
md
.
length
;
char
str
[]
=
new
char
[
j
*
2
];
char
[]
str
=
new
char
[
j
*
2
];
int
k
=
0
;
for
(
int
i
=
0
;
i
<
j
;
i
++)
{
// i = 0
byte
byte0
=
md
[
i
];
//95
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/security/shiro/session/SessionManager.java
View file @
7fa8137a
...
...
@@ -68,7 +68,8 @@ public class SessionManager extends DefaultWebSessionManager {
super
.
validateSessions
();
}
protected
Session
retrieveSession
(
SessionKey
sessionKey
)
{
@Override
protected
Session
retrieveSession
(
SessionKey
sessionKey
)
{
try
{
return
super
.
retrieveSession
(
sessionKey
);
}
catch
(
UnknownSessionException
e
)
{
...
...
@@ -77,6 +78,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
Date
getStartTimestamp
(
SessionKey
key
)
{
try
{
return
super
.
getStartTimestamp
(
key
);
...
...
@@ -86,6 +88,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
Date
getLastAccessTime
(
SessionKey
key
)
{
try
{
return
super
.
getLastAccessTime
(
key
);
...
...
@@ -95,6 +98,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
long
getTimeout
(
SessionKey
key
){
try
{
return
super
.
getTimeout
(
key
);
...
...
@@ -104,6 +108,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
void
setTimeout
(
SessionKey
key
,
long
maxIdleTimeInMillis
)
{
try
{
super
.
setTimeout
(
key
,
maxIdleTimeInMillis
);
...
...
@@ -112,6 +117,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
void
touch
(
SessionKey
key
)
{
try
{
super
.
touch
(
key
);
...
...
@@ -120,6 +126,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
String
getHost
(
SessionKey
key
)
{
try
{
return
super
.
getHost
(
key
);
...
...
@@ -129,6 +136,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
Collection
<
Object
>
getAttributeKeys
(
SessionKey
key
)
{
try
{
return
super
.
getAttributeKeys
(
key
);
...
...
@@ -138,6 +146,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
Object
getAttribute
(
SessionKey
sessionKey
,
Object
attributeKey
)
{
try
{
return
super
.
getAttribute
(
sessionKey
,
attributeKey
);
...
...
@@ -147,6 +156,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
void
setAttribute
(
SessionKey
sessionKey
,
Object
attributeKey
,
Object
value
)
{
try
{
super
.
setAttribute
(
sessionKey
,
attributeKey
,
value
);
...
...
@@ -155,6 +165,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
Object
removeAttribute
(
SessionKey
sessionKey
,
Object
attributeKey
)
{
try
{
return
super
.
removeAttribute
(
sessionKey
,
attributeKey
);
...
...
@@ -164,6 +175,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
void
stop
(
SessionKey
key
)
{
try
{
super
.
stop
(
key
);
...
...
@@ -172,6 +184,7 @@ public class SessionManager extends DefaultWebSessionManager {
}
}
@Override
public
void
checkValid
(
SessionKey
key
)
{
try
{
super
.
checkValid
(
key
);
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/servlet/ValidateCodeServlet.java
View file @
7fa8137a
...
...
@@ -41,7 +41,8 @@ public class ValidateCodeServlet extends HttpServlet {
super
();
}
public
void
destroy
()
{
@Override
public
void
destroy
()
{
super
.
destroy
();
}
...
...
@@ -50,7 +51,8 @@ public class ValidateCodeServlet extends HttpServlet {
return
validateCode
.
toUpperCase
().
equals
(
code
);
}
public
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
@Override
public
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
String
validateCode
=
request
.
getParameter
(
VALIDATE_CODE
);
// AJAX验证,成功返回true
if
(
StringUtils
.
isNotBlank
(
validateCode
)){
...
...
@@ -60,7 +62,8 @@ public class ValidateCodeServlet extends HttpServlet {
}
}
public
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
@Override
public
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
createImage
(
request
,
response
);
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/tag/AceMenuTag.java
View file @
7fa8137a
...
...
@@ -34,11 +34,13 @@ public class AceMenuTag extends TagSupport {
this
.
menu
=
menu
;
}
public
int
doStartTag
()
throws
JspTagException
{
@Override
public
int
doStartTag
()
throws
JspTagException
{
return
EVAL_PAGE
;
}
public
int
doEndTag
()
throws
JspTagException
{
@Override
public
int
doEndTag
()
throws
JspTagException
{
try
{
JspWriter
out
=
this
.
pageContext
.
getOut
();
String
menu
=
(
String
)
this
.
pageContext
.
getSession
().
getAttribute
(
...
...
@@ -69,8 +71,9 @@ public class AceMenuTag extends TagSupport {
private
static
String
getChildOfTree
(
Menu
parent
,
int
level
,
List
<
Menu
>
menuList
)
{
StringBuffer
menuString
=
new
StringBuffer
();
String
href
=
""
;
if
(!
parent
.
hasPermisson
())
return
""
;
if
(!
parent
.
hasPermisson
())
{
return
""
;
}
ServletContext
context
=
SpringContextHolder
.
getBean
(
ServletContext
.
class
);
...
...
@@ -88,7 +91,7 @@ public class AceMenuTag extends TagSupport {
if
(
level
>
0
)
{
// level 为0是功能菜单
menuString
.
append
(
"<li>"
);
if
((
parent
.
getHref
()
==
null
||
parent
.
getHref
().
trim
().
equals
(
""
))
&&
parent
.
getIsShow
()
.
equals
(
"1"
))
{
if
((
parent
.
getHref
()
==
null
||
""
.
equals
(
parent
.
getHref
().
trim
()
))
&&
"1"
.
equals
(
parent
.
getIsShow
()))
{
menuString
.
append
(
"<a href=\""
+
href
+
"\" class=\"dropdown-toggle\">"
);
}
else
{
...
...
@@ -98,13 +101,13 @@ public class AceMenuTag extends TagSupport {
menuString
.
append
(
"<i class=\"menu-icon fa "
+
parent
.
getIcon
()
+
"\"></i>"
);
menuString
.
append
(
"<span class=\"menu-text\">"
+
parent
.
getName
()+
"</span>"
);
if
((
parent
.
getHref
()
==
null
||
parent
.
getHref
().
trim
().
equals
(
""
))
&&
parent
.
getIsShow
()
.
equals
(
"1"
))
{
if
((
parent
.
getHref
()
==
null
||
""
.
equals
(
parent
.
getHref
().
trim
()
))
&&
"1"
.
equals
(
parent
.
getIsShow
()))
{
menuString
.
append
(
"<b class=\"arrow fa fa-angle-down\"></b>"
);
}
menuString
.
append
(
"</a>"
);
menuString
.
append
(
"<b class=\"arrow\"></b>"
);
}
if
((
parent
.
getHref
()
==
null
||
parent
.
getHref
().
trim
().
equals
(
""
))
&&
parent
.
getIsShow
()
.
equals
(
"1"
))
{
if
((
parent
.
getHref
()
==
null
||
""
.
equals
(
parent
.
getHref
().
trim
()
))
&&
"1"
.
equals
(
parent
.
getIsShow
()))
{
if
(
level
==
0
)
{
menuString
.
append
(
"<ul class=\"nav nav-list\">"
);
}
else
{
...
...
@@ -113,7 +116,7 @@ public class AceMenuTag extends TagSupport {
for
(
Menu
child
:
menuList
)
{
if
(
child
.
getParentId
().
equals
(
parent
.
getId
())&&
child
.
getIsShow
()
.
equals
(
"1"
))
{
if
(
child
.
getParentId
().
equals
(
parent
.
getId
())&&
"1"
.
equals
(
child
.
getIsShow
()))
{
menuString
.
append
(
getChildOfTree
(
child
,
level
+
1
,
menuList
));
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/tag/MenuTag.java
View file @
7fa8137a
...
...
@@ -35,11 +35,13 @@ public class MenuTag extends TagSupport {
this
.
menu
=
menu
;
}
public
int
doStartTag
()
throws
JspTagException
{
@Override
public
int
doStartTag
()
throws
JspTagException
{
return
EVAL_PAGE
;
}
public
int
doEndTag
()
throws
JspTagException
{
@Override
public
int
doEndTag
()
throws
JspTagException
{
try
{
JspWriter
out
=
this
.
pageContext
.
getOut
();
String
menu
=
(
String
)
this
.
pageContext
.
getSession
().
getAttribute
(
"menu"
);
...
...
@@ -68,14 +70,17 @@ public class MenuTag extends TagSupport {
private
static
String
getChildOfTree
(
Menu
parent
,
int
level
)
{
StringBuffer
menuString
=
new
StringBuffer
();
String
href
=
""
;
if
(!
parent
.
hasPermisson
())
return
""
;
if
(!
parent
.
hasPermisson
())
{
return
""
;
}
if
(
level
>
0
)
{
//level 为0是功能菜单
if
(
parent
.
hasChildren
())
//menu-open
menuString
.
append
(
"<li class=\"treeview\">"
);
else
menuString
.
append
(
"<li>"
);
{
menuString
.
append
(
"<li class=\"treeview\">"
);
}
else
{
menuString
.
append
(
"<li>"
);
}
ServletContext
context
=
SpringContextHolder
.
getBean
(
ServletContext
.
class
);
...
...
@@ -115,7 +120,7 @@ public class MenuTag extends TagSupport {
menuString
.
append
(
"<ul class=\"nav nav-fifth-level treeview-menu\" >"
);
}
for
(
Menu
child
:
parent
.
getChildren
())
{
if
(
child
.
getIsShow
()
.
equals
(
"1"
))
{
if
(
"1"
.
equals
(
child
.
getIsShow
()))
{
menuString
.
append
(
getChildOfTree
(
child
,
level
+
1
));
}
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/tag/echarts/EChartsBarTag.java
View file @
7fa8137a
...
...
@@ -111,11 +111,13 @@ public class EChartsBarTag extends BodyTagSupport {
return
Tag
.
EVAL_PAGE
;
// 继续处理页面
}
public
String
getId
()
{
@Override
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/tag/echarts/EChartsLineDoubleNumTag.java
View file @
7fa8137a
...
...
@@ -120,11 +120,13 @@ public class EChartsLineDoubleNumTag extends BodyTagSupport {
return
Tag
.
EVAL_PAGE
;
// 继续处理页面
}
public
String
getId
()
{
@Override
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/tag/echarts/EChartsLineTag.java
View file @
7fa8137a
...
...
@@ -112,11 +112,13 @@ public class EChartsLineTag extends BodyTagSupport {
return
Tag
.
EVAL_PAGE
;
// 继续处理页面
}
public
String
getId
()
{
@Override
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/tag/echarts/EChartsLineTimeLineTag.java
View file @
7fa8137a
...
...
@@ -196,11 +196,13 @@ public class EChartsLineTimeLineTag extends BodyTagSupport {
return
Tag
.
EVAL_PAGE
;
// 继续处理页面
}
public
String
getId
()
{
@Override
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/tag/echarts/EChartsPieTag.java
View file @
7fa8137a
...
...
@@ -84,11 +84,13 @@ public class EChartsPieTag extends BodyTagSupport {
return
Tag
.
EVAL_PAGE
;
// 继续处理页面
}
public
String
getId
()
{
@Override
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/tag/echarts/EChartsRadarTag.java
View file @
7fa8137a
...
...
@@ -123,11 +123,13 @@ public class EChartsRadarTag extends BodyTagSupport {
return
Tag
.
EVAL_PAGE
;
// 继续处理页面
}
public
String
getId
()
{
@Override
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
@Override
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/utils/Base64ImageUtils.java
View file @
7fa8137a
...
...
@@ -73,7 +73,9 @@ public class Base64ImageUtils {
*/
public
static
boolean
saveImage
(
String
imgStr
,
String
imgFilePath
)
{
if
(
imgStr
==
null
)
// 图像数据为空
{
return
false
;
}
BASE64Decoder
decoder
=
new
BASE64Decoder
();
try
{
// Base64解码
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/utils/Convert.java
View file @
7fa8137a
...
...
@@ -893,7 +893,7 @@ public class Convert
*/
public
static
String
toSBC
(
String
input
,
Set
<
Character
>
notConvertSet
)
{
char
c
[]
=
input
.
toCharArray
();
char
[]
c
=
input
.
toCharArray
();
for
(
int
i
=
0
;
i
<
c
.
length
;
i
++)
{
if
(
null
!=
notConvertSet
&&
notConvertSet
.
contains
(
c
[
i
]))
...
...
@@ -935,7 +935,7 @@ public class Convert
*/
public
static
String
toDBC
(
String
text
,
Set
<
Character
>
notConvertSet
)
{
char
c
[]
=
text
.
toCharArray
();
char
[]
c
=
text
.
toCharArray
();
for
(
int
i
=
0
;
i
<
c
.
length
;
i
++)
{
if
(
null
!=
notConvertSet
&&
notConvertSet
.
contains
(
c
[
i
]))
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/utils/Exceptions.java
View file @
7fa8137a
...
...
@@ -31,8 +31,9 @@ public class Exceptions {
* 将ErrorStack转化为String.
*/
public
static
String
getStackTraceAsString
(
Throwable
e
)
{
if
(
e
==
null
)
if
(
e
==
null
)
{
return
""
;
}
StringWriter
stringWriter
=
new
StringWriter
();
e
.
printStackTrace
(
new
PrintWriter
(
stringWriter
));
return
stringWriter
.
toString
();
...
...
@@ -45,9 +46,11 @@ public class Exceptions {
public
static
boolean
isCausedBy
(
Exception
ex
,
Class
<?
extends
Exception
>...
causeExceptionClasses
)
{
Throwable
cause
=
ex
.
getCause
();
while
(
cause
!=
null
)
{
for
(
Class
<?
extends
Exception
>
causeClass
:
causeExceptionClasses
)
if
(
causeClass
.
isInstance
(
cause
))
for
(
Class
<?
extends
Exception
>
causeClass
:
causeExceptionClasses
)
{
if
(
causeClass
.
isInstance
(
cause
))
{
return
true
;
}
}
cause
=
cause
.
getCause
();
}
return
false
;
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/utils/FileSizeHelper.java
View file @
7fa8137a
...
...
@@ -19,7 +19,9 @@ public class FileSizeHelper {
public
static
long
ONE_PB
=
ONE_TB
*
(
long
)
1024
;
public
static
String
getHumanReadableFileSize
(
Long
fileSize
)
{
if
(
fileSize
==
null
)
return
null
;
if
(
fileSize
==
null
)
{
return
null
;
}
return
getHumanReadableFileSize
(
fileSize
.
longValue
());
}
...
...
@@ -52,7 +54,9 @@ public class FileSizeHelper {
}
private
static
String
getHumanReadableFileSize
(
long
fileSize
,
long
unit
,
String
unitName
)
{
if
(
fileSize
==
0
)
return
"0"
;
if
(
fileSize
==
0
)
{
return
"0"
;
}
if
(
fileSize
/
unit
>=
1
)
{
double
value
=
fileSize
/
(
double
)
unit
;
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/utils/FileUtils.java
View file @
7fa8137a
...
...
@@ -612,120 +612,121 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
*/
public
static
String
getContentType
(
String
returnFileName
)
{
String
contentType
=
"application/octet-stream"
;
if
(
returnFileName
.
lastIndexOf
(
"."
)
<
0
)
return
contentType
;
if
(
returnFileName
.
lastIndexOf
(
"."
)
<
0
)
{
return
contentType
;
}
returnFileName
=
returnFileName
.
toLowerCase
();
returnFileName
=
returnFileName
.
substring
(
returnFileName
.
lastIndexOf
(
"."
)
+
1
);
if
(
returnFileName
.
equals
(
"html"
)
||
returnFileName
.
equals
(
"htm"
)
||
returnFileName
.
equals
(
"shtml"
))
{
if
(
"html"
.
equals
(
returnFileName
)
||
"htm"
.
equals
(
returnFileName
)
||
"shtml"
.
equals
(
returnFileName
))
{
contentType
=
"text/html"
;
}
else
if
(
returnFileName
.
equals
(
"apk"
))
{
}
else
if
(
"apk"
.
equals
(
returnFileName
))
{
contentType
=
"application/vnd.android.package-archive"
;
}
else
if
(
returnFileName
.
equals
(
"sis"
))
{
}
else
if
(
"sis"
.
equals
(
returnFileName
))
{
contentType
=
"application/vnd.symbian.install"
;
}
else
if
(
returnFileName
.
equals
(
"sisx"
))
{
}
else
if
(
"sisx"
.
equals
(
returnFileName
))
{
contentType
=
"application/vnd.symbian.install"
;
}
else
if
(
returnFileName
.
equals
(
"exe"
))
{
}
else
if
(
"exe"
.
equals
(
returnFileName
))
{
contentType
=
"application/x-msdownload"
;
}
else
if
(
returnFileName
.
equals
(
"msi"
))
{
}
else
if
(
"msi"
.
equals
(
returnFileName
))
{
contentType
=
"application/x-msdownload"
;
}
else
if
(
returnFileName
.
equals
(
"css"
))
{
}
else
if
(
"css"
.
equals
(
returnFileName
))
{
contentType
=
"text/css"
;
}
else
if
(
returnFileName
.
equals
(
"xml"
))
{
}
else
if
(
"xml"
.
equals
(
returnFileName
))
{
contentType
=
"text/xml"
;
}
else
if
(
returnFileName
.
equals
(
"gif"
))
{
}
else
if
(
"gif"
.
equals
(
returnFileName
))
{
contentType
=
"image/gif"
;
}
else
if
(
returnFileName
.
equals
(
"jpeg"
)
||
returnFileName
.
equals
(
"jpg"
))
{
}
else
if
(
"jpeg"
.
equals
(
returnFileName
)
||
"jpg"
.
equals
(
returnFileName
))
{
contentType
=
"image/jpeg"
;
}
else
if
(
returnFileName
.
equals
(
"js"
))
{
}
else
if
(
"js"
.
equals
(
returnFileName
))
{
contentType
=
"application/x-javascript"
;
}
else
if
(
returnFileName
.
equals
(
"atom"
))
{
}
else
if
(
"atom"
.
equals
(
returnFileName
))
{
contentType
=
"application/atom+xml"
;
}
else
if
(
returnFileName
.
equals
(
"rss"
))
{
}
else
if
(
"rss"
.
equals
(
returnFileName
))
{
contentType
=
"application/rss+xml"
;
}
else
if
(
returnFileName
.
equals
(
"mml"
))
{
}
else
if
(
"mml"
.
equals
(
returnFileName
))
{
contentType
=
"text/mathml"
;
}
else
if
(
returnFileName
.
equals
(
"txt"
))
{
}
else
if
(
"txt"
.
equals
(
returnFileName
))
{
contentType
=
"text/plain"
;
}
else
if
(
returnFileName
.
equals
(
"jad"
))
{
}
else
if
(
"jad"
.
equals
(
returnFileName
))
{
contentType
=
"text/vnd.sun.j2me.app-descriptor"
;
}
else
if
(
returnFileName
.
equals
(
"wml"
))
{
}
else
if
(
"wml"
.
equals
(
returnFileName
))
{
contentType
=
"text/vnd.wap.wml"
;
}
else
if
(
returnFileName
.
equals
(
"htc"
))
{
}
else
if
(
"htc"
.
equals
(
returnFileName
))
{
contentType
=
"text/x-component"
;
}
else
if
(
returnFileName
.
equals
(
"png"
))
{
}
else
if
(
"png"
.
equals
(
returnFileName
))
{
contentType
=
"image/png"
;
}
else
if
(
returnFileName
.
equals
(
"tif"
)
||
returnFileName
.
equals
(
"tiff"
))
{
}
else
if
(
"tif"
.
equals
(
returnFileName
)
||
"tiff"
.
equals
(
returnFileName
))
{
contentType
=
"image/tiff"
;
}
else
if
(
returnFileName
.
equals
(
"wbmp"
))
{
}
else
if
(
"wbmp"
.
equals
(
returnFileName
))
{
contentType
=
"image/vnd.wap.wbmp"
;
}
else
if
(
returnFileName
.
equals
(
"ico"
))
{
}
else
if
(
"ico"
.
equals
(
returnFileName
))
{
contentType
=
"image/x-icon"
;
}
else
if
(
returnFileName
.
equals
(
"jng"
))
{
}
else
if
(
"jng"
.
equals
(
returnFileName
))
{
contentType
=
"image/x-jng"
;
}
else
if
(
returnFileName
.
equals
(
"bmp"
))
{
}
else
if
(
"bmp"
.
equals
(
returnFileName
))
{
contentType
=
"image/x-ms-bmp"
;
}
else
if
(
returnFileName
.
equals
(
"svg"
))
{
}
else
if
(
"svg"
.
equals
(
returnFileName
))
{
contentType
=
"image/svg+xml"
;
}
else
if
(
returnFileName
.
equals
(
"jar"
)
||
returnFileName
.
equals
(
"var"
)
||
returnFileName
.
equals
(
"ear"
))
{
}
else
if
(
"jar"
.
equals
(
returnFileName
)
||
"var"
.
equals
(
returnFileName
)
||
"ear"
.
equals
(
returnFileName
))
{
contentType
=
"application/java-archive"
;
}
else
if
(
returnFileName
.
equals
(
"doc"
))
{
}
else
if
(
"doc"
.
equals
(
returnFileName
))
{
contentType
=
"application/msword"
;
}
else
if
(
returnFileName
.
equals
(
"pdf"
))
{
}
else
if
(
"pdf"
.
equals
(
returnFileName
))
{
contentType
=
"application/pdf"
;
}
else
if
(
returnFileName
.
equals
(
"rtf"
))
{
}
else
if
(
"rtf"
.
equals
(
returnFileName
))
{
contentType
=
"application/rtf"
;
}
else
if
(
returnFileName
.
equals
(
"xls"
))
{
}
else
if
(
"xls"
.
equals
(
returnFileName
))
{
contentType
=
"application/vnd.ms-excel"
;
}
else
if
(
returnFileName
.
equals
(
"ppt"
))
{
}
else
if
(
"ppt"
.
equals
(
returnFileName
))
{
contentType
=
"application/vnd.ms-powerpoint"
;
}
else
if
(
returnFileName
.
equals
(
"7z"
))
{
}
else
if
(
"7z"
.
equals
(
returnFileName
))
{
contentType
=
"application/x-7z-compressed"
;
}
else
if
(
returnFileName
.
equals
(
"rar"
))
{
}
else
if
(
"rar"
.
equals
(
returnFileName
))
{
contentType
=
"application/x-rar-compressed"
;
}
else
if
(
returnFileName
.
equals
(
"swf"
))
{
}
else
if
(
"swf"
.
equals
(
returnFileName
))
{
contentType
=
"application/x-shockwave-flash"
;
}
else
if
(
returnFileName
.
equals
(
"rpm"
))
{
}
else
if
(
"rpm"
.
equals
(
returnFileName
))
{
contentType
=
"application/x-redhat-package-manager"
;
}
else
if
(
returnFileName
.
equals
(
"der"
)
||
returnFileName
.
equals
(
"pem"
)
||
returnFileName
.
equals
(
"crt"
))
{
}
else
if
(
"der"
.
equals
(
returnFileName
)
||
"pem"
.
equals
(
returnFileName
)
||
"crt"
.
equals
(
returnFileName
))
{
contentType
=
"application/x-x509-ca-cert"
;
}
else
if
(
returnFileName
.
equals
(
"xhtml"
))
{
}
else
if
(
"xhtml"
.
equals
(
returnFileName
))
{
contentType
=
"application/xhtml+xml"
;
}
else
if
(
returnFileName
.
equals
(
"zip"
))
{
}
else
if
(
"zip"
.
equals
(
returnFileName
))
{
contentType
=
"application/zip"
;
}
else
if
(
returnFileName
.
equals
(
"mid"
)
||
returnFileName
.
equals
(
"midi"
)
||
returnFileName
.
equals
(
"kar"
))
{
}
else
if
(
"mid"
.
equals
(
returnFileName
)
||
"midi"
.
equals
(
returnFileName
)
||
"kar"
.
equals
(
returnFileName
))
{
contentType
=
"audio/midi"
;
}
else
if
(
returnFileName
.
equals
(
"mp3"
))
{
}
else
if
(
"mp3"
.
equals
(
returnFileName
))
{
contentType
=
"audio/mpeg"
;
}
else
if
(
returnFileName
.
equals
(
"ogg"
))
{
}
else
if
(
"ogg"
.
equals
(
returnFileName
))
{
contentType
=
"audio/ogg"
;
}
else
if
(
returnFileName
.
equals
(
"m4a"
))
{
}
else
if
(
"m4a"
.
equals
(
returnFileName
))
{
contentType
=
"audio/x-m4a"
;
}
else
if
(
returnFileName
.
equals
(
"ra"
))
{
}
else
if
(
"ra"
.
equals
(
returnFileName
))
{
contentType
=
"audio/x-realaudio"
;
}
else
if
(
returnFileName
.
equals
(
"3gpp"
)
||
returnFileName
.
equals
(
"3gp"
))
{
}
else
if
(
"3gpp"
.
equals
(
returnFileName
)
||
"3gp"
.
equals
(
returnFileName
))
{
contentType
=
"video/3gpp"
;
}
else
if
(
returnFileName
.
equals
(
"mp4"
))
{
}
else
if
(
"mp4"
.
equals
(
returnFileName
))
{
contentType
=
"video/mp4"
;
}
else
if
(
returnFileName
.
equals
(
"mpeg"
)
||
returnFileName
.
equals
(
"mpg"
))
{
}
else
if
(
"mpeg"
.
equals
(
returnFileName
)
||
"mpg"
.
equals
(
returnFileName
))
{
contentType
=
"video/mpeg"
;
}
else
if
(
returnFileName
.
equals
(
"mov"
))
{
}
else
if
(
"mov"
.
equals
(
returnFileName
))
{
contentType
=
"video/quicktime"
;
}
else
if
(
returnFileName
.
equals
(
"flv"
))
{
}
else
if
(
"flv"
.
equals
(
returnFileName
))
{
contentType
=
"video/x-flv"
;
}
else
if
(
returnFileName
.
equals
(
"m4v"
))
{
}
else
if
(
"m4v"
.
equals
(
returnFileName
))
{
contentType
=
"video/x-m4v"
;
}
else
if
(
returnFileName
.
equals
(
"mng"
))
{
}
else
if
(
"mng"
.
equals
(
returnFileName
))
{
contentType
=
"video/x-mng"
;
}
else
if
(
returnFileName
.
equals
(
"asx"
)
||
returnFileName
.
equals
(
"asf"
))
{
}
else
if
(
"asx"
.
equals
(
returnFileName
)
||
"asf"
.
equals
(
returnFileName
))
{
contentType
=
"video/x-ms-asf"
;
}
else
if
(
returnFileName
.
equals
(
"wmv"
))
{
}
else
if
(
"wmv"
.
equals
(
returnFileName
))
{
contentType
=
"video/x-ms-wmv"
;
}
else
if
(
returnFileName
.
equals
(
"avi"
))
{
}
else
if
(
"avi"
.
equals
(
returnFileName
))
{
contentType
=
"video/x-msvideo"
;
}
return
contentType
;
...
...
@@ -780,7 +781,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
RandomAccessFile
raf
=
null
;
// 负责读取数据
OutputStream
os
=
null
;
// 写出数据
OutputStream
out
=
null
;
// 缓冲
byte
b
[]
=
new
byte
[
1024
];
// 暂存容器
byte
[]
b
=
new
byte
[
1024
];
// 暂存容器
if
(
request
.
getHeader
(
"Range"
)
!=
null
)
{
// 客户端请求的下载的文件块的开始字节
response
.
setStatus
(
HttpServletResponse
.
SC_PARTIAL_CONTENT
);
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/utils/IdGen.java
View file @
7fa8137a
...
...
@@ -52,6 +52,7 @@ public class IdGen implements IdGenerator, SessionIdGenerator {
* Activiti ID 生成
*/
//@Override
@Override
public
String
getNextId
()
{
return
IdGen
.
uuid
();
}
...
...
JeeSpringCloud/src/main/java/com/jeespring/common/utils/IdcardUtils.java
View file @
7fa8137a
...
...
@@ -23,19 +23,25 @@ public class IdcardUtils extends StringUtils {
/** 中国公民身份证号码最大长度。 */
public
static
final
int
CHINA_ID_MAX_LENGTH
=
18
;
/** 省、直辖市代码表 */
public
static
final
String
cityCode
[]
=
{
"11"
,
"12"
,
"13"
,
"14"
,
"15"
,
"21"
,
"22"
,
"23"
,
"31"
,
"32"
,
"33"
,
"34"
,
"35"
,
"36"
,
"37"
,
"41"
,
"42"
,
"43"
,
"44"
,
"45"
,
"46"
,
"50"
,
"51"
,
"52"
,
"53"
,
"54"
,
"61"
,
"62"
,
"63"
,
"64"
,
"65"
,
"71"
,
"81"
,
"82"
,
"91"
};
/**
* 省、直辖市代码表
*/
public
static
final
String
[]
cityCode
=
{
"11"
,
"12"
,
"13"
,
"14"
,
"15"
,
"21"
,
"22"
,
"23"
,
"31"
,
"32"
,
"33"
,
"34"
,
"35"
,
"36"
,
"37"
,
"41"
,
"42"
,
"43"
,
"44"
,
"45"
,
"46"
,
"50"
,
"51"
,
"52"
,
"53"
,
"54"
,
"61"
,
"62"
,
"63"
,
"64"
,
"65"
,
"71"
,
"81"
,
"82"
,
"91"
};
/** 每位加权因子 */
public
static
final
int
power
[]
=
{
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
};
/**
* 每位加权因子
*/
public
static
final
int
[]
power
=
{
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
};
/** 第18位校检码 */
public
static
final
String
verifyCode
[]
=
{
"1"
,
"0"
,
"X"
,
"9"
,
"8"
,
"7"
,
"6"
,
"5"
,
"4"
,
"3"
,
"2"
};
/**
* 第18位校检码
*/
public
static
final
String
[]
verifyCode
=
{
"1"
,
"0"
,
"X"
,
"9"
,
"8"
,
"7"
,
"6"
,
"5"
,
"4"
,
"3"
,
"2"
};
/** 最低年限 */
public
static
final
int
MIN
=
1930
;
public
static
Map
<
String
,
String
>
cityCodes
=
new
HashMap
<
String
,
String
>();
...
...
@@ -139,8 +145,9 @@ public class IdcardUtils extends StringUtils {
e
.
printStackTrace
();
}
Calendar
cal
=
Calendar
.
getInstance
();
if
(
birthDate
!=
null
)
cal
.
setTime
(
birthDate
);
if
(
birthDate
!=
null
)
{
cal
.
setTime
(
birthDate
);
}
// 获取出生年(完全表现形式,如:2010)
String
sYear
=
String
.
valueOf
(
cal
.
get
(
Calendar
.
YEAR
));
idCard18
=
idCard
.
substring
(
0
,
6
)
+
sYear
+
idCard
.
substring
(
8
);
...
...
@@ -176,7 +183,7 @@ public class IdcardUtils extends StringUtils {
}
String
[]
cardval
=
validateIdCard10
(
card
);
if
(
cardval
!=
null
)
{
if
(
cardval
[
2
].
equals
(
"true"
))
{
if
(
"true"
.
equals
(
cardval
[
2
]
))
{
return
true
;
}
}
...
...
@@ -240,8 +247,9 @@ public class IdcardUtils extends StringUtils {
e
.
printStackTrace
();
}
Calendar
cal
=
Calendar
.
getInstance
();
if
(
birthDate
!=
null
)
cal
.
setTime
(
birthDate
);
if
(
birthDate
!=
null
)
{
cal
.
setTime
(
birthDate
);
}
if
(!
valiDate
(
cal
.
get
(
Calendar
.
YEAR
),
Integer
.
valueOf
(
birthCode
.
substring
(
2
,
4
)),
Integer
.
valueOf
(
birthCode
.
substring
(
4
,
6
))))
{
...
...
@@ -274,10 +282,10 @@ public class IdcardUtils extends StringUtils {
info
[
0
]
=
"台湾"
;
System
.
out
.
println
(
"11111"
);
String
char2
=
idCard
.
substring
(
1
,
2
);
if
(
char2
.
equals
(
"1"
))
{
if
(
"1"
.
equals
(
char2
))
{
info
[
1
]
=
"M"
;
System
.
out
.
println
(
"MMMMMMM"
);
}
else
if
(
char2
.
equals
(
"2"
))
{
}
else
if
(
"2"
.
equals
(
char2
))
{
info
[
1
]
=
"F"
;
System
.
out
.
println
(
"FFFFFFF"
);
}
else
{
...
...
@@ -359,7 +367,7 @@ public class IdcardUtils extends StringUtils {
sum
=
sum
+
Integer
.
valueOf
(
c
+
""
)
*
iflag
;
iflag
--;
}
if
(
end
.
toUpperCase
()
.
equals
(
"A"
))
{
if
(
"A"
.
equals
(
end
.
toUpperCase
()))
{
sum
=
sum
+
10
;
}
else
{
sum
=
sum
+
Integer
.
valueOf
(
end
);
...
...
Prev
1
2
3
4
5
6
…
11
Next
Write
Preview
Supports
Markdown
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