Search in sources :

Example 6 with TestProjectRoleForOrg

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

the class ProjectPrivilegeServiceImpl method addUserAsProjectRolePers.

@Override
public boolean addUserAsProjectRolePers(Long orgId, Long projectId, String roleCode, Long userId) {
    DetachedCriteria dc = DetachedCriteria.forClass(TestProjectRoleForOrg.class);
    dc.add(Restrictions.eq("orgId", orgId));
    dc.add(Restrictions.eq("code", "test_leader"));
    dc.add(Restrictions.eq("deleted", Boolean.FALSE));
    dc.add(Restrictions.eq("disabled", Boolean.FALSE));
    dc.addOrder(Order.asc("id"));
    List<TestProjectRoleForOrg> ls = findAllByCriteria(dc);
    if (ls.size() == 0) {
        return false;
    }
    TestProjectRoleForOrg role = ls.get(0);
    TestRelationProjectRoleEntity relation = new TestRelationProjectRoleEntity(projectId, userId, role.getId(), "user");
    saveOrUpdate(relation);
    return true;
}
Also used : TestRelationProjectRoleEntity(com.ngtesting.platform.entity.TestRelationProjectRoleEntity) DetachedCriteria(org.hibernate.criterion.DetachedCriteria) TestProjectRoleForOrg(com.ngtesting.platform.entity.TestProjectRoleForOrg)

Aggregations

TestProjectRoleForOrg (com.ngtesting.platform.entity.TestProjectRoleForOrg)6 ProjectRoleVo (com.ngtesting.platform.vo.ProjectRoleVo)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 List (java.util.List)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 TestRelationProjectRoleEntity (com.ngtesting.platform.entity.TestRelationProjectRoleEntity)1 ProjectPrivilegeDefineVo (com.ngtesting.platform.vo.ProjectPrivilegeDefineVo)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1