Exemplo n.º 1
0
  @RequestMapping(value = "/create", method = RequestMethod.POST)
  public ModelAndView createEmployee(
      @RequestParam String name, @RequestParam int employeeId, @RequestParam String password) {

    if (!userService.getUserByName(name)) {

      Employee employee = employeeService.getEmployeeById(employeeId);
      User user = new User(name, EncryptionHelper.md5(password), employee);
      userService.createUser(user);
    }

    return new ModelAndView("redirect:/users/");
  }
Exemplo n.º 2
0
  @RequestMapping(value = "/update", method = RequestMethod.POST)
  public ModelAndView UpdateUser(
      @RequestParam int id,
      @RequestParam int employee_id,
      @RequestParam String nickName,
      @RequestParam String name,
      @RequestParam String role,
      @RequestParam String password,
      @RequestParam String gender,
      @RequestParam int age,
      @RequestParam String email) {

    Employee employee = new Employee(employee_id, name, gender, age, email, role);
    userService.updateUser(new User(id, nickName, EncryptionHelper.md5(password), employee));

    return new ModelAndView("redirect:/users/");
  }