//查看飞手的飞行任务 public List<BisFlyerVO> getBisFlyerListAll() { List<BisFlyer> bisFlyerList = bisFlyerMapper.selectList(null); List<BisFlyerVO> bisFlyerVOList = new ArrayList<>(); for (BisFlyer bisFlyer : bisFlyerList) { BisFlyerVO bisFlyerVO = new BisFlyerVO(); BeanUtils.copyProperties(bisFlyer, bisFlyerVO); DatSite datSite = datSiteMapper.selectById(bisFlyer.getSiteId()); if (datSite != null) { bisFlyerVO.setStieName(datSite.getSiteName()); } QueryWrapper<BisTask> bisTaskQueryWrapper = new QueryWrapper<>(); bisTaskQueryWrapper.eq("flyer_id", bisFlyer.getId()).eq("task_status", 2); int taskCount = bisTaskMapper.selectCount(bisTaskQueryWrapper); bisFlyerVO.setTaskStatus(String.valueOf(taskCount)); QueryWrapper<BisTask> bisTaskQueryWrapper2 = new QueryWrapper<>(); bisTaskQueryWrapper2.eq("flyer_id", bisFlyer.getId()).eq("task_status", 8) .ge("create_time", LocalDate.now().withDayOfMonth(1)).le("create_time", LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth())); int flyNumber = bisTaskMapper.selectCount(bisTaskQueryWrapper2); bisFlyerVO.setThisMonthFlyNumber(flyNumber); bisFlyerVOList.add(bisFlyerVO); } return bisFlyerVOList; } 把这个方法加个分页,BisFlyerVO继承了 分页VO类 @Data public class PageReqVO { @ApiModelProperty(value = "第几页") @TableField(exist = false) private int page=1; @ApiModelProperty(value = "分页数量") @TableField(exist = false) private int limit=10; }
时间: 2023-12-31 14:05:19 浏览: 187
好的,您的要求是在这个方法中加入分页功能,同时让BisFlyerVO继承分页VO类。可以按照以下步骤进行修改:
1. 在BisFlyerVO类中继承分页VO类PageReqVO:
```
@Data
public class BisFlyerVO extends PageReqVO {
// 其他属性
}
```
2. 在getBisFlyerListAll方法中使用Page对象进行分页:
```
public List<BisFlyerVO> getBisFlyerListAll(int page, int limit) {
Page<BisFlyer> bisFlyerPage = new Page<>(page, limit);
bisFlyerMapper.selectPage(bisFlyerPage, null);
List<BisFlyer> bisFlyerList = bisFlyerPage.getRecords();
List<BisFlyerVO> bisFlyerVOList = new ArrayList<>();
// 其他代码不变
return bisFlyerVOList;
}
```
3. 在调用getBisFlyerListAll方法时传入分页参数,例如:getBisFlyerListAll(1, 10) 表示获取第一页,每页10条记录。
注意:如果您使用的是MyBatis Plus,可以直接在方法参数中添加Page对象,然后在查询中传入该Page对象即可完成分页操作。
相关问题
//查看飞手的飞行任务 public Ipage<BisFlyerVO> getBisFlyerListAll() { List<BisFlyer> bisFlyerList = bisFlyerMapper.selectList(null); List<BisFlyerVO> bisFlyerVOList = new ArrayList<>(); for (BisFlyer bisFlyer : bisFlyerList) { BisFlyerVO bisFlyerVO = new BisFlyerVO(); BeanUtils.copyProperties(bisFlyer, bisFlyerVO); DatSite datSite = datSiteMapper.selectById(bisFlyer.getSiteId()); if (datSite != null) { bisFlyerVO.setStieName(datSite.getSiteName()); } QueryWrapper<BisTask> bisTaskQueryWrapper = new QueryWrapper<>(); bisTaskQueryWrapper.eq("flyer_id", bisFlyer.getId()).eq("task_status", 2); int taskCount = bisTaskMapper.selectCount(bisTaskQueryWrapper); bisFlyerVO.setTaskStatus(String.valueOf(taskCount)); QueryWrapper<BisTask> bisTaskQueryWrapper2 = new QueryWrapper<>(); bisTaskQueryWrapper2.eq("flyer_id", bisFlyer.getId()).eq("task_status", 8) .ge("create_time", LocalDate.now().withDayOfMonth(1)).le("create_time", LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth())); int flyNumber = bisTaskMapper.selectCount(bisTaskQueryWrapper2); bisFlyerVO.setThisMonthFlyNumber(flyNumber); bisFlyerVOList.add(bisFlyerVO); } return bisFlyerVOList; } 把这个方法加个分页,参数改成BisFlyerVO bisFlyerVO,BisFlyerVO继承了 分页VO类 @Data public class PageReqVO { @ApiModelProperty(value = "第几页") @TableField(exist = false) private int page=1; @ApiModelProperty(value = "分页数量") @TableField(exist = false) private int limit=10; }
好的,您的要求是在这个方法中加入分页功能,同时将方法返回类型改为IPage<BisFlyerVO>。可以按照以下步骤进行修改:
1. 在BisFlyerVO类中继承分页VO类PageReqVO:
```
@Data
public class BisFlyerVO extends PageReqVO {
// 其他属性
}
```
2. 在getBisFlyerListAll方法中使用Page对象进行分页,并将方法返回类型改为IPage<BisFlyerVO>:
```
public IPage<BisFlyerVO> getBisFlyerListAll(BisFlyerVO bisFlyerVO) {
Page<BisFlyer> bisFlyerPage = new Page<>(bisFlyerVO.getPage(), bisFlyerVO.getLimit());
bisFlyerMapper.selectPage(bisFlyerPage, null);
List<BisFlyer> bisFlyerList = bisFlyerPage.getRecords();
List<BisFlyerVO> bisFlyerVOList = new ArrayList<>();
for (BisFlyer bisFlyer : bisFlyerList) {
BisFlyerVO bisFlyerVO = new BisFlyerVO();
BeanUtils.copyProperties(bisFlyer, bisFlyerVO);
DatSite datSite = datSiteMapper.selectById(bisFlyer.getSiteId());
if (datSite != null) {
bisFlyerVO.setStieName(datSite.getSiteName());
}
QueryWrapper<BisTask> bisTaskQueryWrapper = new QueryWrapper<>();
bisTaskQueryWrapper.eq("flyer_id", bisFlyer.getId()).eq("task_status", 2);
int taskCount = bisTaskMapper.selectCount(bisTaskQueryWrapper);
bisFlyerVO.setTaskStatus(String.valueOf(taskCount));
QueryWrapper<BisTask> bisTaskQueryWrapper2 = new QueryWrapper<>();
bisTaskQueryWrapper2.eq("flyer_id", bisFlyer.getId()).eq("task_status", 8)
.ge("create_time", LocalDate.now().withDayOfMonth(1)).le("create_time", LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()));
int flyNumber = bisTaskMapper.selectCount(bisTaskQueryWrapper2);
bisFlyerVO.setThisMonthFlyNumber(flyNumber);
bisFlyerVOList.add(bisFlyerVO);
}
return new PageImpl<>(bisFlyerVOList, bisFlyerPage, bisFlyerPage.getTotal());
}
```
3. 在调用getBisFlyerListAll方法时传入BisFlyerVO对象,其中的page和limit属性表示分页参数。
注意:如果您使用的是MyBatis Plus,可以直接在方法参数中添加Page对象,然后在查询中传入该Page对象即可完成分页操作。
帮我解释一下下面的代码 public PageResponse<QuestionVo> getQuestionVoByIds(List<Integer> ids) { List<Question> questions = questionMapper.selectBatchIds(ids); List<Answer> answers = answerMapper.selectList(new QueryWrapper<Answer>().in("question_id", ids)); List<QuestionVo> questionVos = questions.stream() .map(question -> { Answer currentQuestionAnswer = answers.stream() .filter(answer -> answer.getQuestionId().equals(question.getId())) .findFirst() .orElse(null); return buildQuestionVoByQuestionAndAnswer(question, currentQuestionAnswer); }).collect(Collectors.toList()); return PageResponse.<QuestionVo>builder() .data(questionVos) .total(questionVos.size()) .build();
这段代码是一个方法,它接受一个整数列表作为参数,返回一个包含QuestionVo对象的PageResponse对象。
首先,代码从数据库中获取与给定id列表匹配的Question对象列表。接着,它使用给定的ids列表查询数据库中与这些ids匹配的Answer对象列表。
然后,代码使用流操作对问题列表进行映射。对于每个问题,它通过筛选与该问题id相匹配的答案对象,并将其构建为QuestionVo对象。最后,使用Collectors.toList()将所有的QuestionVo对象收集到一个列表中。
最后,通过PageResponse.builder()创建一个PageResponse对象,并设置data属性为问题Vo对象列表,total属性为问题Vo对象列表的大小,然后返回该PageResponse对象。
阅读全文
相关推荐















返回
单号:
g
i
d
<
/
s
p
a
n
>
<
/
d
i
v
>
<
d
i
v
c
l
a
s
s
=
"
r
i
g
h
t
i
n
f
o
"
>
<
t
a
b
l
e
c
l
a
s
s
=
"
t
a
b
l
e
l
i
s
t
"
>
<
t
h
e
a
d
>
<
t
r
>
<
t
h
>
编号
<
/
t
h
>
<
t
h
>
名称
<
/
t
h
>
<
t
h
>
价格
<
/
t
h
>
<
t
h
>
数量
<
/
t
h
>
<
t
h
>
购买时间
<
/
t
h
>
<
/
t
r
>
<
/
t
h
e
a
d
>
<
t
b
o
d
y
>
<
c
:
f
o
r
E
a
c
h
i
t
e
m
s
=
"
gid</span></span><span><span><thead><tr><th>编号</th><th>名称</th><th>价格</th><th>数量</th><th>购买时间</th></tr></thead><tbody><c:forEachitems="{somerkqk }" var=“xsqk” varStatus=“status”>
s
t
a
t
u
s
.
i
n
d
e
x
+
1
<
/
t
d
>
<
t
d
>
status.index+1 {xsqk.name }
x
s
q
k
.
p
r
i
c
e
<
/
t
d
>
<
t
d
>
xsqk.price {xsqk.sl }
${xsqk.dtime }
</c:forEach>
用这些数据在MyEclipse加一个分析数据页面,代码简单一些,使用Servlet 2.5,DAO叫做lssRkqkDAO

