Beispiel #1
0
  public static boolean putAccount(Account account) {
    try {
      if (StringUtils.isEmpty(account.getUid())) {
        account.setCreateTime(System.currentTimeMillis());
        account.setUpdateTime(account.getCreateTime());
        account.setRole(Account.ROLE_USER);
        account.setStatus(Account.STATUS_CREATED);

        for (int i = 0; i < 10; i++) {
          String uid;

          uid =
              String.valueOf(System.currentTimeMillis())
                  + String.valueOf(Math.abs(InstanceUtils.random.nextInt(1000)));

          synchronized (Runtime.getRuntime()) {
            if (getAdapter().get(uid) != null) continue;
            account.setUid(uid);
            getAdapter().put(account);
            break;
          }
        }
      } else {
        account.setUpdateTime(System.currentTimeMillis());
        getAdapter().update(account);
      }

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
Beispiel #2
0
 public static boolean setLastLoginTime(String uid) {
   try {
     Account account = new Account();
     account.setUid(uid);
     account.setLastLoginTime(System.currentTimeMillis());
     getAdapter().update(account);
     return true;
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
 }
Beispiel #3
0
 public static boolean authMe(String uid) {
   try {
     Account account = new Account();
     account.setUid(uid);
     account.setStatus(Account.STATUS_NORMAL);
     account.setUpdateTime(System.currentTimeMillis());
     getAdapter().update(account);
     return true;
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
 }