Esempio n. 1
0
  @RequestMapping(value = "employeeRole.html", method = RequestMethod.POST)
  public String employeeRole(Integer employeeId, Integer[] roleId, HttpServletRequest request) {
    employeeRoleService.deleteByEid(employeeId);

    List<EmployeeRole> list = new ArrayList<EmployeeRole>();
    if (roleId != null) {
      for (int i = 0; i < roleId.length; i++) {
        Integer rid = roleId[i];
        EmployeeRole employeeRole = new EmployeeRole();
        employeeRole.setCreatedAt(new Date());
        employeeRole.setUpdatedAt(new Date());
        employeeRole.setRoleId(rid);
        employeeRole.setEmployeeId(employeeId);
        list.add(employeeRole);
      }
      employeeRoleService.addAll(list.toArray(new EmployeeRole[0]));
    }
    request.setAttribute("message", "角色分配成功.");
    return doEmployeeRole(employeeId, request);
  }
Esempio n. 2
0
  @RequestMapping(value = "doEmployeerole.html", method = RequestMethod.GET)
  public String doEmployeeRole(Integer employeeId, HttpServletRequest request) {
    List<Role> roles = roleService.findRoles();
    List<EmployeeRole> employeeRoles = employeeRoleService.findEmployeeRoleByEid(employeeId);

    List<String> list = new ArrayList<String>();
    for (int i = 0; i < employeeRoles.size(); i++) {
      list.add(employeeRoles.get(i).getRoleId() + "");
    }
    request.setAttribute("employeeRoles", list);
    request.setAttribute("roles", roles);
    request.setAttribute("employeeId", employeeId);
    return "admin/employee/employeerole";
  }