Search in sources :

Example 6 with TestUser

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

Example 7 with TestUser

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

Example 8 with TestUser

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

Example 9 with TestUser

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

Example 10 with TestUser

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