use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class AccountServiceImpl method saveInfo.
@Override
public TestUser saveInfo(JSONObject json) {
Long id = json.getLong("id");
String prop = json.getString("prop");
String value = json.getString("value");
TestUser po = (TestUser) get(TestUser.class, id);
if ("name".equals(prop)) {
po.setName(value);
} else if ("email".equals(prop)) {
po.setEmail(value);
} else if ("phone".equals(prop)) {
po.setPhone(value);
} else if ("avatar".equals(prop)) {
po.setAvatar(value);
}
saveOrUpdate(po);
return po;
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class AccountServiceImpl method getByEmail.
@Override
public TestUser getByEmail(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 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 genVerifyCodePers.
@Override
public TestVerifyCode genVerifyCodePers(Long userId) {
TestUser user = (TestUser) get(TestUser.class, userId);
if (user == null) {
return null;
}
TestVerifyCode po = new TestVerifyCode();
String code = UUID.randomUUID().toString().replaceAll("-", "");
Date now = new Date();
po.setRefId(user.getId());
po.setCode(code);
po.setCreateTime(now);
po.setExpireTime(new Date(now.getTime() + 10 * 60 * 1000));
saveOrUpdate(po);
return po;
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class AccountServiceImpl method resetPasswordPers.
@Override
public TestUser resetPasswordPers(String verifyCode, String password) {
String newToken = null;
DetachedCriteria dc = DetachedCriteria.forClass(TestVerifyCode.class);
dc.add(Restrictions.eq("code", verifyCode));
dc.add(Restrictions.ge("expireTime", new Date()));
dc.add(Restrictions.ne("deleted", true));
dc.add(Restrictions.ne("disabled", true));
dc.addOrder(Order.desc("id"));
List<TestVerifyCode> ls = (List<TestVerifyCode>) findAllByCriteria(dc);
if (ls.size() < 1) {
return null;
}
TestVerifyCode code = ls.get(0);
code.setDeleted(true);
saveOrUpdate(code);
TestUser user = (TestUser) get(TestUser.class, code.getRefId());
if (user == null) {
return null;
}
newToken = UUID.randomUUID().toString();
user.setToken(newToken);
if (password != null) {
user.setPassword(password);
}
user.setLastLoginTime(new Date());
saveOrUpdate(user);
return user;
}
use of com.ngtesting.platform.entity.TestUser in project ngtesting-platform by aaronchen2k.
the class AccountServiceImpl method changePasswordPers.
@Override
public boolean changePasswordPers(Long userId, String oldPassword, String password) {
TestUser po = (TestUser) get(TestUser.class, userId);
if (po == null || !po.getPassword().equals(oldPassword)) {
return false;
}
po.setPassword(password);
saveOrUpdate(po);
return true;
}
Aggregations