use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class OrgRoleAction method save.
@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(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();
OrgRoleVo orgRoleVo = JSON.parseObject(JSON.toJSONString(json.get("orgRole")), OrgRoleVo.class);
TestOrgRole po = orgRoleService.save(orgRoleVo, orgId);
List<OrgPrivilegeVo> orgPrivileges = (List<OrgPrivilegeVo>) json.get("orgPrivileges");
boolean success = orgRolePrivilegeService.saveOrgRolePrivileges(po.getId(), orgPrivileges);
List<UserVo> orgRoleUsers = (List<UserVo>) json.get("orgRoleUsers");
success = orgRoleUserService.saveOrgRoleUsers(po.getId(), orgRoleUsers);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class OrgRoleAction method get.
@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject req) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long orgId = userVo.getDefaultOrgId();
Long orgRoleId = req.getLong("id");
List<OrgPrivilegeVo> orgRolePrivileges = orgRolePrivilegeService.listPrivilegesByOrgRole(orgId, orgRoleId);
List<UserVo> orgRoleUsers = orgRoleUserService.listUserByOrgRole(orgRoleId);
if (orgRoleId == null) {
ret.put("orgRole", new OrgRoleVo());
ret.put("orgRolePrivileges", orgRolePrivileges);
ret.put("orgRoleUsers", orgRoleUsers);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
TestOrgRole po = (TestOrgRole) orgRoleService.get(TestOrgRole.class, orgRoleId);
OrgRoleVo vo = orgRoleService.genVo(po);
ret.put("orgRole", vo);
ret.put("orgRolePrivileges", orgRolePrivileges);
ret.put("orgRoleUsers", orgRoleUsers);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.util.AuthPassport 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.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class ProjectAction method save.
@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(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 userId = userVo.getId();
TestProjectVo vo = json.getObject("model", TestProjectVo.class);
TestProject po = projectService.save(vo, orgId, userVo);
if (TestProject.ProjectType.project.equals(po.getType())) {
projectService.updateNameInHisotyPers(po.getId(), userId);
}
pushSettingsService.pushRecentProjects(userVo);
pushSettingsService.pushPrjSettings(userVo);
ret.put("data", vo);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.
the class ProjectRoleAction method save.
@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(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();
ProjectRoleVo projectRoleVo = JSON.parseObject(JSON.toJSONString(json.get("projectRole")), ProjectRoleVo.class);
TestProjectRoleForOrg po = projectRoleService.save(projectRoleVo, orgId);
Map<String, List<ProjectPrivilegeDefineVo>> projectPrivileges = (Map<String, List<ProjectPrivilegeDefineVo>>) json.get("projectPrivileges");
int i = 0;
boolean success = projectPrivilegeService.saveProjectPrivileges(po.getId(), projectPrivileges);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
Aggregations