Search in sources :

Example 1 with TestOrgGroup

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

the class RelationOrgGroupUserServiceImpl method listAllOrgGroups.

private List<TestOrgGroup> listAllOrgGroups(Long orgId) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestOrgGroup.class);
    dc.add(Restrictions.eq("orgId", orgId));
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    dc.addOrder(Order.asc("id"));
    List<TestOrgGroup> ls = findAllByCriteria(dc);
    return ls;
}
Also used : TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Example 2 with TestOrgGroup

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

the class RelationOrgGroupUserServiceImpl method genVo.

private RelationOrgGroupUserVo genVo(Long orgId, Long orgGroupId, Long userId) {
    RelationOrgGroupUserVo vo = new RelationOrgGroupUserVo();
    vo.setOrgId(orgId);
    if (orgGroupId != null) {
        TestOrgGroup orgGroup = (TestOrgGroup) get(TestOrgGroup.class, orgGroupId);
        vo.setOrgGroupId(orgGroupId);
        vo.setOrgGroupName(orgGroup.getName());
    }
    if (userId != null) {
        TestUser user = (TestUser) get(TestUser.class, userId);
        vo.setUserId(user.getId());
        vo.setUserName(user.getName());
    }
    return vo;
}
Also used : TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) TestUser(com.ngtesting.platform.entity.TestUser)

Example 3 with TestOrgGroup

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

the class RelationOrgGroupUserServiceImpl method listRelationsByUser.

@Override
public List<RelationOrgGroupUserVo> listRelationsByUser(Long orgId, Long userId) {
    List<TestOrgGroup> allOrgGroups = listAllOrgGroups(orgId);
    List<TestRelationOrgGroupUser> relations;
    if (userId == null) {
        relations = new LinkedList<>();
    } else {
        relations = listRelations(orgId, null, userId);
    }
    List<RelationOrgGroupUserVo> vos = new LinkedList<>();
    for (TestOrgGroup orgGroup : allOrgGroups) {
        RelationOrgGroupUserVo vo = genVo(orgId, orgGroup.getId(), userId);
        vo.setSelected(false);
        vo.setSelecting(false);
        for (TestRelationOrgGroupUser po : relations) {
            if (po.getOrgGroupId() == orgGroup.getId() && po.getUserId() == userId) {
                vo.setSelected(true);
                vo.setSelecting(true);
            }
        }
        vos.add(vo);
    }
    return vos;
}
Also used : TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup) TestRelationOrgGroupUser(com.ngtesting.platform.entity.TestRelationOrgGroupUser) RelationOrgGroupUserVo(com.ngtesting.platform.vo.RelationOrgGroupUserVo) LinkedList(java.util.LinkedList)

Example 4 with TestOrgGroup

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

the class OrgGroupServiceImpl method genVos.

@Override
public List<OrgGroupVo> genVos(List<TestOrgGroup> pos) {
    List<OrgGroupVo> vos = new LinkedList<OrgGroupVo>();
    for (TestOrgGroup po : pos) {
        OrgGroupVo vo = genVo(po);
        vos.add(vo);
    }
    return vos;
}
Also used : TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup) OrgGroupVo(com.ngtesting.platform.vo.OrgGroupVo) LinkedList(java.util.LinkedList)

Example 5 with TestOrgGroup

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

the class OrgGroupServiceImpl method save.

@Override
public TestOrgGroup save(OrgGroupVo vo, Long orgId) {
    if (vo == null) {
        return null;
    }
    TestOrgGroup po = new TestOrgGroup();
    if (vo.getId() != null) {
        po = (TestOrgGroup) get(TestOrgGroup.class, vo.getId());
    }
    po.setName(vo.getName());
    po.setDescr(vo.getDescr());
    po.setDisabled(vo.getDisabled());
    po.setOrgId(orgId);
    saveOrUpdate(po);
    return po;
}
Also used : TestOrgGroup(com.ngtesting.platform.entity.TestOrgGroup)

Aggregations

TestOrgGroup (com.ngtesting.platform.entity.TestOrgGroup)8 RelationOrgGroupUserVo (com.ngtesting.platform.vo.RelationOrgGroupUserVo)4 OrgGroupVo (com.ngtesting.platform.vo.OrgGroupVo)3 JSONObject (com.alibaba.fastjson.JSONObject)2 AuthPassport (com.ngtesting.platform.util.AuthPassport)2 UserVo (com.ngtesting.platform.vo.UserVo)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 TestRelationOrgGroupUser (com.ngtesting.platform.entity.TestRelationOrgGroupUser)1 TestUser (com.ngtesting.platform.entity.TestUser)1 List (java.util.List)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1