Java Code Examples for com.querydsl.core.types.ExpressionUtils

The following examples show how to use com.querydsl.core.types.ExpressionUtils. These examples are extracted from open source projects. 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 Project: codeway_service   Source File: RoleService.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 条件查询角色
 *
 * @param role : Role
 * @return IPage<Role>
 */
public QueryResults<Role> findRuleByCondition(Role role, QueryVO queryVO) {

    QRole qRole = QRole.role;
    com.querydsl.core.types.Predicate predicate = null;
    OrderSpecifier<?> sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qRole);
    if (StringUtils.isNotEmpty(role.getRoleName())) {
        predicate = ExpressionUtils.and(predicate, qRole.roleName.like(role.getRoleName()));
    }
    if (StringUtils.isNotEmpty(queryVO.getFieldSort())) {
        sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qRole, queryVO.getFieldSort());
    }
    QueryResults<Role> queryResults = jpaQueryFactory
            .selectFrom(qRole)
            .where(predicate)
            .offset(queryVO.getPageNum())
            .limit(queryVO.getPageSize())
            .orderBy(sortedColumn)
            .fetchResults();
    return queryResults;
}
 
Example 2
Source Project: codeway_service   Source File: RoleService.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 条件查询角色
 *
 * @param role : Role
 * @return IPage<Role>
 */
public QueryResults<Role> findRuleByCondition(Role role, QueryVO queryVO) {

    QRole qRole = QRole.role;
    com.querydsl.core.types.Predicate predicate = null;
    OrderSpecifier<?> sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qRole);
    if (StringUtils.isNotEmpty(role.getRoleName())) {
        predicate = ExpressionUtils.and(predicate, qRole.roleName.like(role.getRoleName()));
    }
    if (StringUtils.isNotEmpty(queryVO.getFieldSort())) {
        sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qRole, queryVO.getFieldSort());
    }
    QueryResults<Role> queryResults = jpaQueryFactory
            .selectFrom(qRole)
            .where(predicate)
            .offset(queryVO.getPageNum())
            .limit(queryVO.getPageSize())
            .orderBy(sortedColumn)
            .fetchResults();
    return queryResults;
}
 
Example 3
Source Project: codeway_service   Source File: UserService.java    License: GNU General Public License v3.0 5 votes vote down vote up
public QueryResults<User> findByCondition(User user, QueryVO queryVO) {

        QUser qUser = QUser.user;
        com.querydsl.core.types.Predicate predicate = null;
        OrderSpecifier<?> sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qUser);
        if (StringUtils.isNotEmpty(user.getUserName())) {
            predicate = ExpressionUtils.and(predicate, qUser.userName.like(user.getUserName()));
        }
        if (user.getStatus() != null) {
            predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus()));
        }
        if (StringUtils.isNotEmpty(user.getId())) {
            predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus()));
        }
        if (StringUtils.isNotEmpty(user.getUserName())) {
            predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus()));
        }
        if (StringUtils.isNotEmpty(user.getAccount())) {
            predicate = ExpressionUtils.and(predicate, qUser.account.eq(user.getAccount()));
        }
        if (StringUtils.isNotEmpty(user.getPhone())) {
            predicate = ExpressionUtils.and(predicate, qUser.phone.eq(user.getPhone()));
        }
        if (StringUtils.isNotEmpty(queryVO.getFieldSort())) {
            sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qUser, queryVO.getFieldSort());
        }
        QueryResults<User> queryResults = jpaQueryFactory
                .selectFrom(qUser)
                .where(predicate)
                .offset(queryVO.getPageNum())
                .limit(queryVO.getPageSize())
                .orderBy(sortedColumn)
                .fetchResults();
        return queryResults;
    }
 
Example 4
Source Project: ZTuoExchange_framework   Source File: PageModel.java    License: MIT License 5 votes vote down vote up
public List<OrderSpecifier> getOrderSpecifiers(){
    List<OrderSpecifier> orderSpecifiers = new ArrayList<>();
    setSort();
    if(this.getProperty()!=null){
        for(int i = 0 ; i < this.getProperty().size() ;i++){
            Path path = ExpressionUtils.path(Path.class,this.getProperty().get(i));
            OrderSpecifier orderSpecifier = new OrderSpecifier(this.toOrders(this.getDirection()).get(i),path);
            orderSpecifiers.add(orderSpecifier);
        }
    }
    return orderSpecifiers ;
}
 
Example 5
Source Project: ZTuoExchange_framework   Source File: PageModel.java    License: MIT License 5 votes vote down vote up
public List<OrderSpecifier> getOrderSpecifiers(){
    List<OrderSpecifier> orderSpecifiers = new ArrayList<>();
    setSort();
    if(this.getProperty()!=null){
        for(int i = 0 ; i < this.getProperty().size() ;i++){
            Path path = ExpressionUtils.path(Path.class,this.getProperty().get(i));
            OrderSpecifier orderSpecifier = new OrderSpecifier(this.toOrders(this.getDirection()).get(i),path);
            orderSpecifiers.add(orderSpecifier);
        }
    }
    return orderSpecifiers ;
}
 
Example 6
Source Project: codeway_service   Source File: UserService.java    License: GNU General Public License v3.0 5 votes vote down vote up
public QueryResults<User> findByCondition(User user, QueryVO queryVO) {

        QUser qUser = QUser.user;
        com.querydsl.core.types.Predicate predicate = null;
        OrderSpecifier<?> sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qUser);
        if (StringUtils.isNotEmpty(user.getUserName())) {
            predicate = ExpressionUtils.and(predicate, qUser.userName.like(user.getUserName()));
        }
        if (user.getStatus() != null) {
            predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus()));
        }
        if (StringUtils.isNotEmpty(user.getId())) {
            predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus()));
        }
        if (StringUtils.isNotEmpty(user.getUserName())) {
            predicate = ExpressionUtils.and(predicate, qUser.status.eq(user.getStatus()));
        }
        if (StringUtils.isNotEmpty(user.getAccount())) {
            predicate = ExpressionUtils.and(predicate, qUser.account.eq(user.getAccount()));
        }
        if (StringUtils.isNotEmpty(user.getPhone())) {
            predicate = ExpressionUtils.and(predicate, qUser.phone.eq(user.getPhone()));
        }
        if (StringUtils.isNotEmpty(queryVO.getFieldSort())) {
            sortedColumn = QuerydslUtil.getSortedColumn(Order.DESC, qUser, queryVO.getFieldSort());
        }
        QueryResults<User> queryResults = jpaQueryFactory
                .selectFrom(qUser)
                .where(predicate)
                .offset(queryVO.getPageNum())
                .limit(queryVO.getPageSize())
                .orderBy(sortedColumn)
                .fetchResults();
        return queryResults;
    }
 
Example 7
Source Project: crnk-framework   Source File: QuerydslQueryBackend.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Predicate not() {
	if (not == null) {
		not = ExpressionUtils.predicate(Ops.NOT, this);
	}
	return not;
}
 
Example 8
Source Project: katharsis-framework   Source File: QuerydslQueryBackend.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Predicate not() {
	if (not == null) {
		not = ExpressionUtils.predicate(Ops.NOT, this);
	}
	return not;
}