Java Code Examples for com.querydsl.jpa.impl.JPAQuery#where()
The following examples show how to use
com.querydsl.jpa.impl.JPAQuery#where() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MemberApplicationService.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<MemberApplication> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<MemberApplication> list; JPAQuery<MemberApplication> jpaQuery = queryFactory.selectFrom(memberApplication); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } jpaQuery.orderBy(memberApplication.createTime.desc()); if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 2
Source File: SysAdvertiseService.java From ZTuoExchange_framework with MIT License | 6 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<SysAdvertise> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<SysAdvertise> list; JPAQuery<SysAdvertise> jpaQuery = queryFactory.selectFrom(sysAdvertise); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)) .offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)).fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 3
Source File: OtcCoinService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<OtcCoin> queryWhereOrPage(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { List<OtcCoin> list; JPAQuery<OtcCoin> jpaQuery = queryFactory.selectFrom(QOtcCoin.otcCoin); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 4
Source File: AccessCodeRepository.java From jump-the-queue with Apache License 2.0 | 5 votes |
/** * @param criteria the {@link AccessCodeSearchCriteriaTo} with the criteria * to search. * @param pageRequest {@link Pageable} implementation used to set page * properties like page size * @return the {@link Page} of the {@link AccessCodeEntity} objects that matched * the search. */ default Page<AccessCodeEntity> findByCriteria(AccessCodeSearchCriteriaTo criteria) { AccessCodeEntity alias = newDslAlias(); JPAQuery<AccessCodeEntity> query = newDslQuery(alias); String ticketNumber = criteria.getTicketNumber(); if (ticketNumber != null && !ticketNumber.isEmpty()) { QueryUtil.get().whereString(query, $(alias.getTicketNumber()), ticketNumber, criteria.getTicketNumberOption()); } Timestamp creationTime = criteria.getCreationTime(); if (creationTime != null) { query.where($(alias.getCreationTime()).eq(creationTime)); } Timestamp startTime = criteria.getStartTime(); if (startTime != null) { query.where($(alias.getStartTime()).eq(startTime)); } Timestamp endTime = criteria.getEndTime(); if (endTime != null) { query.where($(alias.getEndTime()).eq(endTime)); } Long visitor = criteria.getVisitorId(); if (visitor != null) { query.where($(alias.getVisitor().getId()).eq(visitor)); } Long queue = criteria.getQueueId(); if (queue != null) { query.where($(alias.getQueue().getId()).eq(queue)); } addOrderBy(query, alias, criteria.getPageable().getSort()); return QueryUtil.get().findPaginated(criteria.getPageable(), query, true); }
Example 5
Source File: AdminAccessLogService.java From ZTuoExchange_framework with MIT License | 5 votes |
@Transactional(readOnly = true) public PageResult<AdminAccessLog> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<AdminAccessLog> list; JPAQuery<AdminAccessLog> jpaQuery = queryFactory.selectFrom(QAdminAccessLog.adminAccessLog); if (predicateList != null && predicateList.size() > 0) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount());//添加总条数 }
Example 6
Source File: MemberTransactionService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<MemberTransaction> queryWhereOrPage(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { List<MemberTransaction> list; JPAQuery<MemberTransaction> jpaQuery = queryFactory.selectFrom(QMemberTransaction.memberTransaction); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 7
Source File: SysAdvertiseService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<SysAdvertise> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<SysAdvertise> list; JPAQuery<SysAdvertise> jpaQuery = queryFactory.selectFrom(sysAdvertise); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)) .offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)).fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 8
Source File: CoinService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<Coin> query(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { List<Coin> list; JPAQuery<Coin> jpaQuery = queryFactory.selectFrom(QCoin.coin); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount());//添加总条数 }
Example 9
Source File: BusinessAuthApplyService.java From ZTuoExchange_framework with MIT License | 5 votes |
public MessageResult detail(Long id){ QBusinessAuthApply qBusinessAuthApply = QBusinessAuthApply.businessAuthApply ; JPAQuery<BusinessAuthApplyDetailVO> query = queryFactory.select( Projections.fields(BusinessAuthApplyDetailVO.class,qBusinessAuthApply.id.as("id") ,qBusinessAuthApply.certifiedBusinessStatus.as("status") ,qBusinessAuthApply.amount.as("amount") ,qBusinessAuthApply.authInfo.as("authInfo") ,qBusinessAuthApply.member.realName.as("realName") ,qBusinessAuthApply.detail.as("detail") ,qBusinessAuthApply.auditingTime.as("checkTime"))).from(qBusinessAuthApply); query.where(qBusinessAuthApply.id.eq(id)) ; BusinessAuthApplyDetailVO vo = query.fetchOne() ; MessageResult result; String jsonStr = vo.getAuthInfo() ; log.info("认证信息 jsonStr = {}", jsonStr); if (StringUtils.isEmpty(jsonStr)) { result = MessageResult.error("认证相关信息不存在"); result.setData(vo); return result; } try { JSONObject json = JSONObject.parseObject(jsonStr); vo.setInfo(json); result = MessageResult.success("认证详情"); result.setData(vo); return result; } catch (Exception e) { log.info("认证信息格式异常:{}", e); result = MessageResult.error("认证信息格式异常"); return result; } }
Example 10
Source File: BusinessAuthApplyService.java From ZTuoExchange_framework with MIT License | 5 votes |
public MessageResult detail(Long id){ QBusinessAuthApply qBusinessAuthApply = QBusinessAuthApply.businessAuthApply ; JPAQuery<BusinessAuthApplyDetailVO> query = queryFactory.select( Projections.fields(BusinessAuthApplyDetailVO.class,qBusinessAuthApply.id.as("id") ,qBusinessAuthApply.certifiedBusinessStatus.as("status") ,qBusinessAuthApply.amount.as("amount") ,qBusinessAuthApply.authInfo.as("authInfo") ,qBusinessAuthApply.member.realName.as("realName") ,qBusinessAuthApply.detail.as("detail") ,qBusinessAuthApply.auditingTime.as("checkTime"))).from(qBusinessAuthApply); query.where(qBusinessAuthApply.id.eq(id)) ; BusinessAuthApplyDetailVO vo = query.fetchOne() ; MessageResult result; String jsonStr = vo.getAuthInfo() ; log.info("认证信息 jsonStr = {}", jsonStr); if (StringUtils.isEmpty(jsonStr)) { result = MessageResult.error("认证相关信息不存在"); result.setData(vo); return result; } try { JSONObject json = JSONObject.parseObject(jsonStr); vo.setInfo(json); result = MessageResult.success("认证详情"); result.setData(vo); return result; } catch (Exception e) { log.info("认证信息格式异常:{}", e); result = MessageResult.error("认证信息格式异常"); return result; } }
Example 11
Source File: CoinService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<Coin> query(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { List<Coin> list; JPAQuery<Coin> jpaQuery = queryFactory.selectFrom(QCoin.coin); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount());//添加总条数 }
Example 12
Source File: SysHelpService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<SysHelp> queryWhereOrPage(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { JPAQuery<SysHelp> jpaQuery = queryFactory.selectFrom(QSysHelp.sysHelp); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } jpaQuery.orderBy(QSysHelp.sysHelp.createTime.desc()); List<SysHelp> list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); long count = jpaQuery.fetchCount(); PageResult<SysHelp> page = new PageResult<>(list, pageNo, pageSize, count); return page; }
Example 13
Source File: BaseService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 查询列表 * * @param pageNo 分页参数 * @param pageSize 分页大小 * @param predicateList 查询条件 * @param entityPathBase 查询表 * @param orderSpecifierList 排序条件 * @return */ @Transactional(readOnly = true) public PageResult<T> queryDsl(Integer pageNo, Integer pageSize, List<Predicate> predicateList, EntityPathBase<T> entityPathBase, List<OrderSpecifier> orderSpecifierList) { List<T> list; //查询表 JPAQuery<T> jpaQuery = queryFactory.selectFrom(entityPathBase); //查询条件 if (predicateList != null && predicateList.size() > 0) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } //排序方式 if (orderSpecifierList != null && orderSpecifierList.size() > 0) { jpaQuery.orderBy(orderSpecifierList.toArray(new OrderSpecifier[orderSpecifierList.size()])); } //分页查询 if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, pageNo, pageSize, jpaQuery.fetchCount()); }
Example 14
Source File: QueueRepository.java From jump-the-queue with Apache License 2.0 | 5 votes |
/** * @param criteria the {@link QueueSearchCriteriaTo} with the criteria to * search. * @param pageRequest {@link Pageable} implementation used to set page * properties like page size * @return the {@link Page} of the {@link QueueEntity} objects that matched the * search. */ default Page<QueueEntity> findByCriteria(QueueSearchCriteriaTo criteria) { QueueEntity alias = newDslAlias(); JPAQuery<QueueEntity> query = newDslQuery(alias); String name = criteria.getName(); if (name != null && !name.isEmpty()) { QueryUtil.get().whereString(query, $(alias.getName()), name, criteria.getNameOption()); } String logo = criteria.getLogo(); if (logo != null && !logo.isEmpty()) { QueryUtil.get().whereString(query, $(alias.getLogo()), logo, criteria.getLogoOption()); } String currentNumber = criteria.getCurrentNumber(); if (currentNumber != null && !currentNumber.isEmpty()) { QueryUtil.get().whereString(query, $(alias.getCurrentNumber()), currentNumber, criteria.getCurrentNumberOption()); } Timestamp attentionTime = criteria.getAttentionTime(); if (attentionTime != null) { query.where($(alias.getAttentionTime()).eq(attentionTime)); } Timestamp minAttentionTime = criteria.getMinAttentionTime(); if (minAttentionTime != null) { query.where($(alias.getMinAttentionTime()).eq(minAttentionTime)); } Boolean active = criteria.getActive(); if (active != null) { query.where($(alias.getActive()).eq(active)); } Integer customers = criteria.getCustomers(); if (customers != null) { query.where($(alias.getCustomers()).eq(customers)); } addOrderBy(query, alias, criteria.getPageable().getSort()); return QueryUtil.get().findPaginated(criteria.getPageable(), query, true); }
Example 15
Source File: WithdrawRecordService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<WithdrawRecord> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<WithdrawRecord> list; JPAQuery<WithdrawRecord> jpaQuery = queryFactory.selectFrom(withdrawRecord); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 16
Source File: SysAdvertiseService.java From ZTuoExchange_framework with MIT License | 5 votes |
public List<SysAdvertise> findAll(List<Predicate> predicateList) { List<SysAdvertise> list; JPAQuery<SysAdvertise> jpaQuery = queryFactory.selectFrom(sysAdvertise); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } list = jpaQuery.orderBy(new OrderSpecifier<>(Order.DESC, sysAdvertise.createTime)).fetch(); return list; }
Example 17
Source File: AdvertiseService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 pageNo pageSize 同时传时分页 * * @param booleanExpressionList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<Advertise> queryWhereOrPage(List<BooleanExpression> booleanExpressionList, Integer pageNo, Integer pageSize) { List<Advertise> list; JPAQuery<Advertise> jpaQuery = queryFactory.selectFrom(advertise); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 18
Source File: MemberTransactionService.java From ZTuoExchange_framework with MIT License | 5 votes |
public Page<MemberTransactionVO> joinFind(List<Predicate> predicates, PageModel pageModel){ List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers() ; JPAQuery<MemberTransactionVO> query = queryFactory.select(Projections.fields(MemberTransactionVO.class, QMemberTransaction.memberTransaction.address, QMemberTransaction.memberTransaction.amount, QMemberTransaction.memberTransaction.createTime.as("createTime"), QMemberTransaction.memberTransaction.fee, QMemberTransaction.memberTransaction.flag, QMemberTransaction.memberTransaction.id.as("id"), QMemberTransaction.memberTransaction.symbol, QMemberTransaction.memberTransaction.type, QMember.member.username.as("memberUsername"), QMember.member.mobilePhone.as("phone"), QMember.member.email, QMember.member.realName.as("memberRealName"), QMember.member.id.as("memberId"))) .from(QMemberTransaction.memberTransaction, QMember.member); predicates.add(QMemberTransaction.memberTransaction.memberId.eq(QMember.member.id)); query.where(predicates.toArray(new BooleanExpression[predicates.size()])); query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); List<MemberTransactionVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch(); long total = query.fetchCount(); return new PageImpl<>(list, pageModel.getPageable(), total); }
Example 19
Source File: WithdrawRecordService.java From ZTuoExchange_framework with MIT License | 5 votes |
/** * 条件查询对象 * * @param predicateList * @param pageNo * @param pageSize * @return */ @Transactional(readOnly = true) public PageResult<WithdrawRecord> query(List<Predicate> predicateList, Integer pageNo, Integer pageSize) { List<WithdrawRecord> list; JPAQuery<WithdrawRecord> jpaQuery = queryFactory.selectFrom(withdrawRecord); if (predicateList != null) { jpaQuery.where(predicateList.toArray(new Predicate[predicateList.size()])); } if (pageNo != null && pageSize != null) { list = jpaQuery.offset((pageNo - 1) * pageSize).limit(pageSize).fetch(); } else { list = jpaQuery.fetch(); } return new PageResult<>(list, jpaQuery.fetchCount()); }
Example 20
Source File: AppealService.java From ZTuoExchange_framework with MIT License | 4 votes |
/** * 条件查询对象 (pageNo pageSize 同时传时分页) * * @param booleanExpressionList * @return */ @Transactional(readOnly = true) public PageResult<AppealVO> joinFind(List<BooleanExpression> booleanExpressionList, PageModel pageModel) { QAppeal qAppeal = QAppeal.appeal ; QBean qBean = Projections.fields(AppealVO.class ,qAppeal.id.as("appealId") ,qAppeal.order.memberName.as("advertiseCreaterUserName") ,qAppeal.order.memberRealName.as("advertiseCreaterName") ,qAppeal.order.customerName.as("customerUserName") ,qAppeal.order.customerRealName.as("customerName") ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.memberName.as("initiatorUsername"):qAppeal.order.customerName.as("initiatorUsername") ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.memberRealName.as("initiatorName"):qAppeal.order.customerRealName.as("initiatorName") ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.customerName.as("associateUsername"):qAppeal.order.memberName.as("associateUsername") ,qAppeal.initiatorId==qAppeal.order.memberId?qAppeal.order.customerRealName.as("associateName"):qAppeal.order.memberRealName.as("associateName") ,qAppeal.order.commission.as("fee") ,qAppeal.order.number ,qAppeal.order.money ,qAppeal.order.orderSn.as("orderSn") ,qAppeal.order.createTime.as("transactionTime") ,qAppeal.createTime.as("createTime") ,qAppeal.dealWithTime.as("dealTime") ,qAppeal.order.payMode.as("payMode") ,qAppeal.order.coin.name.as("coinName") ,qAppeal.order.status.as("orderStatus") ,qAppeal.isSuccess.as("isSuccess") ,qAppeal.order.advertiseType.as("advertiseType") ,qAppeal.status ,qAppeal.remark ); List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers(); JPAQuery<AppealVO> jpaQuery = queryFactory.select(qBean); jpaQuery.from(qAppeal); if (booleanExpressionList != null) { jpaQuery.where(booleanExpressionList.toArray(new BooleanExpression[booleanExpressionList.size()])); } jpaQuery.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])); List<AppealVO> list = jpaQuery.offset((pageModel.getPageNo() - 1) * pageModel.getPageSize()) .orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()])) .limit(pageModel.getPageSize()).fetch(); return new PageResult<>(list, jpaQuery.fetchCount()); }