com.querydsl.jpa.impl.JPAQuery Java Examples

The following examples show how to use com.querydsl.jpa.impl.JPAQuery. 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: BaseService.java    From ZTuoExchange_framework with MIT License 7 votes vote down vote up
/**
 * @param expressions        查询列表
 * @param entityPaths        查询表
 * @param predicates         条件
 * @param orderSpecifierList 排序
 * @param pageNo             页码
 * @param pageSize           页面大小
 */
@Transactional(readOnly = true)
public PageListMapResult queryDslForPageListResult(
        List<Expression> expressions,
        List<EntityPath> entityPaths,
        List<Predicate> predicates,
        List<OrderSpecifier> orderSpecifierList,
        Integer pageNo,
        Integer pageSize) {
    JPAQuery<Tuple> jpaQuery = queryFactory.select(expressions.toArray(new Expression[expressions.size()]))
            .from(entityPaths.toArray(new EntityPath[entityPaths.size()]))
            .where(predicates.toArray(new Predicate[predicates.size()]));
    List<Tuple> tuples = jpaQuery.orderBy(orderSpecifierList.toArray(new OrderSpecifier[orderSpecifierList.size()]))
            .offset((pageNo - 1) * pageSize).limit(pageSize)
            .fetch();
    List<Map<String, Object>> list = new LinkedList<>();//返回结果
    //封装结果
    for (int i = 0; i < tuples.size(); i++) {
        //遍历tuples
        Map<String, Object> map = new LinkedHashMap<>();//一条信息
        for (Expression expression : expressions) {
            map.put(expression.toString().split(" as ")[1],//别名作为Key
                    tuples.get(i).get(expression));//获取结果
        }
        list.add(map);
    }
    PageListMapResult pageListMapResult = new PageListMapResult(list, pageNo, pageSize, jpaQuery.fetchCount());//分页封装
    return pageListMapResult;
}
 
Example #2
Source File: OrderService.java    From ZTuoExchange_framework with MIT License 7 votes vote down vote up
public Page<OtcOrderVO> outExcel(List<Predicate> predicates , PageModel pageModel){
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    JPAQuery<OtcOrderVO> query = queryFactory.select(
            Projections.fields(OtcOrderVO.class,
                    QOrder.order.id.as("id"),
                    QOrder.order.orderSn.as("orderSn"),
                    QOrder.order.advertiseType.as("advertiseType"),
                    QOrder.order.createTime.as("createTime"),
                    QOrder.order.memberName.as("memberName"),
                    QOrder.order.customerName.as("customerName"),
                    QOrder.order.coin.unit,
                    QOrder.order.money,
                    QOrder.order.number,
                    QOrder.order.commission.as("fee"),
                    QOrder.order.payMode.as("payMode"),
                    QOrder.order.releaseTime.as("releaseTime"),
                    QOrder.order.cancelTime.as("cancelTime"),
                    QOrder.order.payTime.as("payTime"),
                    QOrder.order.status.as("status"))
    ).from(QOrder.order).where(predicates.toArray(new BooleanExpression[predicates.size()]));
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    List<OtcOrderVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch();
    long total = query.fetchCount() ;
    return new PageImpl<>(list,pageModel.getPageable(),total);
}
 
Example #3
Source File: UserService.java    From eds-starter6-jpa with Apache License 2.0 6 votes vote down vote up
private boolean isLastAdmin(Long id) {
	JPAQuery<Integer> query = this.jpaQueryFactory.select(Expressions.ONE)
			.from(QUser.user);
	BooleanBuilder bb = new BooleanBuilder();
	bb.or(QUser.user.authorities.eq(Authority.ADMIN.name()));
	bb.or(QUser.user.authorities.endsWith("," + Authority.ADMIN.name()));
	bb.or(QUser.user.authorities.contains("," + Authority.ADMIN.name() + ","));
	bb.or(QUser.user.authorities.startsWith(Authority.ADMIN.name() + ","));

	query.where(QUser.user.id.ne(id).and(QUser.user.deleted.isFalse())
			.and(QUser.user.enabled.isTrue()).and(bb));
	return query.fetchFirst() == null;
}
 
