Beispiel #1
0
  // @RequestMapping(value = "queryAllRoleList", method = { RequestMethod.POST })
  public String queryAllRoleList(HttpServletRequest request, HttpServletResponse response) {
    int page = Integer.parseInt(request.getParameter("page")); // 当前页数
    int rows = Integer.parseInt(request.getParameter("rows")); // 每页多少行
    int startNum = page * rows - rows; // 分页查询开始位置
    String roleJsonStr = "";
    Datagrid datagrid = new Datagrid();
    int roleTotalCount = roleService.queryRoleTotalCount(); // 统计角色数量
    List<Role> roleList = roleService.quryAllRoleList(startNum, rows); // 查询角色列表
    datagrid.setRows(roleList);
    datagrid.setTotal(roleTotalCount);
    try {
      // 将查询的角色集合list转换成json格式字符串
      roleJsonStr = Json.toJson(datagrid); // JsonUtils.objectToJackson(datagrid, Datagrid.class);
      PrintWriter out = response.getWriter();
      out.print(roleJsonStr);
      out.flush();
      out.close();
      request.setAttribute("roleJsonStr", roleJsonStr);
    } catch (Exception e) {
      log.error("处理json数据报错:" + e.getStackTrace());
    }
    log.info(roleJsonStr);

    return null;
  }
Beispiel #2
0
  // @RequestMapping(value="getRoleByRoleName",method={RequestMethod.POST})
  public String getRoleByRoleName(
      HttpServletRequest request, HttpServletResponse response, String roleName) {
    int page = Integer.parseInt(request.getParameter("page")); // 当前页数
    int rows = Integer.parseInt(request.getParameter("rows")); // 每页多少行
    int startNum = page * rows - rows; // 分页查询开始位置

    List<Role> roles = roleService.getRoleByRoleName(roleName, startNum, rows);
    int rolesTotalCountByRoleName = roleService.getRolesTotalCountByRoleName(roleName);
    Datagrid datagrid = new Datagrid();
    datagrid.setRows(roles);
    datagrid.setTotal(rolesTotalCountByRoleName);
    String rolesJsonStr = "";
    try {
      rolesJsonStr =
          Json.toJson(
              datagrid); // JsonUtils.objectToJackson(datagrid, Datagrid.class);// 将对象转换成json字符串
      PrintWriter out = response.getWriter();
      out.print(rolesJsonStr);
      out.flush();
      out.close();
    } catch (Exception e) {
      log.error("处理json数据报错:" + e.getStackTrace());
    }
    return null;
  }
Beispiel #3
0
 // @RequestMapping(value = "validataRoleName", method = { RequestMethod.POST })
 public void validataRoleName(HttpServletResponse response, String roleName) {
   int i = roleService.valiedateRoleName(roleName);
   String ok = i + "";
   try {
     PrintWriter out = response.getWriter();
     out.write(ok);
     out.flush();
     out.close();
   } catch (IOException e) {
     log.error("处理数据报错:" + e.getStackTrace());
   }
 }
Beispiel #4
0
 // @RequestMapping(value = "deleteRoles", method = { RequestMethod.GET })
 public String deleteRoles(HttpServletResponse response, String ids) {
   String msg = "";
   try {
     roleService.deleteRoles(ids);
     msg = "1";
   } catch (Exception e) {
     msg = "0";
     log.error("删除角色失败:" + e.getStackTrace());
   }
   // ResponseUtils.renderText(response, msg);
   return null;
 }
Beispiel #5
0
 // @RequestMapping(value = "saveRole", method = { RequestMethod.POST })
 public String saveRole(
     HttpServletRequest request, HttpServletResponse response, Role role, String selectAuthIds) {
   String msg = "";
   try {
     roleService.saveRole(request, role, selectAuthIds); // 保存角色
     msg = "1"; // 保存角色成功
   } catch (Exception e) {
     msg = "0"; // 保存角色失败
     log.error("保存角色失败:" + e.getStackTrace());
   }
   // ResponseUtils.renderText(response, msg);
   return null;
 }
Beispiel #6
0
 // @RequestMapping(value = "loadAllAuthTree", method = { RequestMethod.POST })
 public String loadAllAuthTree(HttpServletRequest request, HttpServletResponse response) {
   String id = request.getParameter("id");
   List<Authority> checkedAuthList = roleService.getCheckedAuthIds(id);
   String authTreeJson = menusService.createAuthTree(checkedAuthList);
   log.info(authTreeJson);
   PrintWriter out;
   try {
     out = response.getWriter();
     out.print(authTreeJson);
     out.flush();
     out.close();
   } catch (IOException e) {
     log.error("处理json数据报错:" + e.getStackTrace());
   }
   return null;
 }
Beispiel #7
0
 // @RequestMapping(value = "getRoleByCode", method = { RequestMethod.GET })
 public String getRoleByCode(HttpServletRequest request, String id) {
   Role role = roleService.getRoleById(id);
   request.setAttribute("role", role);
   return "role/roleDetails";
 }