Search in sources :

Example 1 with TestOrg

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

the class OrgServiceImpl method disable.

@Override
public Boolean disable(Long id) {
    if (id == null) {
        return false;
    }
    TestOrg po = (TestOrg) get(TestOrg.class, id);
    po.setDisabled(true);
    saveOrUpdate(po);
    return true;
}
Also used : TestOrg(com.ngtesting.platform.entity.TestOrg)

Example 2 with TestOrg

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

the class OrgServiceImpl method save.

@Override
public TestOrg save(OrgVo vo, Long userId) {
    if (vo == null) {
        return null;
    }
    TestUser user = (TestUser) get(TestUser.class, userId);
    boolean isNew = vo.getId() == null;
    TestOrg po = new TestOrg();
    if (!isNew) {
        po = (TestOrg) get(TestOrg.class, vo.getId());
    }
    po.setName(vo.getName());
    po.setWebsite(vo.getWebsite());
    po.setDisabled(vo.getDisabled());
    saveOrUpdate(po);
    if (isNew) {
        getDao().querySql("{call init_org(?,?)}", po.getId(), user.getId());
    }
    if (user.getDefaultOrgId() == null) {
        user.setDefaultOrgId(po.getId());
        saveOrUpdate(user);
    }
    return po;
}
Also used : TestUser(com.ngtesting.platform.entity.TestUser) TestOrg(com.ngtesting.platform.entity.TestOrg)

Example 3 with TestOrg

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

the class UserServiceImpl method save.

@Override
public TestUser save(UserVo userVo, Long orgId) {
    if (userVo == null) {
        return null;
    }
    TestUser temp = accountService.getByEmail(userVo.getEmail());
    if (temp != null && temp.getId() != userVo.getId()) {
        return null;
    }
    TestUser po;
    if (userVo.getId() != null) {
        po = (TestUser) get(TestUser.class, userVo.getId());
    } else {
        po = new TestUser();
        po.setDefaultOrgId(orgId);
    }
    po.setName(userVo.getName());
    po.setPhone(userVo.getPhone());
    po.setEmail(userVo.getEmail());
    po.setDisabled(userVo.getDisabled());
    if (userVo.getAvatar() == null) {
        po.setAvatar("upload/sample/user/avatar.png");
    }
    saveOrUpdate(po);
    TestOrg org = (TestOrg) get(TestOrg.class, orgId);
    if (!contains(org.getUserSet(), po.getId())) {
        org.getUserSet().add(po);
        saveOrUpdate(org);
    }
    return po;
}
Also used : TestUser(com.ngtesting.platform.entity.TestUser) TestOrg(com.ngtesting.platform.entity.TestOrg)

Example 4 with TestOrg

use of com.ngtesting.platform.entity.TestOrg 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 5 with TestOrg

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

the class UserServiceImpl method invitePers.

@Override
public TestUser invitePers(UserVo userVo, UserVo newUserVo, List<RelationOrgGroupUserVo> relations) {
    Long orgId = userVo.getDefaultOrgId();
    Long prjId = userVo.getDefaultPrjId();
    String prjName = userVo.getDefaultPrjName();
    TestUser existUser = accountService.getByEmail(newUserVo.getEmail());
    boolean isNew;
    TestUser userPo;
    if (existUser != null) {
        isNew = false;
        userPo = existUser;
    } else {
        isNew = true;
        userPo = new TestUser();
        userPo.setDefaultOrgId(orgId);
        userPo.setName(newUserVo.getName());
        userPo.setPhone(newUserVo.getPhone());
        userPo.setEmail(newUserVo.getEmail());
        userPo.setDisabled(newUserVo.getDisabled());
        userPo.setAvatar("upload/sample/user/avatar.png");
        userPo.setDefaultOrgId(userVo.getDefaultOrgId());
        userPo.setDefaultPrjId(userVo.getDefaultPrjId());
        userPo.setName(newUserVo.getName());
        saveOrUpdate(userPo);
    }
    TestOrg org = (TestOrg) get(TestOrg.class, orgId);
    if (!contains(org.getUserSet(), userPo.getId())) {
        // 不在组里
        org.getUserSet().add(userPo);
        saveOrUpdate(org);
        projectService.getHistoryPers(orgId, userPo.getId(), prjId, prjName);
        orgGroupUserService.saveRelations(relations);
        String sys = PropertyConfig.getConfig("sys.name");
        Map<String, String> map = new HashMap<String, String>();
        map.put("user", userPo.getName() + "(" + userPo.getEmail() + ")");
        map.put("name", userPo.getName());
        map.put("sys", sys);
        String url;
        if (isNew) {
            TestVerifyCode verifyCode = accountService.genVerifyCodePers(userPo.getId());
            url = PropertyConfig.getConfig("url.reset.password") + "/" + verifyCode.getCode();
        } else {
            url = PropertyConfig.getConfig("url.login");
        }
        map.put("url", url);
        mailService.sendTemplateMail("来自[" + sys + "]的邀请", "invite-user.ftl", newUserVo.getEmail(), map);
        return userPo;
    } else {
        return null;
    }
}
Also used : TestVerifyCode(com.ngtesting.platform.entity.TestVerifyCode) TestUser(com.ngtesting.platform.entity.TestUser) TestOrg(com.ngtesting.platform.entity.TestOrg)

Aggregations

TestOrg (com.ngtesting.platform.entity.TestOrg)8 TestUser (com.ngtesting.platform.entity.TestUser)5 OrgVo (com.ngtesting.platform.vo.OrgVo)2 JSONObject (com.alibaba.fastjson.JSONObject)1 TestVerifyCode (com.ngtesting.platform.entity.TestVerifyCode)1 AuthPassport (com.ngtesting.platform.util.AuthPassport)1 UserVo (com.ngtesting.platform.vo.UserVo)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1