增加在线排序queryByPage

This commit is contained in:
irving
2025-08-31 12:42:08 -04:00
parent 662eb93289
commit 1c4d8776df
2 changed files with 33 additions and 29 deletions

View File

@@ -347,27 +347,6 @@ public class WxClerkController {
public R queryByPage(@RequestBody PlayClerkUserInfoQueryVo vo) {
IPage<PlayClerkUserInfoResultVo> page = playClerkUserInfoService.selectByPage(vo,
customUserService.getLoginUserId());
// 对记录进行排序,优先显示在线店员
if (page.getRecords() != null && !page.getRecords().isEmpty()) {
page.getRecords().sort((clerk1, clerk2) -> {
// 在线状态优先级:"1"(在线)排在"0"(离线)之前
String onlineState1 = clerk1.getOnlineState();
String onlineState2 = clerk2.getOnlineState();
// 如果两者在线状态相同,保持原有顺序
if (onlineState1 != null && onlineState2 != null) {
// 反向比较,使"1"排在"0"之前
return onlineState2.compareTo(onlineState1);
}
// 处理空值情况将null视为离线状态"0"
if (onlineState1 == null && onlineState2 == null)
return 0;
if (onlineState1 == null)
return 1; // null视为离线排在在线之后
if (onlineState2 == null)
return -1; // null视为离线排在在线之后
return onlineState2.compareTo(onlineState1);
});
}
return R.ok(page);
}