记录一下,看官方文档比较慢
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);
}