Exemplo n.º 1
0
  /**
   * 设置角色权限
   *
   * @param request
   * @param response
   * @return
   */
  public String setauthority(HttpServletRequest request, HttpServletResponse response) {
    Role role = null;
    try {
      role = iroleService.getRoleById(Long.parseLong(request.getParameter("id")));
    } catch (Exception e1) {
      e1.printStackTrace();
    }
    String austr = request.getParameter("austr");
    List<String> list = new ArrayList<String>();

    if (austr != null && austr != "") {
      String[] au = austr.split(",");
      for (int i = 0; i < au.length; i++) {
        list.add(au[i]);
      }
    }

    if (role != null) {
      role.setAuthority(GsonUtil.getJsonFromObject(list));
    }

    try {
      iroleService.updateRole(role);
    } catch (Exception e) {
      AjaxReturnUtil rmsg = new AjaxReturnUtil(false, e.getMessage(), null);
      return GsonUtil.getJsonFromObject(rmsg);
    }
    AjaxReturnUtil rmsg = new AjaxReturnUtil(true, "成功", null);
    return GsonUtil.getJsonFromObject(rmsg);
  }
Exemplo n.º 2
0
 /**
  * 修改角色
  *
  * @param request
  * @param response
  * @return
  */
 public String edit(HttpServletRequest request, HttpServletResponse response) {
   Role role = new Role();
   role.setId(Long.parseLong(request.getParameter("id")));
   role.setRolename(request.getParameter("rolename"));
   try {
     iroleService.updateRole(role);
   } catch (Exception e) {
     AjaxReturnUtil rmsg = new AjaxReturnUtil(false, e.getMessage(), null);
     return GsonUtil.getJsonFromObject(rmsg);
   }
   AjaxReturnUtil rmsg = new AjaxReturnUtil(true, "成功", null);
   return GsonUtil.getJsonFromObject(rmsg);
 }