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
Eladmin
Commits
3d53a3a0
Commit
3d53a3a0
authored
Jun 04, 2020
by
ZhengJie
Browse files
[代码完善](v2.5): v2.5 beta 更新 fastjson 版本,代码优化
parent
b699d325
Changes
10
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/utils/RsaUtils.java
View file @
3d53a3a0
...
...
@@ -19,7 +19,7 @@ public class RsaUtils {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"\n"
);
R
SA
KeyPair
keyPair
=
generateKeyPair
();
R
sa
KeyPair
keyPair
=
generateKeyPair
();
System
.
out
.
println
(
"公钥:"
+
keyPair
.
getPublicKey
());
System
.
out
.
println
(
"私钥:"
+
keyPair
.
getPrivateKey
());
System
.
out
.
println
(
"\n"
);
...
...
@@ -32,7 +32,7 @@ public class RsaUtils {
/**
* 公钥加密私钥解密
*/
private
static
void
test1
(
R
SA
KeyPair
keyPair
)
throws
Exception
{
private
static
void
test1
(
R
sa
KeyPair
keyPair
)
throws
Exception
{
System
.
out
.
println
(
"***************** 公钥加密私钥解密开始 *****************"
);
String
text1
=
encryptByPublicKey
(
keyPair
.
getPublicKey
(),
RsaUtils
.
SRC
);
String
text2
=
decryptByPrivateKey
(
keyPair
.
getPrivateKey
(),
text1
);
...
...
@@ -51,7 +51,7 @@ public class RsaUtils {
* 私钥加密公钥解密
* @throws Exception /
*/
private
static
void
test2
(
R
SA
KeyPair
keyPair
)
throws
Exception
{
private
static
void
test2
(
R
sa
KeyPair
keyPair
)
throws
Exception
{
System
.
out
.
println
(
"***************** 私钥加密公钥解密开始 *****************"
);
String
text1
=
encryptByPrivateKey
(
keyPair
.
getPrivateKey
(),
RsaUtils
.
SRC
);
String
text2
=
decryptByPublicKey
(
keyPair
.
getPublicKey
(),
text1
);
...
...
@@ -143,7 +143,7 @@ public class RsaUtils {
* @return /
* @throws NoSuchAlgorithmException /
*/
public
static
R
SA
KeyPair
generateKeyPair
()
throws
NoSuchAlgorithmException
{
public
static
R
sa
KeyPair
generateKeyPair
()
throws
NoSuchAlgorithmException
{
KeyPairGenerator
keyPairGenerator
=
KeyPairGenerator
.
getInstance
(
"RSA"
);
keyPairGenerator
.
initialize
(
1024
);
KeyPair
keyPair
=
keyPairGenerator
.
generateKeyPair
();
...
...
@@ -151,19 +151,19 @@ public class RsaUtils {
RSAPrivateKey
rsaPrivateKey
=
(
RSAPrivateKey
)
keyPair
.
getPrivate
();
String
publicKeyString
=
Base64
.
encodeBase64String
(
rsaPublicKey
.
getEncoded
());
String
privateKeyString
=
Base64
.
encodeBase64String
(
rsaPrivateKey
.
getEncoded
());
return
new
R
SA
KeyPair
(
publicKeyString
,
privateKeyString
);
return
new
R
sa
KeyPair
(
publicKeyString
,
privateKeyString
);
}
/**
* RSA密钥对对象
*/
public
static
class
R
SA
KeyPair
{
public
static
class
R
sa
KeyPair
{
private
final
String
publicKey
;
private
final
String
privateKey
;
public
R
SA
KeyPair
(
String
publicKey
,
String
privateKey
)
{
public
R
sa
KeyPair
(
String
publicKey
,
String
privateKey
)
{
this
.
publicKey
=
publicKey
;
this
.
privateKey
=
privateKey
;
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java
View file @
3d53a3a0
...
...
@@ -62,7 +62,7 @@ public class AuthorizationController {
@Value
(
"${loginCode.expiration}"
)
private
Long
expiration
;
@Value
(
"${single.login
:false
}"
)
@Value
(
"${single.login}"
)
private
Boolean
singleLogin
;
private
final
SecurityProperties
properties
;
private
final
RedisUtils
redisUtils
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java
View file @
3d53a3a0
...
...
@@ -26,7 +26,6 @@ import org.springframework.http.HttpStatus;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.Set
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java
View file @
3d53a3a0
...
...
@@ -114,6 +114,7 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
/**
* 根据角色查询
* @param ids /
* @return /
*/
@Query
(
value
=
"SELECT count(1) FROM sys_user u, sys_users_roles r WHERE "
+
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java
View file @
3d53a3a0
...
...
@@ -78,8 +78,8 @@ public class RoleServiceImpl implements RoleService {
}
@Override
@Transactional
@Cacheable
(
key
=
"'id:' + #p0"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
RoleDto
findById
(
long
id
)
{
Role
role
=
roleRepository
.
findById
(
id
).
orElseGet
(
Role:
:
new
);
ValidationUtil
.
isNull
(
role
.
getId
(),
"Role"
,
"id"
,
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
View file @
3d53a3a0
...
...
@@ -68,8 +68,8 @@ public class UserServiceImpl implements UserService {
}
@Override
@Transactional
@Cacheable
(
key
=
"'id:' + #p0"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
UserDto
findById
(
long
id
)
{
User
user
=
userRepository
.
findById
(
id
).
orElseGet
(
User:
:
new
);
ValidationUtil
.
isNull
(
user
.
getId
(),
"User"
,
"id"
,
id
);
...
...
@@ -177,7 +177,7 @@ public class UserServiceImpl implements UserService {
FileUtil
.
del
(
oldPath
);
}
redisUtils
.
del
(
"user::username:"
+
user
.
getUsername
());
return
new
HashMap
<
String
,
String
>(){{
put
(
"avatar"
,
file
.
getName
());}};
return
new
HashMap
<
String
,
String
>(
1
){{
put
(
"avatar"
,
file
.
getName
());}};
}
@Override
...
...
eladmin-system/src/main/resources/config/application-dev.yml
View file @
3d53a3a0
...
...
@@ -43,6 +43,11 @@ spring:
wall
:
config
:
multi-statement-allow
:
true
# 是否限制单用户登录
single
:
login
:
false
#jwt
jwt
:
header
:
Authorization
...
...
eladmin-system/src/main/resources/config/application-prod.yml
View file @
3d53a3a0
...
...
@@ -45,6 +45,11 @@ spring:
wall
:
config
:
multi-statement-allow
:
true
# 是否限制单用户登录
single
:
login
:
false
#jwt
jwt
:
header
:
Authorization
...
...
eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java
View file @
3d53a3a0
...
...
@@ -27,9 +27,10 @@ public interface EmailService {
/**
* 更新邮件配置
* @param emailConfig 邮件配置
* @param old 旧的配置
* @return EmailConfig
* @param emailConfig 邮箱配置
* @param old /
* @return /
* @throws Exception /
*/
EmailConfig
config
(
EmailConfig
emailConfig
,
EmailConfig
old
)
throws
Exception
;
...
...
pom.xml
View file @
3d53a3a0
...
...
@@ -32,7 +32,7 @@
<java.version>
1.8
</java.version>
<log4jdbc.version>
1.16
</log4jdbc.version>
<swagger.version>
2.9.2
</swagger.version>
<fastjson.version>
1.2.
68
</fastjson.version>
<fastjson.version>
1.2.
70
</fastjson.version>
<druid.version>
1.1.22
</druid.version>
<commons-pool2.version>
2.5.0
</commons-pool2.version>
<mapstruct.version>
1.3.1.Final
</mapstruct.version>
...
...
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