Search in sources :

Example 1 with TestRelationProjectRoleEntity

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

the class ProjectAction method saveMembers.

@AuthPassport(validate = true)
@RequestMapping(value = "saveMembers", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> saveMembers(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();
    List<TestRelationProjectRoleEntity> pos = relationProjectRoleEntityService.batchSavePers(json);
    List<RelationProjectRoleEntityVo> entityInRoles = relationProjectRoleEntityService.genVos(pos);
    Long projectId = json.getLong("projectId");
    TestProject project = (TestProject) relationProjectRoleEntityService.get(TestProject.class, projectId);
    historyService.create(project.getId(), userVo, Constant.MsgType.update.msg, TestHistory.TargetType.project_member, project.getId(), project.getName());
    ret.put("entityInRoles", entityInRoles);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) HashMap(java.util.HashMap) TestRelationProjectRoleEntity(com.ngtesting.platform.entity.TestRelationProjectRoleEntity) JSONObject(com.alibaba.fastjson.JSONObject) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with TestRelationProjectRoleEntity

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

the class ProjectAction method get.

@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(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();
    Long projectId = json.getLong("id");
    if (projectId != null) {
        TestProject project = projectService.getDetail(projectId);
        TestProjectVo vo = projectService.genVo(project);
        if (TestProject.ProjectType.group.equals(project.getType())) {
            vo.setLastestProjectGroup(projectService.isLastestProjectGroup(orgId, projectId));
        }
        ret.put("data", vo);
    }
    List<TestProjectVo> groups = projectService.listProjectGroups(orgId);
    List<ProjectRoleVo> projectRoles = projectRoleService.list(orgId, null, null);
    List<TestRelationProjectRoleEntity> entityInRolesPos = relationProjectRoleEntityService.listByProject(projectId);
    List<RelationProjectRoleEntityVo> entityInRoles = relationProjectRoleEntityService.genVos(entityInRolesPos);
    ret.put("groups", groups);
    ret.put("projectRoles", projectRoles);
    ret.put("entityInRoles", entityInRoles);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : HashMap(java.util.HashMap) TestProject(com.ngtesting.platform.entity.TestProject) TestRelationProjectRoleEntity(com.ngtesting.platform.entity.TestRelationProjectRoleEntity) JSONObject(com.alibaba.fastjson.JSONObject) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with TestRelationProjectRoleEntity

use of com.ngtesting.platform.entity.TestRelationProjectRoleEntity 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

TestRelationProjectRoleEntity (com.ngtesting.platform.entity.TestRelationProjectRoleEntity)3 JSONObject (com.alibaba.fastjson.JSONObject)2 TestProject (com.ngtesting.platform.entity.TestProject)2 AuthPassport (com.ngtesting.platform.util.AuthPassport)2 HashMap (java.util.HashMap)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 TestProjectRoleForOrg (com.ngtesting.platform.entity.TestProjectRoleForOrg)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1