use of com.ngtesting.platform.entity.TestUser 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.TestUser 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.TestUser in project ngtesting-platform by aaronchen2k.
the class UserServiceImpl method disable.
@Override
public boolean disable(Long userId, Long orgId) {
TestUser po = (TestUser) get(TestUser.class, userId);
po.setDisabled(!po.getDisabled());
saveOrUpdate(po);
return true;
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class AccountServiceImpl method getByPhone.
@Override
public TestUser getByPhone(String phone) {
DetachedCriteria dc = DetachedCriteria.forClass(TestUser.class);
dc.add(Restrictions.eq("phone", phone));
dc.add(Restrictions.ne("deleted", true));
dc.add(Restrictions.ne("disabled", true));
List ls = findAllByCriteria(dc);
if (ls.size() > 0) {
return (TestUser) ls.get(0);
} else {
return null;
}
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class AccountServiceImpl method logoutPers.
@Override
public TestUser logoutPers(String email) {
DetachedCriteria dc = DetachedCriteria.forClass(TestUser.class);
dc.add(Restrictions.eq("email", email));
dc.add(Restrictions.ne("deleted", true));
dc.add(Restrictions.ne("disabled", true));
List<TestUser> ls = (List<TestUser>) findAllByCriteria(dc);
TestUser user = null;
if (ls.size() > 0) {
user = ls.get(0);
user.setToken("");
saveOrUpdate(user);
}
return user;
}
Aggregations