[代码完善](v2.5): v2.5 beta 更新 fastjson 版本,代码优化

pull/394/head
ZhengJie 2020-06-04 10:28:14 +08:00
parent b699d32546
commit 3d53a3a0ec
10 changed files with 27 additions and 16 deletions

View File

@ -19,7 +19,7 @@ public class RsaUtils {
public static void main(String[] args) throws Exception {
System.out.println("\n");
RSAKeyPair keyPair = generateKeyPair();
RsaKeyPair 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(RSAKeyPair keyPair) throws Exception {
private static void test1(RsaKeyPair 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(RSAKeyPair keyPair) throws Exception {
private static void test2(RsaKeyPair 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 RSAKeyPair generateKeyPair() throws NoSuchAlgorithmException {
public static RsaKeyPair 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 RSAKeyPair(publicKeyString, privateKeyString);
return new RsaKeyPair(publicKeyString, privateKeyString);
}
/**
* RSA
*/
public static class RSAKeyPair {
public static class RsaKeyPair {
private final String publicKey;
private final String privateKey;
public RSAKeyPair(String publicKey, String privateKey) {
public RsaKeyPair(String publicKey, String privateKey) {
this.publicKey = publicKey;
this.privateKey = privateKey;
}

View File

@ -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;

View File

@ -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;

View File

@ -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 " +

View File

@ -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);

View File

@ -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

View File

@ -43,6 +43,11 @@ spring:
wall:
config:
multi-statement-allow: true
# 是否限制单用户登录
single:
login: false
#jwt
jwt:
header: Authorization

View File

@ -45,6 +45,11 @@ spring:
wall:
config:
multi-statement-allow: true
# 是否限制单用户登录
single:
login: false
#jwt
jwt:
header: Authorization

View File

@ -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;

View File

@ -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>