Example #4
Source File: MemberApplicationService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
/**
 * 条件查询对象 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 #5
Source File: BaseService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
/**
 * 查询列表
 *
 * @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 #6
Source File: UnrelatedEntitiesUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenCocktailsWithRecipe_whenQuerying_thenTheExpectedCocktailsReturned() {
    // JPA
    Cocktail cocktail = entityManager.createQuery("select c "
      + "from Cocktail c join c.recipe", Cocktail.class)
      .getSingleResult();
    verifyResult(mojito, cocktail);

    cocktail = entityManager.createQuery("select c "
      + "from Cocktail c join Recipe r "
      + "on c.name = r.cocktail", Cocktail.class)
      .getSingleResult();
    verifyResult(mojito, cocktail);

    // QueryDSL
    cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
      .join(QCocktail.cocktail.recipe)
      .fetchOne();
    verifyResult(mojito, cocktail);

    cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
      .join(QRecipe.recipe)
      .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail))
      .fetchOne();
    verifyResult(mojito, cocktail);
}
 
Example #7
Source File: BaseService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
@Transactional(readOnly = true)
public PageListMapResult queryDslForPageListResult(QueryDslContext qdc, Integer pageNo, Integer pageSize) {
    JPAQuery<Tuple> jpaQuery = queryFactory.select(qdc.expressionToArray())
            .from(qdc.entityPathToArray())
            .where(qdc.predicatesToArray());
    List<Tuple> tuples = jpaQuery.orderBy(qdc.orderSpecifiersToArray())
            .offset((pageNo - 1) * pageSize).limit(pageSize)
            .fetch();
    List<Map<String, Object>> list = new LinkedList<>();//返回结果
    //封装结果
    for (int i = 0; i < tuples.size(); i++) {
        //遍历tuples
        Map<String, Object> map = new LinkedHashMap<>();//一条信息
        for (Expression expression : qdc.getExpressions()) {
            map.put(expression.toString().split(" as ")[1],//别名作为Key
                    tuples.get(i).get(expression));//获取结果
        }
        list.add(map);
    }
    PageListMapResult pageListMapResult = new PageListMapResult(list, pageNo, pageSize, jpaQuery.fetchCount());//分页封装
    return pageListMapResult;
}
 
Example #8
Source File: BaseService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
@Transactional(readOnly = true)
public PageListMapResult queryDslForPageListResult(QueryDslContext qdc, Integer pageNo, Integer pageSize) {
    JPAQuery<Tuple> jpaQuery = queryFactory.select(qdc.expressionToArray())
            .from(qdc.entityPathToArray())
            .where(qdc.predicatesToArray());
    List<Tuple> tuples = jpaQuery.orderBy(qdc.orderSpecifiersToArray())
            .offset((pageNo - 1) * pageSize).limit(pageSize)
            .fetch();
    List<Map<String, Object>> list = new LinkedList<>();//返回结果
    //封装结果
    for (int i = 0; i < tuples.size(); i++) {
        //遍历tuples
        Map<String, Object> map = new LinkedHashMap<>();//一条信息
        for (Expression expression : qdc.getExpressions()) {
            map.put(expression.toString().split(" as ")[1],//别名作为Key
                    tuples.get(i).get(expression));//获取结果
        }
        list.add(map);
    }
    PageListMapResult pageListMapResult = new PageListMapResult(list, pageNo, pageSize, jpaQuery.fetchCount());//分页封装
    return pageListMapResult;
}
 
Example #9
Source File: SysAdvertiseService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
/**
 * 条件查询对象 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 #10
Source File: MemberTransactionService.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
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 #11
Source File: OrderFinder.java    From jeeshop with Apache License 2.0 6 votes vote down vote up
public List<Order> findByUser(User user, Integer offset, Integer limit, String orderby, Boolean isDesc, OrderStatus status) {
    JPAQuery<Order> query = new JPAQueryFactory(entityManager).selectFrom(order)
            .where(
                    order.user.eq(user),
                    status != null && status.equals(OrderStatus.CREATED) ? null : order.status.ne(OrderStatus.CREATED),
                    status != null ? order.status.eq(status) : null);

    if (offset != null)
        query.offset(offset);
    if (limit != null)
        query.limit(limit);

    sortBy(orderby, isDesc, query);

    return query.fetch();
}
 
Example #12
Source File: UnrelatedEntitiesUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenCocktailsWithMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() {
    // JPQL
    Cocktail cocktail = entityManager.createQuery("select c "
      + "from Cocktail c join c.recipeList", Cocktail.class)
      .getSingleResult();
    verifyResult(mojito, cocktail);

    cocktail = entityManager.createQuery("select c "
      + "from Cocktail c join MultipleRecipe mr "
      + "on mr.cocktail = c.name", Cocktail.class)
      .getSingleResult();
    verifyResult(mojito, cocktail);

    // QueryDSL
    cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
      .join(QCocktail.cocktail.recipeList)
      .fetchOne();
    verifyResult(mojito, cocktail);

    cocktail = new JPAQuery<Cocktail>(entityManager).from(QCocktail.cocktail)
      .join(QMultipleRecipe.multipleRecipe)
      .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail))
      .fetchOne();
    verifyResult(mojito, cocktail);
}
 
Example #13
Source File: CatalogItemFinder.java    From jeeshop with Apache License 2.0 5 votes vote down vote up
public Long countBySearchCriteria(EntityPath<? extends CatalogItem> entityPath, String searchCriteria) {
    QCatalogItem qCatalogItem = new QCatalogItem(entityPath);
    JPAQuery query = new JPAQueryFactory(entityManager)
            .selectFrom(qCatalogItem)
            .where(buildSearchPredicate(searchCriteria, qCatalogItem));
    return query.fetchCount();
}
 
Example #14
Source File: QuerydslQueryBackend.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
public JPAQuery<T> getQuery() {
	JPAQueryBase finalQuery = querydslQuery;
	for (OrderSpecifier<?> order : orderList) {
		finalQuery = (JPAQueryBase) finalQuery.orderBy(order);
	}
	return (JPAQuery<T>) finalQuery;
}
 
Example #15
Source File: ArtifactNotificationRuleDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public ArtifactNotificationRule getByFollowedArtifactAndRegex(FollowedArtifact followedArtifact, String regex) {
	JPAQuery<ArtifactNotificationRule> query = new JPAQuery<>(getEntityManager());
	
	query
		.select(qArtifactNotificationRule)
		.from(qArtifactNotificationRule)
		.where(qArtifactNotificationRule.followedArtifact.eq(followedArtifact))
		.where(qArtifactNotificationRule.regex.eq(regex));
	
	return query.fetchOne();
}
 
Example #16
Source File: QuerydslUtils.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
public static boolean hasManyRootsFetchesOrJoins(JPAQuery<?> query) {
	List<JoinExpression> joins = query.getMetadata().getJoins();
	for (JoinExpression join : joins) {
		if (join.getTarget() instanceof CollectionExpression) {
			return true;
		}
	}
	return false;
}
 
Example #17
Source File: UserFinder.java    From jeeshop with Apache License 2.0 5 votes vote down vote up
public List<User> findBySearchCriteria(String searchCriteria, Integer offset, Integer limit, String orderBy, Boolean isDesc) {
    JPAQuery<User> query = new JPAQueryFactory(entityManager).selectFrom(user)
            .where(buildSearchPredicate(searchCriteria));

    if (offset != null)
        query.offset(offset);
    if (limit != null)
        query.limit(limit);

    sortBy(orderBy, isDesc, query);

    return query.fetch();
}
 
Example #18
Source File: UserDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public User getOldGoogleOpenIdProfile(String email) {
	JPAQuery<User> query = new JPAQuery<>(getEntityManager());
	QUser qUser = QUser.user;
	
	query.select(qUser).from(qUser).where(qUser.userName.eq(email + "__" + AuthenticationType.OPENID_GOOGLE))
			.where(qUser.authenticationType.eq(AuthenticationType.OPENID_GOOGLE));
	
	return query.fetchOne();
}
 
Example #19
Source File: ProjectVersionDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public ProjectVersion getByProjectAndVersion(Project project, String version) {
	JPAQuery<ProjectVersion> query = new JPAQuery<>(getEntityManager());
	
	query
		.select(qProjectVersion)
		.from(qProjectVersion)
		.where(qProjectVersion.project.eq(project))
		.where(qProjectVersion.version.eq(version));
	
	return query.fetchOne();
}
 
Example #20
Source File: CoinService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * 条件查询对象 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 #21
Source File: QuerydslUtils.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
public static boolean hasManyRootsFetchesOrJoins(JPAQuery<?> query) {
	List<JoinExpression> joins = query.getMetadata().getJoins();
	for (JoinExpression join : joins) {
		if (join.getTarget() instanceof CollectionExpression) {
			return true;
		}
	}
	return false;
}
 
Example #22
Source File: PersonDaoImpl.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public List<Person> findPersonsByFirstnameQueryDSL(final String firstname) {
    final JPAQuery<Person> query = new JPAQuery<>(em);
    final QPerson person = QPerson.person;

    return query.from(person).where(person.firstname.eq(firstname)).fetch();
}
 
Example #23
Source File: VisitorRepository.java    From jump-the-queue with Apache License 2.0 5 votes vote down vote up
/**
 * @param criteria    the {@link VisitorSearchCriteriaTo} 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 VisitorEntity} objects that matched
 *         the search.
 */
