Object array List to Page type (mybatisplus)

		// 分页代码片段
		// T表示对象实体 list是所要处理的列表数据
		Page<T> page = new Page<>(1,10);
        // 当前页第一条数据在List中的位置
        int start = (int)((page.getCurrent() - 1) * page.getSize());
        // 当前页最后一条数据在List中的位置
        int end = (int)((start + page.getSize()) > list.size() ? list.size() : (page.getSize() * page.getCurrent()));
        page.setRecords(new ArrayList<>());
        page.setTotal(list.size());
        if (page.getSize()*(page.getCurrent()-1) <= page.getTotal()) {
        	// 分隔列表 当前页存在数据时 设置	
            page.setRecords(list.subList(start, end));
        }
        return page;

When using mybatisplus to execute queries, using too many table connections makes it difficult to deduplicate based on a single column, so take the queried data list, get all the data, and turn it into a paging object

Guess you like

Origin blog.csdn.net/qq_27246521/article/details/130830564