Search in sources :

Example 6 with TestOrg

use of com.ngtesting.platform.entity.TestOrg in project ngtesting-platform by aaronchen2k.

the class OrgServiceImpl method list.

@Override
public List<TestOrg> list(String keywords, String disabled, Long userId) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestOrg.class);
    dc.createAlias("userSet", "users");
    dc.add(Restrictions.eq("users.id", userId));
    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"));
    List<TestOrg> ls = findAllByCriteria(dc);
    return ls;
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) TestOrg(com.ngtesting.platform.entity.TestOrg)

Example 7 with TestOrg

use of com.ngtesting.platform.entity.TestOrg in project ngtesting-platform by aaronchen2k.

the class OrgServiceImpl method genVos.

@Override
public List<OrgVo> genVos(List<TestOrg> pos, Long userId) {
    TestUser user = (TestUser) get(TestUser.class, userId);
    List<OrgVo> voList = new LinkedList<OrgVo>();
    for (TestOrg po : pos) {
        OrgVo vo = genVo(po);
        if (po.getId().longValue() == user.getDefaultOrgId().longValue()) {
            vo.setDefaultOrg(true);
        }
        voList.add(vo);
    }
    return voList;
}
Also used : OrgVo(com.ngtesting.platform.vo.OrgVo) TestUser(com.ngtesting.platform.entity.TestUser) TestOrg(com.ngtesting.platform.entity.TestOrg) LinkedList(java.util.LinkedList)

Example 8 with TestOrg

use of com.ngtesting.platform.entity.TestOrg in project ngtesting-platform by aaronchen2k.

the class OrgServiceImpl method delete.

@Override
public Boolean delete(Long id) {
    if (id == null) {
        return false;
    }
    TestOrg po = (TestOrg) get(TestOrg.class, id);
    po.setDeleted(true);
    saveOrUpdate(po);
    return true;
}
Also used : TestOrg(com.ngtesting.platform.entity.TestOrg)

Aggregations

TestOrg (com.ngtesting.platform.entity.TestOrg)8 TestUser (com.ngtesting.platform.entity.TestUser)5 OrgVo (com.ngtesting.platform.vo.OrgVo)2 JSONObject (com.alibaba.fastjson.JSONObject)1 TestVerifyCode (com.ngtesting.platform.entity.TestVerifyCode)1 AuthPassport (com.ngtesting.platform.util.AuthPassport)1 UserVo (com.ngtesting.platform.vo.UserVo)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1