default Page<VisitorEntity> findByCriteria(VisitorSearchCriteriaTo criteria) {

	VisitorEntity alias = newDslAlias();
	JPAQuery<VisitorEntity> query = newDslQuery(alias);

	String username = criteria.getUsername();
	if (username != null && !username.isEmpty()) {
		QueryUtil.get().whereString(query, $(alias.getUsername()), username, criteria.getUsernameOption());
	}
	String name = criteria.getName();
	if (name != null && !name.isEmpty()) {
		QueryUtil.get().whereString(query, $(alias.getName()), name, criteria.getNameOption());
	}
	String phoneNumber = criteria.getPhoneNumber();
	if (phoneNumber != null && !phoneNumber.isEmpty()) {
		QueryUtil.get().whereString(query, $(alias.getPhoneNumber()), phoneNumber, criteria.getPhoneNumberOption());
	}
	String password = criteria.getPassword();
	if (password != null && !password.isEmpty()) {
		QueryUtil.get().whereString(query, $(alias.getPassword()), password, criteria.getPasswordOption());
	}
	Boolean acceptedCommercial = criteria.getAcceptedCommercial();
	if (acceptedCommercial != null) {
		query.where($(alias.getAcceptedCommercial()).eq(acceptedCommercial));
	}
	Boolean acceptedTerms = criteria.getAcceptedTerms();
	if (acceptedTerms != null) {
		query.where($(alias.getAcceptedTerms()).eq(acceptedTerms));
	}
	Boolean userType = criteria.getUserType();
	if (userType != null) {
		query.where($(alias.getUserType()).eq(userType));
	}
	addOrderBy(query, alias, criteria.getPageable().getSort());

	return QueryUtil.get().findPaginated(criteria.getPageable(), query, true);
}
 
