Search in sources :

Example 16 with TestUser

use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.

the class OrgAction 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>();
    Long id = json.getLong("id");
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    if (id != null) {
        TestOrg po = (TestOrg) orgService.get(TestOrg.class, id);
        OrgVo vo = orgService.genVo(po);
        TestUser user = (TestUser) orgService.get(TestUser.class, userVo.getId());
        if (po.getId().longValue() == user.getDefaultOrgId().longValue()) {
            vo.setDefaultOrg(true);
        }
        ret.put("data", vo);
    }
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : OrgVo(com.ngtesting.platform.vo.OrgVo) UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestOrg(com.ngtesting.platform.entity.TestOrg) 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 17 with TestUser

use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.

the class UserAction 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();
    UserVo user = JSON.parseObject(JSON.toJSONString(json.get("user")), UserVo.class);
    TestUser po = userService.save(user, orgId);
    if (po == null) {
        ret.put("code", RespCode.BIZ_FAIL.getCode());
        ret.put("msg", "邮箱已存在");
        return ret;
    }
    List<RelationOrgGroupUserVo> relations = (List<RelationOrgGroupUserVo>) json.get("relations");
    orgGroupUserService.saveRelations(relations);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) 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 18 with TestUser

use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.

the class UserAction method saveInfo.

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

Example 19 with TestUser

use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.

the class UserAction method invite.

@AuthPassport(validate = true)
@RequestMapping(value = "invite", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> invite(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    UserVo newUserVo = JSON.parseObject(JSON.toJSONString(json.get("user")), UserVo.class);
    List<RelationOrgGroupUserVo> relations = (List<RelationOrgGroupUserVo>) json.get("relations");
    TestUser po = userService.invitePers(userVo, newUserVo, relations);
    if (po == null) {
        ret.put("code", RespCode.BIZ_FAIL.getCode());
        ret.put("msg", "邮箱已加入当期组织");
        return ret;
    }
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) 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 20 with TestUser

use of com.ngtesting.platform.entity.TestUser 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)

Aggregations

TestUser (com.ngtesting.platform.entity.TestUser)43 HashMap (java.util.HashMap)13 JSONObject (com.alibaba.fastjson.JSONObject)12 AuthPassport (com.ngtesting.platform.util.AuthPassport)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 UserVo (com.ngtesting.platform.vo.UserVo)9 List (java.util.List)9 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)9 TestOrg (com.ngtesting.platform.entity.TestOrg)5 TestVerifyCode (com.ngtesting.platform.entity.TestVerifyCode)5 Date (java.util.Date)5 RelationOrgGroupUserVo (com.ngtesting.platform.vo.RelationOrgGroupUserVo)3 LinkedList (java.util.LinkedList)3 OrgVo (com.ngtesting.platform.vo.OrgVo)2 TestAlert (com.ngtesting.platform.entity.TestAlert)1 TestOrgGroup (com.ngtesting.platform.entity.TestOrgGroup)1 TestOrgRole (com.ngtesting.platform.entity.TestOrgRole)1 TestPlan (com.ngtesting.platform.entity.TestPlan)1 TestProject (com.ngtesting.platform.entity.TestProject)1