use of com.ngtesting.platform.entity.TestVerifyCode 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;
}
}
Aggregations