Search in sources :

Example 36 with UserVo

use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.

the class AccountAction method changePassword.

@RequestMapping(value = "changePassword", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> changePassword(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo vo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    String oldPassword = json.getString("oldPassword");
    String password = json.getString("password");
    boolean success = accountService.changePasswordPers(vo.getId(), oldPassword, password);
    int code = success ? RespCode.SUCCESS.getCode() : RespCode.BIZ_FAIL.getCode();
    ret.put("code", code);
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 37 with UserVo

use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.

the class AccountAction method logout.

@AuthPassport(validate = true)
@RequestMapping(value = "logout", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> logout(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo vo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    if (vo == null) {
        ret.put("code", RespCode.BIZ_FAIL.getCode());
        ret.put("msg", "您不在登录状态");
        return ret;
    }
    TestUser user = accountService.logoutPers(vo.getEmail());
    if (user != null) {
        request.getSession().removeAttribute(Constant.HTTP_SESSION_USER_KEY);
        ret.put("code", RespCode.SUCCESS.getCode());
    } else {
        ret.put("code", RespCode.BIZ_FAIL.getCode());
        ret.put("msg", "登出失败");
    }
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) 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 38 with UserVo

use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.

the class AlertAction method markAllRead.

@AuthPassport(validate = true)
@RequestMapping(value = "markAllRead", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> markAllRead(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    alertService.markAllReadPers(json.getString("ids"));
    optFacade.opt(WsConstant.WS_TODO, userVo.getId().toString());
    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) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 39 with UserVo

use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.

the class WebSocketHandshakeInterceptor method beforeHandshake.

@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
    ApplicationScopeBean scopeBean = SpringContextHolder.getBean(ApplicationScopeBean.class);
    if (request instanceof ServletServerHttpRequest) {
        ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
        HttpSession httpSession = servletRequest.getServletRequest().getSession(true);
        String test = (String) httpSession.getAttribute("TEST");
        UserVo user = null;
        if (httpSession.getAttribute(Constant.HTTP_SESSION_USER_KEY) != null) {
            user = (UserVo) httpSession.getAttribute(Constant.HTTP_SESSION_USER_KEY);
        }
        if (user != null) {
            attributes.put(WsConstant.WS_USER_KEY, user.getId().toString());
            attributes.put("somthing", "somthing");
            return true;
        }
    }
    return false;
}
Also used : ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) UserVo(com.ngtesting.platform.vo.UserVo) HttpSession(javax.servlet.http.HttpSession) ApplicationScopeBean(com.ngtesting.platform.bean.ApplicationScopeBean)

Example 40 with UserVo

use of com.ngtesting.platform.vo.UserVo in project ngtesting-platform by aaronchen2k.

the class EnvAction 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");
    TestEnvVo vo = envService.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) TestEnvVo(com.ngtesting.platform.vo.TestEnvVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

UserVo (com.ngtesting.platform.vo.UserVo)84 HashMap (java.util.HashMap)79 AuthPassport (com.ngtesting.platform.util.AuthPassport)78 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)78 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)78 JSONObject (com.alibaba.fastjson.JSONObject)77 TestUser (com.ngtesting.platform.entity.TestUser)9 List (java.util.List)7 CasePriorityVo (com.ngtesting.platform.vo.CasePriorityVo)5 CaseTypeVo (com.ngtesting.platform.vo.CaseTypeVo)5 RelationOrgGroupUserVo (com.ngtesting.platform.vo.RelationOrgGroupUserVo)5 TestRun (com.ngtesting.platform.entity.TestRun)4 TestSuite (com.ngtesting.platform.entity.TestSuite)4 CaseExeStatusVo (com.ngtesting.platform.vo.CaseExeStatusVo)4 CustomFieldVo (com.ngtesting.platform.vo.CustomFieldVo)4 OrgGroupVo (com.ngtesting.platform.vo.OrgGroupVo)4 TestCaseInRunVo (com.ngtesting.platform.vo.TestCaseInRunVo)4 TestRunVo (com.ngtesting.platform.vo.TestRunVo)4 TestSuiteVo (com.ngtesting.platform.vo.TestSuiteVo)4 Map (java.util.Map)4