mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-09-19 10:08:07 +08:00
会话查询API增加反序获取会话方式
This commit is contained in:
@@ -170,9 +170,11 @@ public interface SaTokenDao {
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return 查询到的数据集合
|
||||
*/
|
||||
public List<String> searchData(String prefix, String keyword, int start, int size);
|
||||
public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -240,8 +240,8 @@ public class SaTokenDaoDefaultImpl implements SaTokenDao {
|
||||
// --------------------- 会话管理
|
||||
|
||||
@Override
|
||||
public List<String> searchData(String prefix, String keyword, int start, int size) {
|
||||
return SaFoxUtil.searchList(expireMap.keySet(), prefix, keyword, start, size);
|
||||
public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType) {
|
||||
return SaFoxUtil.searchList(expireMap.keySet(), prefix, keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1499,10 +1499,12 @@ public class StpLogic {
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return token集合
|
||||
*/
|
||||
public List<String> searchTokenValue(String keyword, int start, int size) {
|
||||
return getSaTokenDao().searchData(splicingKeyTokenValue(""), keyword, start, size);
|
||||
public List<String> searchTokenValue(String keyword, int start, int size, boolean sortType) {
|
||||
return getSaTokenDao().searchData(splicingKeyTokenValue(""), keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1510,10 +1512,12 @@ public class StpLogic {
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return sessionId集合
|
||||
*/
|
||||
public List<String> searchSessionId(String keyword, int start, int size) {
|
||||
return getSaTokenDao().searchData(splicingKeySession(""), keyword, start, size);
|
||||
public List<String> searchSessionId(String keyword, int start, int size, boolean sortType) {
|
||||
return getSaTokenDao().searchData(splicingKeySession(""), keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1521,10 +1525,12 @@ public class StpLogic {
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return sessionId集合
|
||||
*/
|
||||
public List<String> searchTokenSessionId(String keyword, int start, int size) {
|
||||
return getSaTokenDao().searchData(splicingKeyTokenSession(""), keyword, start, size);
|
||||
public List<String> searchTokenSessionId(String keyword, int start, int size, boolean sortType) {
|
||||
return getSaTokenDao().searchData(splicingKeyTokenSession(""), keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -692,10 +692,12 @@ public class StpUtil {
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return token集合
|
||||
*/
|
||||
public static List<String> searchTokenValue(String keyword, int start, int size) {
|
||||
return stpLogic.searchTokenValue(keyword, start, size);
|
||||
public static List<String> searchTokenValue(String keyword, int start, int size, boolean sortType) {
|
||||
return stpLogic.searchTokenValue(keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -703,10 +705,12 @@ public class StpUtil {
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return sessionId集合
|
||||
*/
|
||||
public static List<String> searchSessionId(String keyword, int start, int size) {
|
||||
return stpLogic.searchSessionId(keyword, start, size);
|
||||
public static List<String> searchSessionId(String keyword, int start, int size, boolean sortType) {
|
||||
return stpLogic.searchSessionId(keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -714,10 +718,12 @@ public class StpUtil {
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return sessionId集合
|
||||
*/
|
||||
public static List<String> searchTokenSessionId(String keyword, int start, int size) {
|
||||
return stpLogic.searchTokenSessionId(keyword, start, size);
|
||||
public static List<String> searchTokenSessionId(String keyword, int start, int size, boolean sortType) {
|
||||
return stpLogic.searchTokenSessionId(keyword, start, size, sortType);
|
||||
}
|
||||
|
||||
|
||||
@@ -920,5 +926,50 @@ public class StpUtil {
|
||||
public static void logoutByLoginId(Object loginId, String device) {
|
||||
stpLogic.kickout(loginId, device);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1> 本函数设计已过时,未来版本可能移除此函数,请及时更换为 StpUtil.searchTokenValue(keyword, start, size, sortType) ,使用方式保持不变 </h1>
|
||||
*
|
||||
* 根据条件查询Token
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
*
|
||||
* @return token集合
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> searchTokenValue(String keyword, int start, int size) {
|
||||
return stpLogic.searchTokenValue(keyword, start, size, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1> 本函数设计已过时,未来版本可能移除此函数,请及时更换为 StpUtil.searchSessionId(keyword, start, size, sortType) ,使用方式保持不变 </h1>
|
||||
*
|
||||
* 根据条件查询SessionId
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
*
|
||||
* @return sessionId集合
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> searchSessionId(String keyword, int start, int size) {
|
||||
return stpLogic.searchSessionId(keyword, start, size, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* <h1> 本函数设计已过时,未来版本可能移除此函数,请及时更换为 StpUtil.searchTokenSessionId(keyword, start, size, sortType) ,使用方式保持不变 </h1>
|
||||
*
|
||||
* 根据条件查询Token专属Session的Id
|
||||
* @param keyword 关键字
|
||||
* @param start 开始处索引 (-1代表查询所有)
|
||||
* @param size 获取数量
|
||||
*
|
||||
* @return sessionId集合
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> searchTokenSessionId(String keyword, int start, int size) {
|
||||
return stpLogic.searchTokenSessionId(keyword, start, size, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -111,10 +112,11 @@ public class SaFoxUtil {
|
||||
* @param keyword 关键字
|
||||
* @param start 起始位置 (-1代表查询所有)
|
||||
* @param size 获取条数
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return 符合条件的新数据集合
|
||||
*/
|
||||
public static List<String> searchList(Collection<String> dataList, String prefix, String keyword, int start,
|
||||
int size) {
|
||||
public static List<String> searchList(Collection<String> dataList, String prefix, String keyword, int start, int size, boolean sortType) {
|
||||
if (prefix == null) {
|
||||
prefix = "";
|
||||
}
|
||||
@@ -131,7 +133,7 @@ public class SaFoxUtil {
|
||||
}
|
||||
}
|
||||
// 取指定段数据
|
||||
return searchList(list, start, size);
|
||||
return searchList(list, start, size, sortType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,9 +142,15 @@ public class SaFoxUtil {
|
||||
* @param list 数据集合
|
||||
* @param start 起始位置 (-1代表查询所有)
|
||||
* @param size 获取条数
|
||||
* @param sortType 排序类型(true=正序,false=反序)
|
||||
*
|
||||
* @return 符合条件的新数据集合
|
||||
*/
|
||||
public static List<String> searchList(List<String> list, int start, int size) {
|
||||
public static List<String> searchList(List<String> list, int start, int size, boolean sortType) {
|
||||
// 如果是反序的话
|
||||
if(sortType == false) {
|
||||
Collections.reverse(list);
|
||||
}
|
||||
// 取指定段数据
|
||||
if (start < 0) {
|
||||
return list;
|
||||
|
Reference in New Issue
Block a user