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;
}
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;
}
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;
}
Aggregations