Search in sources :

Example 56 with AuthPassport

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;
}
Also used : HashMap(java.util.HashMap) TestOrgRole(com.ngtesting.platform.entity.TestOrgRole) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 57 with AuthPassport

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;
}
Also used : HashMap(java.util.HashMap) TestOrgRole(com.ngtesting.platform.entity.TestOrgRole) 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 58 with AuthPassport

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;
}
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 59 with AuthPassport

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;
}
Also used : TestProject(com.ngtesting.platform.entity.TestProject) HashMap(java.util.HashMap) 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 60 with AuthPassport

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;
}
Also used : HashMap(java.util.HashMap) ProjectPrivilegeDefineVo(com.ngtesting.platform.vo.ProjectPrivilegeDefineVo) ProjectRoleVo(com.ngtesting.platform.vo.ProjectRoleVo) UserVo(com.ngtesting.platform.vo.UserVo) TestProjectRoleForOrg(com.ngtesting.platform.entity.TestProjectRoleForOrg) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AuthPassport (com.ngtesting.platform.util.AuthPassport)100 HashMap (java.util.HashMap)100 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)99 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)99 JSONObject (com.alibaba.fastjson.JSONObject)98 UserVo (com.ngtesting.platform.vo.UserVo)78 TestUser (com.ngtesting.platform.entity.TestUser)12 List (java.util.List)12 TestCase (com.ngtesting.platform.entity.TestCase)6 CasePriorityVo (com.ngtesting.platform.vo.CasePriorityVo)5 CaseTypeVo (com.ngtesting.platform.vo.CaseTypeVo)5 TestProject (com.ngtesting.platform.entity.TestProject)4 TestRun (com.ngtesting.platform.entity.TestRun)4 TestSuite (com.ngtesting.platform.entity.TestSuite)4 CustomFieldVo (com.ngtesting.platform.vo.CustomFieldVo)4 OrgGroupVo (com.ngtesting.platform.vo.OrgGroupVo)4 Page (com.ngtesting.platform.vo.Page)4 TestCaseInRunVo (com.ngtesting.platform.vo.TestCaseInRunVo)4 TestRunVo (com.ngtesting.platform.vo.TestRunVo)4 TestSuiteVo (com.ngtesting.platform.vo.TestSuiteVo)4