fix: 在线用户显示异常
This commit is contained in:
@@ -15,8 +15,8 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
|
||||
* List 分页
|
||||
*/
|
||||
public static <T> List<T> paging(int page, int size, List<T> list) {
|
||||
int fromIndex = page * size;
|
||||
int toIndex = page * size + size;
|
||||
int fromIndex = (page - 1) * size;
|
||||
int toIndex = (page - 1) * size + size;
|
||||
if (fromIndex > list.size()) {
|
||||
return Collections.emptyList();
|
||||
} else if (toIndex >= list.size()) {
|
||||
|
||||
+2
-3
@@ -2,7 +2,7 @@ package cn.odboy.modules.security.rest;
|
||||
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.model.system.dto.OnlineUserDto;
|
||||
import cn.odboy.modules.security.service.impl.OnlineUserServiceImpl;
|
||||
import cn.odboy.modules.security.service.OnlineUserService;
|
||||
import cn.odboy.util.EncryptUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -23,8 +23,7 @@ import java.util.Set;
|
||||
@RequestMapping("/auth/online")
|
||||
@Api(tags = "系统:在线用户管理")
|
||||
public class OnlineController {
|
||||
|
||||
private final OnlineUserServiceImpl onlineUserService;
|
||||
private final OnlineUserService onlineUserService;
|
||||
|
||||
@ApiOperation("查询在线用户")
|
||||
@GetMapping
|
||||
|
||||
+2
-4
@@ -48,10 +48,8 @@ public class OnlineUserServiceImpl implements OnlineUserService {
|
||||
@Override
|
||||
public PageResult<OnlineUserDto> getAll(String username, Pageable pageable) {
|
||||
List<OnlineUserDto> onlineUserDtos = getAll(username);
|
||||
return PageUtil.toPage(
|
||||
PageUtil.paging(pageable.getPageNumber(), pageable.getPageSize(), onlineUserDtos),
|
||||
onlineUserDtos.size()
|
||||
);
|
||||
List<OnlineUserDto> paging = PageUtil.paging(pageable.getPageNumber(), pageable.getPageSize(), onlineUserDtos);
|
||||
return PageUtil.toPage(paging, onlineUserDtos.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user