示例#1
0
 @Override
 public int addTeam(Corporation team) {
   int corpId = organizationDao.addCorporation(team);
   for (String account : team.getAccountList()) {
     if (account == null || account.trim().isEmpty()) continue;
     User u = accountMgr.getUser(account);
     if (u.getId() == team.getUserId()) {
       // if the user is creator, there's no need to add again
       continue;
     }
     organizationDao.addUserToCorp(corpId, u.getId(), 3); // 3, normal member
   }
   return corpId;
 }
示例#2
0
  @Override
  public boolean addTeamMembers(long curUserId, int corpId, String accountList) {
    if (!canUserManageCorp(curUserId, corpId)) return false;

    String[] accs = accountList.split(",");
    Corporation c = getCorporation(corpId);
    for (String acc : accs) {
      User u = accountMgr.getUser(acc);
      if (u != null) {
        if (!organizationDao.isUserInCorp(u.getId(), corpId) && u.getId() != c.getUserId()) {
          organizationDao.addUserToCorp(corpId, u.getId(), 3);
        }
      }
    }

    return true;
  }