Search in sources :

Example 1 with Page

use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.

the class ChatServiceImpl method listByEvent.

@Override
public List<TestThread> listByEvent(Long eventId) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestThread.class);
    dc.add(Restrictions.eq("eventId", eventId));
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    dc.addOrder(Order.asc("id"));
    Page page = findPage(dc, 0, 10);
    return page.getItems();
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) Page(com.ngtesting.platform.vo.Page)

Example 2 with Page

use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.

the class OrgGroupServiceImpl method search.

@Override
public List search(Long orgId, String keywords, JSONArray exceptIds) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestOrgGroup.class);
    dc.add(Restrictions.eq("orgId", orgId));
    List<Long> ids = new ArrayList();
    for (Object json : exceptIds.toArray()) {
        ids.add(Long.valueOf(json.toString()));
    }
    if (exceptIds.size() > 0) {
        dc.add(Restrictions.not(Restrictions.in("id", ids)));
    }
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    if (StringUtil.isNotEmpty(keywords)) {
        dc.add(Restrictions.like("name", "%" + keywords + "%"));
    }
    dc.addOrder(Order.asc("id"));
    Page page = findPage(dc, 0, 20);
    return page.getItems();
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) ArrayList(java.util.ArrayList) Page(com.ngtesting.platform.vo.Page)

Example 3 with Page

use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.

the class SysRoleServiceImpl method listByPage.

@Override
public Page listByPage(Long orgId, String keywords, String disabled, Integer currentPage, Integer itemsPerPage) {
    DetachedCriteria dc = DetachedCriteria.forClass(SysRole.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;
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) Page(com.ngtesting.platform.vo.Page)

Example 4 with Page

use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.

the class UserServiceImpl method search.

@Override
public List<TestUser> search(Long orgId, String keywords, JSONArray exceptIds) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestUser.class);
    dc.createAlias("orgSet", "orgs");
    dc.add(Restrictions.eq("orgs.id", orgId));
    if (exceptIds != null && exceptIds.size() > 0) {
        List<Long> ids = new ArrayList();
        for (Object json : exceptIds.toArray()) {
            ids.add(Long.valueOf(json.toString()));
        }
        dc.add(Restrictions.not(Restrictions.in("id", ids)));
    }
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    if (StringUtil.isNotEmpty(keywords)) {
        dc.add(Restrictions.or(Restrictions.like("name", "%" + keywords + "%"), Restrictions.like("email", "%" + keywords + "%"), Restrictions.like("phone", "%" + keywords + "%")));
    }
    dc.addOrder(Order.asc("id"));
    Page page = findPage(dc, 0, 20);
    return page.getItems();
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) Page(com.ngtesting.platform.vo.Page)

Example 5 with Page

use of com.ngtesting.platform.vo.Page in project ngtesting-platform by aaronchen2k.

the class MsgServiceImpl method listByPage.

@Override
public Page listByPage(Long userId, String isRead, String keywords, Integer currentPage, Integer itemsPerPage) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestMsg.class);
    dc.add(Restrictions.eq("userId", userId));
    if (StringUtil.isNotEmpty(keywords)) {
        dc.add(Restrictions.like("name", "%" + keywords + "%"));
    }
    if (StringUtils.isNotEmpty(isRead)) {
        dc.add(Restrictions.eq("isRead", Boolean.valueOf(isRead)));
    }
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    dc.addOrder(Order.desc("createTime"));
    Page page = findPage(dc, currentPage * itemsPerPage, itemsPerPage);
    return page;
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) Page(com.ngtesting.platform.vo.Page)

Aggregations

Page (com.ngtesting.platform.vo.Page)14 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)9 JSONObject (com.alibaba.fastjson.JSONObject)4 AuthPassport (com.ngtesting.platform.util.AuthPassport)4 HashMap (java.util.HashMap)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 UserVo (com.ngtesting.platform.vo.UserVo)3 ArrayList (java.util.ArrayList)2 DocumentVo (com.ngtesting.platform.vo.DocumentVo)1 OrgGroupVo (com.ngtesting.platform.vo.OrgGroupVo)1 RelationOrgGroupUserVo (com.ngtesting.platform.vo.RelationOrgGroupUserVo)1 RoleVo (com.ngtesting.platform.vo.RoleVo)1 List (java.util.List)1 Criteria (org.hibernate.Criteria)1 Query (org.hibernate.Query)1 ScrollableResults (org.hibernate.ScrollableResults)1 Projection (org.hibernate.criterion.Projection)1 CriteriaImpl (org.hibernate.internal.CriteriaImpl)1 ResultTransformer (org.hibernate.transform.ResultTransformer)1