com.querydsl.core.types.ExpressionUtils Java Examples

The following examples show how to use com.querydsl.core.types.ExpressionUtils. 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: RoleService.java    From codeway_service with GNU General Public License v3.0 5 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 File: UserService.java    From codeway_service with 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 #3
Source File: PageModel.java    From ZTuoExchange_framework with 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 #4
Source File: PageModel.java    From ZTuoExchange_framework with 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 File: RoleService.java    From codeway_service with GNU General Public License v3.0 5 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 #6
Source File: UserService.java    From codeway_service with 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 File: QuerydslQueryBackend.java    From crnk-framework with 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 File: QuerydslQueryBackend.java    From katharsis-framework with 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;
}