use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class BaseDaoImpl method findPage.
@Override
public Page findPage(DetachedCriteria dc, int start, int limit) {
Criteria c = dc.getExecutableCriteria(getSession());
CriteriaImpl impl = (CriteriaImpl) c;
Projection projection = impl.getProjection();
ResultTransformer transformer = impl.getResultTransformer();
List<CriteriaImpl.OrderEntry> orderEntries = (List<CriteriaImpl.OrderEntry>) ReflectionUtils.getFieldValue(impl, "orderEntries");
ReflectionUtils.setFieldValue(impl, "orderEntries", new ArrayList<CriteriaImpl.OrderEntry>());
// 执行Count查询
c.setResultTransformer(CriteriaImpl.DISTINCT_ROOT_ENTITY);
long total = (Long) c.setProjection(Projections.countDistinct("id")).uniqueResult();
// 将之前的Projection和OrderBy条件重新设回去
c.setProjection(projection);
c.setResultTransformer(transformer);
ReflectionUtils.setFieldValue(impl, "orderEntries", orderEntries);
c.setFirstResult(start);
c.setMaxResults(limit);
List list = c.list();
return new Page(start, limit, Integer.parseInt(String.valueOf(total)), (list == null ? new ArrayList() : list));
}
use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class MsgAction method list.
@AuthPassport(validate = true)
@RequestMapping(value = "list", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> list(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
String keywords = json.getString("keywords");
String isRead = json.getString("isRead");
int page = json.getInteger("page") == null ? 0 : json.getInteger("page") - 1;
int pageSize = json.getInteger("pageSize") == null ? Constant.PAGE_SIZE : json.getInteger("pageSize");
Page pageDate = msgService.listByPage(userVo.getId(), isRead, keywords, page, pageSize);
List<UserVo> vos = msgService.genVos(pageDate.getItems());
ret.put("collectionSize", pageDate.getTotal());
ret.put("data", vos);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class OrgGroupAction method list.
@AuthPassport(validate = true)
@RequestMapping(value = "list", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> list(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long orgId = userVo.getDefaultOrgId();
String keywords = json.getString("keywords");
String disabled = json.getString("disabled");
int page = json.getInteger("page") == null ? 0 : json.getInteger("page") - 1;
int pageSize = json.getInteger("pageSize") == null ? Constant.PAGE_SIZE : json.getInteger("pageSize");
Page pageData = orgGroupService.listByPage(orgId, keywords, disabled, page, pageSize);
List<OrgGroupVo> vos = orgGroupService.genVos(pageData.getItems());
ret.put("collectionSize", pageData.getTotal());
ret.put("data", vos);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class DocumentAction method list.
@AuthPassport(validate = true)
@RequestMapping(value = "list", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> list(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
long eventId = json.getLong("eventId");
int page = json.getInteger("page") == null ? 0 : json.getInteger("page") - 1;
int pageSize = json.getInteger("pageSize") == null ? Constant.PAGE_SIZE : json.getInteger("pageSize");
Page pageData = documentService.listByPage(eventId, page, pageSize, null);
List<DocumentVo> vos = documentService.genVos(pageData.getItems());
ret.put("collectionSize", pageData.getTotal());
ret.put("data", vos);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.
the class SysRoleAction method list.
@AuthPassport(validate = true)
@RequestMapping(value = "list", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> list(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long orgId = json.getLong("orgId");
String keywords = json.getString("keywords");
String disabled = json.getString("disabled");
int page = json.getInteger("page") == null ? 0 : json.getInteger("page") - 1;
int pageSize = json.getInteger("pageSize") == null ? Constant.PAGE_SIZE : json.getInteger("pageSize");
Page pageData = roleService.listByPage(orgId, keywords, disabled, page, pageSize);
List<RoleVo> vos = roleService.genVos(pageData.getItems());
ret.put("collectionSize", pageData.getTotal());
ret.put("data", vos);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
Aggregations