mirror of https://github.com/elunez/eladmin
[代码完善](v2.5): v2.5 beta 更新 fastjson 版本,代码优化
parent
b699d32546
commit
3d53a3a0ec
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 " +
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -43,6 +43,11 @@ spring:
|
|||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
|
||||
# 是否限制单用户登录
|
||||
single:
|
||||
login: false
|
||||
|
||||
#jwt
|
||||
jwt:
|
||||
header: Authorization
|
||||
|
|
|
@ -45,6 +45,11 @@ spring:
|
|||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
|
||||
# 是否限制单用户登录
|
||||
single:
|
||||
login: false
|
||||
|
||||
#jwt
|
||||
jwt:
|
||||
header: Authorization
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue