Esempio n. 1
0
  @SuppressWarnings("unchecked")
  public Employee editEmployee_save(
      Employee emp,
      User user,
      List<EmployeeResume> resumes,
      List<EmployeeFamily> familys,
      int roles0Id) {
    List resumeList = new ArrayList();
    List familyList = new ArrayList();
    Employee employee0 = userDAO.getEmployeeById(emp.getId());
    // 员工编号不变
    emp.setEmpNo(employee0.getEmpNo());

    if (user != null) {
      User user0 = userDAO.getUserById(user.getId());
      // 处理用户名和密码不变
      user.setUsername(user0.getUsername());
      user.setPassword(user0.getPassword());
      // 处理用户角色
      Set roleSet = new HashSet();
      roleSet.add(systemDAO.getRoleById(roles0Id));
      user.setRoles(roleSet);

      user.setEmployee(emp);
      emp.setUser(user);
      // userDAO.editUser(user);
    }

    if (resumes != null) {
      for (Iterator iterator = resumes.iterator(); iterator.hasNext(); ) {
        EmployeeResume resume = (EmployeeResume) iterator.next();
        if (!("".equals(resume.getCompany().trim()))) {
          resume.setEmployee(emp);
          resumeList.add(resume);
        } else {
          if (resume.getId() != 0) {
            userDAO.removeEmployeeResume(resume.getId());
          }
        }
      }
    }
    if (familys != null) {
      for (Iterator iterator = familys.iterator(); iterator.hasNext(); ) {
        EmployeeFamily family = (EmployeeFamily) iterator.next();
        if (!("".equals(family.getName().trim()))) {
          family.setEmployee(emp);
          familyList.add(family);
        } else {
          if (family.getId() != 0) {
            userDAO.removeEmployeeFamily(family.getId());
          }
        }
      }
    }
    emp.setResume(resumeList);
    emp.setFamily(familyList);
    userDAO.saveEmployee(emp);
    return emp;
  }
Esempio n. 2
0
 public User CheckLogin(User user) {
   User u = userDAO.validateUser(user.getUsername(), user.getPassword());
   if (u != null) {
     Timestamp t =
         new Timestamp(new GregorianCalendar(TimeZone.getTimeZone("GMT")).getTimeInMillis());
     u.setLastLoginTime(t);
     userDAO.editUser(u);
   }
   return u;
 }