Search in sources :

Example 91 with AuthPassport

use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.

the class UserAction 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 userId = json.getLong("id");
    List<RelationOrgGroupUserVo> relations = orgGroupUserService.listRelationsByUser(orgId, userId);
    if (userId == null) {
        ret.put("user", new UserVo());
        ret.put("relations", relations);
        ret.put("code", Constant.RespCode.SUCCESS.getCode());
        return ret;
    }
    TestUser po = (TestUser) userService.get(TestUser.class, Long.valueOf(userId));
    UserVo vo = userService.genVo(po);
    ret.put("user", vo);
    ret.put("relations", relations);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestUser(com.ngtesting.platform.entity.TestUser) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 92 with AuthPassport

use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.

the class UserAction method setLeftSize.

@AuthPassport(validate = true)
@RequestMapping(value = "setLeftSize", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> setLeftSize(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    Integer left = json.getInteger("left");
    TestUser user = accountService.setLeftSizePers(userVo.getId(), left);
    userVo = userService.genVo(user);
    request.getSession().setAttribute(Constant.HTTP_SESSION_USER_KEY, userVo);
    ret.put("data", userVo);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestUser(com.ngtesting.platform.entity.TestUser) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 93 with AuthPassport

use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.

the class VerAction method list.

@AuthPassport(validate = true)
@RequestMapping(value = "query", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> list(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 projectId = json.getLong("projectId");
    List<TestVer> ls = verService.list(projectId);
    List<TestVerVo> vos = verService.genVos(ls);
    ret.put("data", vos);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestVer(com.ngtesting.platform.entity.TestVer) TestVerVo(com.ngtesting.platform.vo.TestVerVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 94 with AuthPassport

use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.

the class VerAction 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 id = json.getLong("id");
    TestVerVo vo = verService.getById(id);
    ret.put("data", vo);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestVerVo(com.ngtesting.platform.vo.TestVerVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 95 with AuthPassport

use of com.ngtesting.platform.util.AuthPassport in project ngtesting-platform by aaronchen2k.

the class AccountAction method forgotPassword.

@AuthPassport(validate = false)
@RequestMapping(value = "forgotPassword", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> forgotPassword(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    String email = json.getString("email");
    TestUser user = accountService.getByEmail(email);
    if (user == null) {
        ret.put("code", RespCode.BIZ_FAIL.getCode());
        ret.put("msg", "用户不存在");
        return ret;
    }
    TestVerifyCode verifyCode = accountService.genVerifyCodePers(user.getId());
    if (verifyCode != null) {
        String sys = PropertyConfig.getConfig("sys.name");
        Map<String, String> map = new HashMap<String, String>();
        map.put("name", user.getName());
        map.put("vcode", verifyCode.getCode());
        map.put("url", PropertyConfig.getConfig("url.reset.password"));
        mailService.sendTemplateMail("[\"" + sys + "\"]忘记密码", "forgot-password.ftl", user.getEmail(), map);
        ret.put("data", verifyCode);
        ret.put("code", RespCode.SUCCESS.getCode());
    } else {
        ret.put("code", RespCode.BIZ_FAIL.getCode());
        ret.put("msg", "用户不存在");
    }
    return ret;
}
Also used : HashMap(java.util.HashMap) TestVerifyCode(com.ngtesting.platform.entity.TestVerifyCode) JSONObject(com.alibaba.fastjson.JSONObject) TestUser(com.ngtesting.platform.entity.TestUser) 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