记录一下,看官方文档比较慢
Join查询
public List<TzLyApproveData> selectTzLyApproveDataList(TzLyApproveData tzLyApproveData) {
MPJLambdaWrapper<TzLyApproveData> queryWrapper = JoinWrappers.lambda(TzLyApproveData.class);
queryWrapper.selectAll(TzLyApproveData.class)
.selectAs("createdApprove", TzLyLeaveUser::getUsername, TzLyApproveData::getCreatedApproveUserName)
.selectAs("approve", TzLyLeaveUser::getUsername, TzLyApproveData::getApproveUserName)
.selectAs("dept", SysDept::getDeptName, TzLyApproveData::getCreatedApproveUnitOfficeName)
.leftJoin(TzLyLeaveUser.class, "createdApprove", on -> on.eq(TzLyApproveData::getCreatedApproveUserId, TzLyLeaveUser::getLyUserId))
.leftJoin(TzLyLeaveUser.class, "approve", on -> on.eq(TzLyApproveData::getApproveUserId, TzLyLeaveUser::getLyUserId))
.leftJoin(SysDept.class, "dept", on -> on.eq(TzLyLeaveUser::getUnitOffice, SysDept::getDeptId));
queryWrapper.in(TzLyApproveData::getApproveState, Arrays.asList(2, 3, 4));
queryWrapper.eq(TzLyApproveData::getDelState, "1");
queryWrapper.orderByDesc(TzLyApproveData::getCreatedDate);
if (ObjectUtils.isNotEmpty(tzLyApproveData)) {
queryWrapper.like(StringUtils.isNotBlank(tzLyApproveData.getCreatedApproveUserName()), TzLyLeaveUser::getUsername, tzLyApproveData.getCreatedApproveUserName());
queryWrapper.eq(ObjectUtils.isNotEmpty(tzLyApproveData.getCreatedApproveUnitOffice()), TzLyLeaveUser::getUnitOffice, tzLyApproveData.getCreatedApproveUnitOffice());
if (ObjectUtils.isNotEmpty(tzLyApproveData.getReportStart()) && ObjectUtils.isNotEmpty(tzLyApproveData.getReportEnd())) {
queryWrapper.between(TzLyApproveData::getReportStart, tzLyApproveData.getReportStart(), tzLyApproveData.getReportEnd());
}
queryWrapper.eq(ObjectUtils.isNotEmpty(tzLyApproveData.getApproveState()), TzLyApproveData::getApproveState, tzLyApproveData.getApproveState());
}
return this.list(queryWrapper);
}
批量模糊查询
public List<SubReviewForm> getAllReviewChildByIds(String publishingId, List<String> ids, String systemType, String sort) {
LambdaQueryWrapper<SubReviewForm> queryWrapper = new LambdaQueryWrapper<>();
//管理端能查看全部评论,app只能看显示评论
if (StringUtils.equals("app", systemType)) {
queryWrapper.eq(SubReviewForm::getIsShow, 0);
}
queryWrapper.eq(SubReviewForm::getIsDeleted, 0);
queryWrapper.and(q -> {
for (String id : ids) {
q.likeRight(SubReviewForm::getSubPublishingPath, publishingId + "," + id);
}
});
if (StringUtils.equals(sort, "ASC")) {
queryWrapper.orderByAsc(SubReviewForm::getCreateTime);
} else {
queryWrapper.orderByDesc(SubReviewForm::getCreateTime);
}
return this.list(queryWrapper);
}