use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class UserServiceImpl method listByPage.
@Override
public Page listByPage(Long orgId, String keywords, String disabled, Integer currentPage, Integer itemsPerPage) {
DetachedCriteria dc = DetachedCriteria.forClass(TestUser.class);
dc.createAlias("orgSet", "companies");
dc.add(Restrictions.eq("companies.id", orgId));
dc.add(Restrictions.eq("deleted", Boolean.FALSE));
if (StringUtil.isNotEmpty(keywords)) {
dc.add(Restrictions.or(Restrictions.like("name", "%" + keywords + "%"), Restrictions.like("email", "%" + keywords + "%"), Restrictions.like("phone", "%" + keywords + "%")));
}
if (StringUtil.isNotEmpty(disabled)) {
dc.add(Restrictions.eq("disabled", Boolean.valueOf(disabled)));
}
dc.addOrder(Order.asc("id"));
Page page = findPage(dc, currentPage * itemsPerPage, itemsPerPage);
return page;
}
use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class OrgGroupServiceImpl method listByPage.
@Override
public Page listByPage(Long orgId, String keywords, String disabled, Integer currentPage, Integer itemsPerPage) {
DetachedCriteria dc = DetachedCriteria.forClass(TestOrgGroup.class);
dc.add(Restrictions.eq("orgId", orgId));
dc.add(Restrictions.eq("deleted", Boolean.FALSE));
if (StringUtil.isNotEmpty(keywords)) {
dc.add(Restrictions.like("name", "%" + keywords + "%"));
}
if (StringUtil.isNotEmpty(disabled)) {
dc.add(Restrictions.eq("disabled", Boolean.valueOf(disabled)));
}
dc.addOrder(Order.asc("id"));
Page page = findPage(dc, currentPage * itemsPerPage, itemsPerPage);
return page;
}
use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class DocumentServiceImpl method listByPage.
@Override
public Page listByPage(long eventId, int currentPage, int itemsPerPage, DocType type) {
DetachedCriteria dc = DetachedCriteria.forClass(TestDocument.class);
dc.add(Restrictions.eq("eventId", eventId));
if (type != null) {
dc.add(Restrictions.eq("docType", type));
}
dc.add(Restrictions.eq("deleted", Boolean.FALSE));
dc.add(Restrictions.eq("disabled", Boolean.FALSE));
dc.addOrder(Order.asc("id"));
Page page = findPage(dc, currentPage * itemsPerPage, itemsPerPage);
return page;
}
use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class BaseDaoImpl method findPageByFetchedHql.
/**
* <HQL分页查询>
*
* @param hql HQL语句
* @param countHql 查询记录条数的HQL语句
* @param pageNo 下一页
* @param pageSize 一页总条数
* @param values 不定Object数组参数
* @return Page的封装类,里面包含了页码的信息以及查询的数据List集合
* @see com.ngtesting.platform.dao.BaseDao#findPageByFetchedHql(java.lang.String, java.lang.String, int, int, java.lang.Object[])
*/
@Override
public Page<Object> findPageByFetchedHql(String hql, String countHql, int pageNo, int pageSize, Object... values) {
Page<Object> retValue = new Page<Object>();
Query query = this.getSession().createQuery(hql);
if (values != null) {
for (int i = 0; i < values.length; i++) {
query.setParameter(i, values[i]);
}
}
int currentPage = pageNo > 1 ? pageNo : 1;
retValue.setLimit(pageSize);
if (countHql == null) {
ScrollableResults results = query.scroll();
results.last();
// 设置总记录数
retValue.setTotal(results.getRowNumber() + 1);
} else {
Long count = countByHql(countHql, values);
retValue.setTotal(count.intValue());
}
List<Object> itemList = query.setFirstResult((currentPage - 1) * pageSize).setMaxResults(pageSize).list();
if (itemList == null) {
itemList = new ArrayList<Object>();
}
retValue.setItems(itemList);
return retValue;
}
Aggregations