Example #24
Source File: BaseService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * 查询列表
 *
 * @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 #25
Source File: BusinessAuthApplyService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
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 #26
Source File: UserDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public List<ArtifactVersionNotification> listNotificationsAfterDate(User user, Date date) {
	JPAQuery<ArtifactVersionNotification> query = new JPAQuery<>(getEntityManager());
	
	query
		.select(qArtifactVersionNotification)
		.from(qArtifactVersionNotification)
		.where(qArtifactVersionNotification.user.eq(user))
		.where(qArtifactVersionNotification.creationDate.after(date))
		.orderBy(qArtifactVersionNotification.creationDate.desc());
	
	return query.fetch();
}
 
Example #27
Source File: ArtifactVersionNotificationDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public Map<User, List<ArtifactVersionNotification>> listNotificationsToSend() {
	JPAQuery<Void> query = new JPAQuery<>(getEntityManager());
	
	return query.from(qArtifactVersionNotification)
			.where(qArtifactVersionNotification.status.eq(ArtifactVersionNotificationStatus.PENDING))
			.orderBy(qArtifactVersionNotification.user.id.asc(), qArtifactVersionNotification.id.asc())
			.transform(GroupBy.groupBy(qArtifactVersionNotification.user).as(GroupBy.list(qArtifactVersionNotification)));
}
 
Example #28
Source File: OrderService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
public Page<OtcOrderVO> outExcel(List<Predicate> predicates , PageModel pageModel){
    List<OrderSpecifier> orderSpecifiers = pageModel.getOrderSpecifiers();
    JPAQuery<OtcOrderVO> query = queryFactory.select(
            Projections.fields(OtcOrderVO.class,
                    QOrder.order.id.as("id"),
                    QOrder.order.orderSn.as("orderSn"),
                    QOrder.order.advertiseType.as("advertiseType"),
                    QOrder.order.createTime.as("createTime"),
                    QOrder.order.memberName.as("memberName"),
                    QOrder.order.customerName.as("customerName"),
                    QOrder.order.coin.unit,
                    QOrder.order.money,
                    QOrder.order.number,
                    QOrder.order.commission.as("fee"),
                    QOrder.order.payMode.as("payMode"),
                    QOrder.order.releaseTime.as("releaseTime"),
                    QOrder.order.cancelTime.as("cancelTime"),
                    QOrder.order.payTime.as("payTime"),
                    QOrder.order.status.as("status"))
    ).from(QOrder.order).where(predicates.toArray(new BooleanExpression[predicates.size()]));
    query.orderBy(orderSpecifiers.toArray(new OrderSpecifier[orderSpecifiers.size()]));
    List<OtcOrderVO> list = query.offset((pageModel.getPageNo()-1)*pageModel.getPageSize()).limit(pageModel.getPageSize()).fetch();
    long total = query.fetchCount() ;
    return new PageImpl<>(list,pageModel.getPageable(),total);
}
 
Example #29
Source File: FollowedArtifactDaoImpl.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public List<User> listFollowers(Artifact artifact) {
	JPAQuery<User> query = new JPAQuery<>(getEntityManager());
	
	query
		.select(qUser)
		.from(qUser)
		.where(qUser.followedArtifacts.any().artifact.eq(artifact));
	
	return query.fetch();
}
 
Example #30
Source File: WithdrawRecordService.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * 条件查询对象
 *
 * @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());
}