Commit c6b3eac6 authored by 赵啸非's avatar 赵啸非

修改登录鉴权时间

parent b88e72a2
package com.mortals.xhx.common.utils; package com.mortals.xhx.common.utils;
import cn.hutool.core.compress.Gzip;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ZipUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import java.io.File; import java.io.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.zip.GZIPInputStream;
@Slf4j @Slf4j
public class ZipUtils { public class ZipUtils {
...@@ -191,12 +191,87 @@ public class ZipUtils { ...@@ -191,12 +191,87 @@ public class ZipUtils {
} }
public static void main(String[] args) { private static final int BUFFER_SIZE = 1024;
/**
* 解压 gzip 文件
*
* @param input
* @param output
*
*/
public static void decompressGzip(File input, File output) throws IOException {
try (GZIPInputStream in = new GZIPInputStream(new FileInputStream(input))) {
try (FileOutputStream out = new FileOutputStream(output)) {
byte[] buffer = new byte[BUFFER_SIZE];
int len;
while((len = in.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
}
}
}
/**
* 解压 tar.gz 文件到指定目录
*
* @param tarGzFile tar.gz 文件路径
* @param destDir 解压到 destDir 目录,如果没有则自动创建
*
*/
public static void extractTarGZ(File tarGzFile, String destDir) throws IOException {
GzipCompressorInputStream gzipIn = new GzipCompressorInputStream(new FileInputStream(tarGzFile));
try (TarArchiveInputStream tarIn = new TarArchiveInputStream(gzipIn)) {
TarArchiveEntry entry;
while ((entry = (TarArchiveEntry) tarIn.getNextEntry()) != null) {
if (entry.isDirectory()) {
File f = new File(destDir + "/" + entry.getName());
boolean created = f.mkdirs();
if (!created) {
System.out.printf("Unable to create directory '%s', during extraction of archive contents.\n",
f.getAbsolutePath());
}
} else {
int count;
byte [] data = new byte[BUFFER_SIZE];
new File(destDir + "/" + entry.getName())
File parent = curfile.getParentFile();
log.info("***文件保存的路径" + curfile.getAbsolutePath());
if (!parent.exists()) {
parent.mkdirs();
}
FileOutputStream fos = new FileOutputStream(destDir + "/" + entry.getName(), false);
try (BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE)) {
while ((count = tarIn.read(data, 0, BUFFER_SIZE)) != -1) {
dest.write(data, 0, count);
}
}
}
}
}
}
public static void main(String[] args) throws IOException {
String fileName = "E:\\pic\\zip\\base-manager.tar.gz"; String fileName = "E:\\pic\\zip\\base-manager.tar.gz";
String unZipPath = "E:\\pic\\zip\\"; String unZipPath = "E:\\pic\\zip\\";
ZipUtils.unGzip(fileName, unZipPath); //ZipUtils.unGzip(fileName, unZipPath);
File file = new File(fileName);
/* File file = new File(fileName);
;
byte[] bytes = ZipUtil.unGzip(FileUtil.readBytes(file));*/
ZipUtils.extractTarGZ(file, unZipPath);
} }
......
package com.mortals.xhx.module.setup.service.impl; package com.mortals.xhx.module.setup.service.impl;
import cn.hutool.Hutool; import cn.hutool.Hutool;
import cn.hutool.core.compress.Gzip;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.RuntimeUtil; import cn.hutool.core.util.RuntimeUtil;
...@@ -103,13 +104,17 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec ...@@ -103,13 +104,17 @@ public class SetupProjectServiceImpl extends AbstractCRUDServiceImpl<SetupProjec
throw new AppException("请上传项目工程文件!"); throw new AppException("请上传项目工程文件!");
} }
InputStream inputStream = FileUtil.getInputStream(file); // InputStream inputStream = FileUtil.getInputStream(file);
///Hutoo.unGzip(inputStream, setupProjectEntity.getProjectPath()); ///Hutoo.unGzip(inputStream, setupProjectEntity.getProjectPath());
//Hutool //Hutool
try {
ZipUtils.unGzip(inputStream, setupProjectEntity.getProjectPath()); ZipUtils.extractTarGZ(file, setupProjectEntity.getProjectPath());
} catch (IOException e) {
log.error("解压失败!{}", e.getMessage());
}
// ZipUtils.unGzip(inputStream, setupProjectEntity.getProjectPath());
String publicPath = setupProjectEntity.getProjectPath() + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getValue(); String publicPath = setupProjectEntity.getProjectPath() + ProductDisEnum.getByValue(setupProjectEntity.getProjectCode()).getValue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment