Skip to content

Commit 3d53a3a

Browse files
committed
[代码完善](v2.5): v2.5 beta 更新 fastjson 版本,代码优化
1 parent b699d32 commit 3d53a3a

10 files changed

Lines changed: 27 additions & 16 deletions

File tree

eladmin-common/src/main/java/me/zhengjie/utils/RsaUtils.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class RsaUtils {
1919

2020
public static void main(String[] args) throws Exception {
2121
System.out.println("\n");
22-
RSAKeyPair keyPair = generateKeyPair();
22+
RsaKeyPair keyPair = generateKeyPair();
2323
System.out.println("公钥:" + keyPair.getPublicKey());
2424
System.out.println("私钥:" + keyPair.getPrivateKey());
2525
System.out.println("\n");
@@ -32,7 +32,7 @@ public static void main(String[] args) throws Exception {
3232
/**
3333
* 公钥加密私钥解密
3434
*/
35-
private static void test1(RSAKeyPair keyPair) throws Exception {
35+
private static void test1(RsaKeyPair keyPair) throws Exception {
3636
System.out.println("***************** 公钥加密私钥解密开始 *****************");
3737
String text1 = encryptByPublicKey(keyPair.getPublicKey(), RsaUtils.SRC);
3838
String text2 = decryptByPrivateKey(keyPair.getPrivateKey(), text1);
@@ -51,7 +51,7 @@ private static void test1(RSAKeyPair keyPair) throws Exception {
5151
* 私钥加密公钥解密
5252
* @throws Exception /
5353
*/
54-
private static void test2(RSAKeyPair keyPair) throws Exception {
54+
private static void test2(RsaKeyPair keyPair) throws Exception {
5555
System.out.println("***************** 私钥加密公钥解密开始 *****************");
5656
String text1 = encryptByPrivateKey(keyPair.getPrivateKey(), RsaUtils.SRC);
5757
String text2 = decryptByPublicKey(keyPair.getPublicKey(), text1);
@@ -143,27 +143,27 @@ public static String encryptByPublicKey(String publicKeyText, String text) throw
143143
* @return /
144144
* @throws NoSuchAlgorithmException /
145145
*/
146-
public static RSAKeyPair generateKeyPair() throws NoSuchAlgorithmException {
146+
public static RsaKeyPair generateKeyPair() throws NoSuchAlgorithmException {
147147
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
148148
keyPairGenerator.initialize(1024);
149149
KeyPair keyPair = keyPairGenerator.generateKeyPair();
150150
RSAPublicKey rsaPublicKey = (RSAPublicKey) keyPair.getPublic();
151151
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) keyPair.getPrivate();
152152
String publicKeyString = Base64.encodeBase64String(rsaPublicKey.getEncoded());
153153
String privateKeyString = Base64.encodeBase64String(rsaPrivateKey.getEncoded());
154-
return new RSAKeyPair(publicKeyString, privateKeyString);
154+
return new RsaKeyPair(publicKeyString, privateKeyString);
155155
}
156156

157157

158158
/**
159159
* RSA密钥对对象
160160
*/
161-
public static class RSAKeyPair {
161+
public static class RsaKeyPair {
162162

163163
private final String publicKey;
164164
private final String privateKey;
165165

166-
public RSAKeyPair(String publicKey, String privateKey) {
166+
public RsaKeyPair(String publicKey, String privateKey) {
167167
this.publicKey = publicKey;
168168
this.privateKey = privateKey;
169169
}

eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class AuthorizationController {
6262

6363
@Value("${loginCode.expiration}")
6464
private Long expiration;
65-
@Value("${single.login:false}")
65+
@Value("${single.login}")
6666
private Boolean singleLogin;
6767
private final SecurityProperties properties;
6868
private final RedisUtils redisUtils;

eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.springframework.http.ResponseEntity;
2727
import org.springframework.security.access.prepost.PreAuthorize;
2828
import org.springframework.web.bind.annotation.*;
29-
3029
import javax.servlet.http.HttpServletResponse;
3130
import java.io.IOException;
3231
import java.util.Set;

eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
114114

115115
/**
116116
* 根据角色查询
117+
* @param ids /
117118
* @return /
118119
*/
119120
@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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public Object queryAll(RoleQueryCriteria criteria, Pageable pageable) {
7878
}
7979

8080
@Override
81-
@Transactional
8281
@Cacheable(key = "'id:' + #p0")
82+
@Transactional(rollbackFor = Exception.class)
8383
public RoleDto findById(long id) {
8484
Role role = roleRepository.findById(id).orElseGet(Role::new);
8585
ValidationUtil.isNull(role.getId(),"Role","id",id);

eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public List<UserDto> queryAll(UserQueryCriteria criteria) {
6868
}
6969

7070
@Override
71-
@Transactional
7271
@Cacheable(key = "'id:' + #p0")
72+
@Transactional(rollbackFor = Exception.class)
7373
public UserDto findById(long id) {
7474
User user = userRepository.findById(id).orElseGet(User::new);
7575
ValidationUtil.isNull(user.getId(),"User","id",id);
@@ -177,7 +177,7 @@ public Map<String, String> updateAvatar(MultipartFile multipartFile) {
177177
FileUtil.del(oldPath);
178178
}
179179
redisUtils.del("user::username:" + user.getUsername());
180-
return new HashMap<String,String>(){{put("avatar",file.getName());}};
180+
return new HashMap<String,String>(1){{put("avatar",file.getName());}};
181181
}
182182

183183
@Override

eladmin-system/src/main/resources/config/application-dev.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ spring:
4343
wall:
4444
config:
4545
multi-statement-allow: true
46+
47+
# 是否限制单用户登录
48+
single:
49+
login: false
50+
4651
#jwt
4752
jwt:
4853
header: Authorization

eladmin-system/src/main/resources/config/application-prod.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ spring:
4545
wall:
4646
config:
4747
multi-statement-allow: true
48+
49+
# 是否限制单用户登录
50+
single:
51+
login: false
52+
4853
#jwt
4954
jwt:
5055
header: Authorization

eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ public interface EmailService {
2727

2828
/**
2929
* 更新邮件配置
30-
* @param emailConfig 邮件配置
31-
* @param old 旧的配置
32-
* @return EmailConfig
30+
* @param emailConfig 邮箱配置
31+
* @param old /
32+
* @return /
33+
* @throws Exception /
3334
*/
3435
EmailConfig config(EmailConfig emailConfig, EmailConfig old) throws Exception;
3536

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<java.version>1.8</java.version>
3333
<log4jdbc.version>1.16</log4jdbc.version>
3434
<swagger.version>2.9.2</swagger.version>
35-
<fastjson.version>1.2.68</fastjson.version>
35+
<fastjson.version>1.2.70</fastjson.version>
3636
<druid.version>1.1.22</druid.version>
3737
<commons-pool2.version>2.5.0</commons-pool2.version>
3838
<mapstruct.version>1.3.1.Final</mapstruct.version>

0 commit comments

Comments
 (0)