feat: There is no way the, TO optimize the query
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package com.adc.da.util;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.UnavailableSecurityManagerException;
|
||||
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||
import org.apache.shiro.session.InvalidSessionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class UserSysUtils {
|
||||
|
||||
private UserSysUtils() {
|
||||
super();
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(UserSysUtils.class);
|
||||
|
||||
/**
|
||||
* 当前登陆用户
|
||||
*/
|
||||
public static final String CURRENT_USER = "currentUser";
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
public static final String CACHE_ROLE_LIST = "roleList";
|
||||
/**
|
||||
* 菜单信息
|
||||
*/
|
||||
public static final String CACHE_MENU_LIST = "menuList";
|
||||
public static final String CACHE_MENU_TREE = "menuTree";
|
||||
public static final String CACHE_AREA_LIST = "areaList";
|
||||
public static final String CACHE_OFFICE_LIST = "officeList";
|
||||
|
||||
/**
|
||||
* @see JwtSysUtils
|
||||
*/
|
||||
private static JwtSysUtils jwtUtils = SpringContextHolder1.getBean(JwtSysUtils.class);
|
||||
|
||||
/**
|
||||
* 退出
|
||||
*/
|
||||
public static void logout() {
|
||||
try {
|
||||
SecurityUtils.getSubject().logout();
|
||||
} catch (UnavailableSecurityManagerException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
} catch (InvalidSessionException e) {
|
||||
logger.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前登陆用户ID
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String getUserId() {
|
||||
return jwtUtils.getUserIdByToken();
|
||||
}
|
||||
|
||||
|
||||
public static void flush() {
|
||||
CacheUtils.removeCache(CURRENT_USER);
|
||||
}
|
||||
|
||||
private static final class CacheUtils {
|
||||
|
||||
public static Object getCache(String key) {
|
||||
return getCache(key, null);
|
||||
}
|
||||
|
||||
public static Object getCache(String key, Object defaultValue) {
|
||||
Object obj = getCacheMap().get(key);
|
||||
return obj == null ? defaultValue : obj;
|
||||
}
|
||||
|
||||
public static void putCache(String key, Object value) {
|
||||
getCacheMap().put(key, value);
|
||||
}
|
||||
|
||||
public static void removeCache(String key) {
|
||||
getCacheMap().remove(key);
|
||||
}
|
||||
|
||||
public static Map<String, Object> getCacheMap() {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user