diff --git a/dq-financial-api/pom.xml b/dq-financial-api/pom.xml index 953d6176..4c8f7567 100644 --- a/dq-financial-api/pom.xml +++ b/dq-financial-api/pom.xml @@ -29,17 +29,17 @@ org.springframework.boot spring-boot-starter-web --> - + - + \ No newline at end of file diff --git a/dq-financial-api/src/main/java/com/daqing/financial/DqFinancialApiApplication.java b/dq-financial-api/src/main/java/com/daqing/financial/DqFinancialApiApplication.java new file mode 100644 index 00000000..96efe364 --- /dev/null +++ b/dq-financial-api/src/main/java/com/daqing/financial/DqFinancialApiApplication.java @@ -0,0 +1,13 @@ +package com.daqing.financial; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@SpringBootApplication +@EnableSwagger2 +public class DqFinancialApiApplication { + public static void main(String[] args) { + SpringApplication.run(DqFinancialApiApplication.class, args); + } +} diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java index b5018c58..0551e573 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java @@ -138,7 +138,7 @@ public class UserLoginServiceImpl extends ServiceImpl if(loginRequest.getTenDayEffective() == 1){ times = 846000; } - String token = JwtUtils.createJWT(userEntity.getId(),"token", times); + String token = JwtUtils.createJWT(userEntity.getId()+"","token", times); Token userToken = tokenService.getOne(new QueryWrapper().eq("user_id", userEntity.getId())); if(userToken != null){ //删除redis里面的token diff --git a/dq-framework-common/pom.xml b/dq-framework-common/pom.xml index d97eea6d..9d7931c5 100644 --- a/dq-framework-common/pom.xml +++ b/dq-framework-common/pom.xml @@ -57,7 +57,11 @@ commons-lang3 3.8.1 - + + com.fasterxml.jackson.core + jackson-annotations + 2.9.7 + io.springfox @@ -70,11 +74,6 @@ 2.7.0 - - com.auth0 - java-jwt - 3.2.0 - io.jsonwebtoken jjwt @@ -111,11 +110,11 @@ - + diff --git a/dq-framework-common/src/main/java/com/daqing/framework/util/JwtUtils.java b/dq-framework-common/src/main/java/com/daqing/framework/util/JwtUtils.java index e6eeda6f..1ed07988 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/util/JwtUtils.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/util/JwtUtils.java @@ -6,7 +6,7 @@ import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.JwtBuilder; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; -import org.bouncycastle.util.encoders.Base64; +import org.apache.commons.codec.binary.Base64; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; @@ -23,7 +23,7 @@ public class JwtUtils { * @return String * */ - public static String createJWT(Long id, String subject, long ttlMillis) { + public static String createJWT(String id, String subject, long ttlMillis) { SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; long nowMillis = System.currentTimeMillis(); Date now = new Date(nowMillis); @@ -41,9 +41,9 @@ public class JwtUtils { } public static void main(String[] args) { - //System.out.printf(createJWT("1","111", 10000000)); - boolean isTrue = validateJWT("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwic3ViIjoiMTExIiwiaXNzIjoidXNlciIsImlhdCI6MTYwMTM0MzYyNywiZXhwIjoxNjAxMzUzNjI3fQ.q5Ssg2LM1OzzgvVWqLhgP_Hko0-pfeNO5bvpUE5KQ-s"); - System.out.println(isTrue); + System.out.println(validateJWT(createJWT("1","123",100000))); + //byte[] encodedKey = Base64.decode("DQJWT"); + //System.out.println(encodedKey); } /** @@ -69,7 +69,7 @@ public class JwtUtils { } public static SecretKey generalKey() { - byte[] encodedKey = Base64.decode("JWTDQ123456"); + byte[] encodedKey = Base64.decodeBase64("DQJWT"); SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); return key; } diff --git a/dq-framework-common/src/main/java/com/daqing/framework/util/Md5Util.java b/dq-framework-common/src/main/java/com/daqing/framework/util/Md5Util.java index ec639040..870f5e5a 100644 --- a/dq-framework-common/src/main/java/com/daqing/framework/util/Md5Util.java +++ b/dq-framework-common/src/main/java/com/daqing/framework/util/Md5Util.java @@ -3,6 +3,9 @@ package com.daqing.framework.util; import org.springframework.util.DigestUtils; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + /** * @author zcw * @version 1.0 @@ -18,7 +21,9 @@ public class Md5Util { return DigestUtils.md5DigestAsHex(str.getBytes()); } - public static void main(String[] args) { - System.out.printf(md5("1234561")); + public static void main(String[] args) throws UnsupportedEncodingException { + //System.out.printf(md5("1234561")); + String s = URLEncoder.encode("www.occupationlab.com", "utf-8"); + System.out.println(s); } }