Commit 0eb470e6 authored by yanzg's avatar yanzg

身份证识别

parent abd36a95
......@@ -2,10 +2,10 @@ package com.yanzuoguang.token;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.cache.MemoryCache;
import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.RsaHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.vo.MapRow;
/**
......@@ -41,7 +41,7 @@ public class TokenHelper {
/**
* 内存缓存
*/
protected final static MemoryCache<TokenData> cache = new MemoryCache<>();
protected final static ThreadLocal<TokenData> cache = new ThreadLocal<>();
/**
......@@ -59,8 +59,7 @@ public class TokenHelper {
* @return 缓存的数据
*/
public static TokenData getTokenData(boolean readNewToken) {
String id = getCurrentId();
TokenData cacheTokenData = cache.get(id);
TokenData cacheTokenData = cache.get();
if (cacheTokenData == null) {
return null;
}
......@@ -77,7 +76,7 @@ public class TokenHelper {
if (databaseToken == null || databaseToken.getData() == null) {
return null;
} else {
cache.put(id, databaseToken);
cache.set(databaseToken);
return databaseToken;
}
}
......@@ -116,7 +115,9 @@ public class TokenHelper {
* @return 缓存的数据
*/
public static <T> T get(boolean checkFlag, Class<T> cls, boolean readNewToken) {
Log.info(TokenHelper.class, "获取登陆信息结果");
TokenData tokenData = getTokenData(readNewToken);
Log.info(TokenHelper.class, "获取登陆信息结果");
if (tokenData == null) {
if (checkFlag) {
throw YzgError.getRuntimeException("061");
......@@ -243,10 +244,11 @@ public class TokenHelper {
* @param tokenString 登录标记字符串
*/
public static TokenData setTokenString(String tokenString) {
String id = getCurrentId();
TokenData tokenData = JsonHelper.deserialize(tokenString, TokenData.class);
cache.put(id, tokenData);
if (tokenData != null) {
tokenData.setWrite(false);
}
cache.set(tokenData);
return tokenData;
}
......@@ -256,8 +258,7 @@ public class TokenHelper {
* @return 登录标记字符粗
*/
public static String getTokenString() {
String id = getCurrentId();
TokenData tokenData = cache.get(id);
TokenData tokenData = cache.get();
if (tokenData == null) {
return StringHelper.EMPTY;
}
......@@ -269,7 +270,6 @@ public class TokenHelper {
* 删除缓存信息
*/
public static void remove() {
String id = getCurrentId();
cache.remove(id);
cache.remove();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment