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;
}
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;
}
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 });
}
}