Search in sources :

Example 1 with Order

use of com.baidu.unbiz.common.genericdao.operator.Order in project disconf by knightliao.

the class QueryGenerator method getSelectQuery.

public Query getSelectQuery(Collection<Match> matches, Order... orders) {
    Query query = getSelectQuery(matches);
    if (orders == null || orders.length == 0) {
        return query;
    }
    // 加入排序
    StringBuilder sb = new StringBuilder(query.getSql());
    sb.append(" order by ");
    for (Order entry : orders) {
        sb.append(entry.getColumn()).append(entry.isAsc() ? " asc" : " desc").append(',');
    }
    sb.deleteCharAt(sb.length() - 1);
    query.setSql(sb.toString());
    return query;
}
Also used : Order(com.baidu.unbiz.common.genericdao.operator.Order) Query(com.baidu.unbiz.common.genericdao.operator.Query)

Example 2 with Order

use of com.baidu.unbiz.common.genericdao.operator.Order in project disconf by knightliao.

the class DaoUtils method daoPageAdapter.

/**
     * 将业务的Page转成Dao的Page
     *
     * @param page
     *
     * @return
     */
public static DaoPage daoPageAdapter(Page page) {
    DaoPage daoPage = new DaoPage();
    daoPage.setPageNo(page.getPageNo());
    daoPage.setPageSize(page.getPageSize());
    List<Order> orderList = new ArrayList<Order>();
    if (!StringUtils.isEmpty(page.getOrderBy())) {
        Order order = new Order(page.getOrderBy(), page.isAsc());
        orderList.add(order);
    }
    daoPage.setOrderList(orderList);
    return daoPage;
}
Also used : Order(com.baidu.unbiz.common.genericdao.operator.Order) ArrayList(java.util.ArrayList) DaoPage(com.baidu.ub.common.db.DaoPage)

Example 3 with Order

use of com.baidu.unbiz.common.genericdao.operator.Order in project disconf by knightliao.

the class ConfigDaoImpl method getConfigList.

/**
     *
     */
@Override
public List<Config> getConfigList(Long appId, Long envId, String version, Boolean hasValue) {
    List<Match> matchs = new ArrayList<Match>();
    matchs.add(new Match(Columns.APP_ID, appId));
    matchs.add(new Match(Columns.ENV_ID, envId));
    matchs.add(new Match(Columns.VERSION, version));
    matchs.add(new Match(Columns.STATUS, Constants.STATUS_NORMAL));
    if (hasValue) {
        return find(matchs, new ArrayList<Order>());
    } else {
        return findColumns(matchs, new String[] { Columns.CONFIG_ID, Columns.TYPE, Columns.NAME, Columns.CREATE_TIME, Columns.UPDATE_TIME, Columns.STATUS, Columns.APP_ID, Columns.ENV_ID, Columns.VERSION });
    }
}
Also used : Order(com.baidu.unbiz.common.genericdao.operator.Order) ArrayList(java.util.ArrayList) Match(com.baidu.unbiz.common.genericdao.operator.Match)

Aggregations

Order (com.baidu.unbiz.common.genericdao.operator.Order)3 ArrayList (java.util.ArrayList)2 DaoPage (com.baidu.ub.common.db.DaoPage)1 Match (com.baidu.unbiz.common.genericdao.operator.Match)1 Query (com.baidu.unbiz.common.genericdao.operator.Query)1