예제 #1
0
 /**
  * 获取所有角色信息
  *
  * @param request
  * @return json
  */
 @POST
 @Path(value = "/queryRole/all")
 public String queryRole(@Context HttpServletRequest request) {
   int pageIndex = Integer.parseInt((request.getParameter("page")));
   int pageSize = Integer.parseInt((request.getParameter("rows")));
   // CustomerContextHolder.setCustomerType("x6");
   List<Role> list = cmRoleManageService.queryRole((pageIndex - 1) * pageSize, pageSize);
   List list1 = new ArrayList();
   Role role;
   for (int i = 0; i < list.size(); i++) {
     role = new Role();
     role.setRoleid(((Role) list.get(i)).getRoleid());
     role.setRolename(((Role) list.get(i)).getRolename());
     role.setRoledesc(((Role) list.get(i)).getRoledesc());
     list1.add(role);
   }
   // Role role = list.get(0);
   // System.out.println(role.getCMMenus());
   String json =
       "{\"total\":"
           + cmRoleManageService.getRoleSize()
           + ", \"rows\":"
           + gson.toJson(list1)
           + "}";
   // System.out.println(json);
   return json;
 }
예제 #2
0
  /**
   * 根据角色名模糊查询角色信息
   *
   * @param rolename
   * @param request
   * @return json
   */
  @POST
  @Path(value = "/queryRole/name/{rolename}")
  public String queryRoleByName(
      @PathParam(value = "rolename") String rolename, @Context HttpServletRequest request) {
    int pageIndex = Integer.parseInt((request.getParameter("page")));
    int pageSize = Integer.parseInt((request.getParameter("rows")));
    // CustomerContextHolder.setCustomerType(DynamicDataSourceType.S1);
    // CustomerContextHolder.setCustomerType("x6");
    List<Role> list =
        cmRoleManageService.getRoleByRoleName(rolename, (pageIndex - 1) * pageSize, pageSize);
    List list1 = new ArrayList();
    Role role;
    for (int i = 0; i < list.size(); i++) {
      role = new Role();
      role.setRoleid(((Role) list.get(i)).getRoleid());
      role.setRolename(((Role) list.get(i)).getRolename());
      role.setRoledesc(((Role) list.get(i)).getRoledesc());
      list1.add(role);
    }

    String json =
        "{\"total\":"
            + cmRoleManageService.getRoleSizeByRoleName(rolename)
            + ", \"rows\":"
            + gson.toJson(list1)
            + "}";
    return json;
  }
예제 #3
0
  @POST
  @Path(value = "/roleChange")
  public void saveChangeRoles(
      @Context HttpServletRequest request, @Context HttpServletResponse response)
      throws IOException {
    String deleted = request.getParameter("deleted");
    String inserted = request.getParameter("inserted");
    String updated = request.getParameter("updated");

    Type type = new TypeToken<List<Role>>() {}.getType();
    HashMap map = new HashMap();
    List<Role> list = gson.fromJson(inserted, type);
    map.put("inserted", list);
    list = gson.fromJson(updated, type);

    list = gson.fromJson(deleted, type);
    map.put("deleted", list);
    // CustomerContextHolder.setCustomerType("x6");
    String rs = cmRoleManageService.saveRole(map);

    PrintWriter pwriter = response.getWriter();
    if ("1".equals(rs)) {
      pwriter.print("01");
    } else {
      pwriter.print("00");
    }

    pwriter.close();
  }
예제 #4
0
 @POST
 @Path(value = "/delMenu/id/{roleid}")
 public String delMenuForRole(
     @PathParam(value = "roleid") String roleid, @Context HttpServletRequest request) {
   String deleted = request.getParameter("deleted");
   Type type = new TypeToken<List<Menu>>() {}.getType();
   List<Menu> list = gson.fromJson(deleted, type);
   String[] menuids = new String[list.size()];
   for (int i = 0; i < list.size(); i++) {
     menuids[i] = list.get(i).getMenuid().toString();
   }
   // CustomerContextHolder.setCustomerType("x6");
   return cmRoleManageService.delMenuForRole(roleid, menuids);
 }
예제 #5
0
 @POST
 @Path(value = "/addMenu/id/{roleid}/{menuids}")
 public String addMenuForRole(
     @PathParam(value = "roleid") String roleid,
     @PathParam(value = "menuids") String menuids,
     @Context HttpServletRequest request) {
   String menuGrant = request.getParameter("grant");
   Type type = new TypeToken<List<Menu>>() {}.getType();
   List<Menu> list = gson.fromJson(menuGrant, type);
   String[] menuIDArray = new String[list.size()];
   for (int i = 0; i < list.size(); i++) {
     menuIDArray[i] = list.get(i).getMenuid().toString();
   }
   // CustomerContextHolder.setCustomerType("x6");
   return cmRoleManageService.addMenuForRole(roleid, menuIDArray);
 }