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;
}
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;
}
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;
}
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;
}
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;
}
}
Aggregations