@RequestMapping("uncompress")
  public String uncompress(
      @RequestParam(value = "descPath") String descPath,
      @RequestParam(value = "paths") String[] paths,
      @RequestParam(value = "conflict") String conflict,
      RedirectAttributes redirectAttributes)
      throws IOException {

    String rootPath = sc.getRealPath(ROOT_DIR);
    descPath = URLDecoder.decode(descPath, Constants.ENCODING);

    for (int i = 0, l = paths.length; i < l; i++) {
      String path = paths[i];
      path = URLDecoder.decode(path, Constants.ENCODING);
      // 只保留.zip的
      if (!path.toLowerCase().endsWith(".zip")) {
        continue;
      }
      paths[i] = rootPath + File.separator + path;
    }

    try {

      String descAbsolutePath = rootPath + File.separator + descPath;
      for (String path : paths) {
        CompressUtils.unzip(path, descAbsolutePath, "override".equals(conflict));
      }
      redirectAttributes.addFlashAttribute(Constants.MESSAGE, "解压成功!");
    } catch (Exception e) {
      redirectAttributes.addFlashAttribute(Constants.ERROR, e.getMessage());
    }

    redirectAttributes.addAttribute("path", URLEncoder.encode(descPath, Constants.ENCODING));
    return redirectToUrl(viewName("list"));
  }
  // 压缩
  @RequestMapping("compress")
  public String compress(
      @RequestParam(value = "parentPath") String parentPath,
      @RequestParam(value = "paths") String[] paths,
      RedirectAttributes redirectAttributes)
      throws IOException {

    String rootPath = sc.getRealPath(ROOT_DIR);
    parentPath = URLDecoder.decode(parentPath, Constants.ENCODING);

    Date now = new Date();
    String pattern = "yyyyMMddHHmmss";

    String compressPath =
        parentPath
            + File.separator
            + "[系统压缩]"
            + DateFormatUtils.format(now, pattern)
            + "-"
            + System.nanoTime()
            + ".zip";

    for (int i = 0, l = paths.length; i < l; i++) {
      String path = paths[i];
      path = URLDecoder.decode(path, Constants.ENCODING);
      paths[i] = rootPath + File.separator + path;
    }

    try {
      CompressUtils.zip(rootPath + File.separator + compressPath, paths);
      String msg =
          "压缩成功,<a href='%s/%s?path=%s' target='_blank' class='btn btn-primary'>点击下载</a>,下载完成后,请手工删除生成的压缩包";
      redirectAttributes.addFlashAttribute(
          Constants.MESSAGE,
          String.format(
              msg,
              sc.getContextPath(),
              viewName("download"),
              URLEncoder.encode(compressPath, Constants.ENCODING)));

    } catch (Exception e) {
      redirectAttributes.addFlashAttribute(Constants.ERROR, e.getMessage());
    }

    redirectAttributes.addAttribute("path", URLEncoder.encode(parentPath, Constants.ENCODING));
    return redirectToUrl(viewName("list"));
  }
  @RequestMapping("copy")
  public String copy(
      @RequestParam(value = "descPath") String descPath,
      @RequestParam(value = "paths") String[] paths,
      @RequestParam(value = "conflict") String conflict,
      RedirectAttributes redirectAttributes)
      throws IOException {

    String rootPath = sc.getRealPath(ROOT_DIR);
    descPath = URLDecoder.decode(descPath, Constants.ENCODING);

    for (int i = 0, l = paths.length; i < l; i++) {
      String path = paths[i];
      path = URLDecoder.decode(path, Constants.ENCODING);
      paths[i] = (rootPath + File.separator + path).replace("\\", "/");
    }

    try {
      File descPathFile = new File(rootPath + File.separator + descPath);
      for (String path : paths) {
        File sourceFile = new File(path);
        File descFile = new File(descPathFile, sourceFile.getName());
        if (descFile.exists() && "ignore".equals(conflict)) {
          continue;
        }

        FileUtils.deleteQuietly(descFile);

        if (sourceFile.isDirectory()) {
          FileUtils.copyDirectoryToDirectory(sourceFile, descPathFile);
        } else {
          FileUtils.copyFileToDirectory(sourceFile, descPathFile);
        }
      }
      redirectAttributes.addFlashAttribute(Constants.MESSAGE, "复制成功!");
    } catch (Exception e) {
      redirectAttributes.addFlashAttribute(Constants.ERROR, e.getMessage());
    }

    redirectAttributes.addAttribute("path", URLEncoder.encode(descPath, Constants.ENCODING));
    return redirectToUrl(viewName("list"));
  }