Search in sources :

Example 11 with TestUser

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;
}
Also used : TestUser(com.ngtesting.platform.entity.TestUser)

Example 12 with TestUser

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;
    }
}
Also used : DetachedCriteria(org.hibernate.criterion.DetachedCriteria) List(java.util.List) TestUser(com.ngtesting.platform.entity.TestUser)

Example 13 with TestUser

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;
}
Also used : TestVerifyCode(com.ngtesting.platform.entity.TestVerifyCode) TestUser(com.ngtesting.platform.entity.TestUser) Date(java.util.Date)

Example 14 with TestUser

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;
}
Also used : TestVerifyCode(com.ngtesting.platform.entity.TestVerifyCode) DetachedCriteria(org.hibernate.criterion.DetachedCriteria) List(java.util.List) TestUser(com.ngtesting.platform.entity.TestUser) Date(java.util.Date)

Example 15 with TestUser

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;
}
Also used : TestUser(com.ngtesting.platform.entity.TestUser)

Aggregations

TestUser (com.ngtesting.platform.entity.TestUser)43 HashMap (java.util.HashMap)13 JSONObject (com.alibaba.fastjson.JSONObject)12 AuthPassport (com.ngtesting.platform.util.AuthPassport)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 UserVo (com.ngtesting.platform.vo.UserVo)9 List (java.util.List)9 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)9 TestOrg (com.ngtesting.platform.entity.TestOrg)5 TestVerifyCode (com.ngtesting.platform.entity.TestVerifyCode)5 Date (java.util.Date)5 RelationOrgGroupUserVo (com.ngtesting.platform.vo.RelationOrgGroupUserVo)3 LinkedList (java.util.LinkedList)3 OrgVo (com.ngtesting.platform.vo.OrgVo)2 TestAlert (com.ngtesting.platform.entity.TestAlert)1 TestOrgGroup (com.ngtesting.platform.entity.TestOrgGroup)1 TestOrgRole (com.ngtesting.platform.entity.TestOrgRole)1 TestPlan (com.ngtesting.platform.entity.TestPlan)1 TestProject (com.ngtesting.platform.entity.TestProject)1