Ejemplo 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;
  }
Ejemplo n.º 2
0
  @Override
  public User changeUsername_save(User user) {
    User user0 = userDAO.getUserById(user.getId());
    user0.setUsername(user.getUsername());
    userDAO.editUser(user0);

    return user0;
  }
Ejemplo n.º 3
0
  public Employee changeUserPassword_save(int id, String userPassword) {
    User user = userDAO.getUserById(id);
    Employee employee = userDAO.getEmployeeById(user.getEmployee().getId());
    Encrypt te = new Encrypt();
    user.setPassword(te.StringEncrypt(userPassword, "MD5"));
    userDAO.editUser(user);

    return userDAO.getEmployeeById(employee.getId());
  }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 public int checkUsernameForReg(String username) {
   String hql = "from User u where u.username='******'";
   int userAmount = userDAO.getUserByHql(hql).size();
   if (userAmount == 0) {
     return 1;
   }
   return 0;
 }
Ejemplo n.º 6
0
  public Employee editEmployee(int id) {
    Employee employee = userDAO.getEmployeeById(id);
    employee.getResume().add(new EmployeeResume());
    employee.getResume().add(new EmployeeResume());

    employee.getFamily().add(new EmployeeFamily());
    employee.getFamily().add(new EmployeeFamily());
    return employee;
  }
Ejemplo n.º 7
0
  @SuppressWarnings("unchecked")
  public Employee addEmployee_save(Employee emp, User user, int roles0Id) {
    // 处理用户角色
    Set roleSet = new HashSet();
    roleSet.add(systemDAO.getRoleById(roles0Id));
    user.setRoles(roleSet);
    // 建立用户和Emp的关系
    user.setEmployee(emp);
    emp.setUser(user);
    // 设置用户状态为试用期状态
    emp.setWorkStatus(1);
    // 设置进厂时间为当前时间
    Timestamp t =
        new Timestamp(new GregorianCalendar(TimeZone.getTimeZone("GMT")).getTimeInMillis());
    emp.setParticipateDate(t);
    userDAO.saveEmployee(emp);
    userDAO.addUser(user);
    Employee employeeDb = userDAO.getLastEmployee();
    employeeDb.setEmpNo(userDAO.getEmpNo(employeeDb.getId()));
    user.setEmployee(employeeDb);

    userDAO.saveEmployee(employeeDb);
    return employeeDb;
  }
Ejemplo n.º 8
0
 @Override
 public List<Employee> getAllEmployee() {
   return userDAO.getAllEmployee();
 }
Ejemplo n.º 9
0
 public void saveEmployee(Employee employee) {
   userDAO.saveEmployee(employee);
 }
Ejemplo n.º 10
0
 public int getEmpNo(int id) {
   return userDAO.getEmpNo(id);
 }
Ejemplo n.º 11
0
 public List<Employee> getEmployeeByDeptId(int deptId) {
   return userDAO.getEmployeeByDeptId(deptId);
 }
Ejemplo n.º 12
0
 public int getCountOfEmployeeListByWorkStatus(int workStatus) {
   return userDAO.getConuntOfEmployeeListByWorkStatus(workStatus);
 }
Ejemplo n.º 13
0
 public void addPhotoToEmployee_save(Employee employee) {
   userDAO.saveEmployee(employee);
 }
Ejemplo n.º 14
0
 public Employee Employee(int id) {
   return userDAO.getEmployeeById(id);
 }
Ejemplo n.º 15
0
 public List<Employee> getEmployeeListByWorkStatus(int workStatus, int currentPage, int pageSize) {
   return userDAO.getEmployeeByWorkStatus(workStatus, currentPage, pageSize);
 }
Ejemplo n.º 16
0
 public User getUserById(int UserId) {
   return userDAO.getUserById(UserId);
 }