Commit 68913dcf authored by 赵啸非's avatar 赵啸非

添加文件压缩

parent b2af7ed1
...@@ -301,15 +301,13 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk ...@@ -301,15 +301,13 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
/** /**
* 临时方法 归类下载 * 临时方法 归类下载
*
* @param context * @param context
* @return * @return
*/ */
@Override @Override
public Rest<byte[]> compressSkinZip(SkinBaseEntity query,Context context) { public Rest<byte[]> compressSkinZip(SkinBaseEntity query, Context context) {
String sourcePathZip = uploadService.getFilePath(query.getLocalZipPath()); String sourcePathZip = uploadService.getFilePath(query.getLocalZipPath());
File zipFile = new File(sourcePathZip);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
//查询所有 //查询所有
...@@ -322,7 +320,6 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk ...@@ -322,7 +320,6 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
continue; continue;
} }
try { try {
zip.putNextEntry(new ZipEntry(StrUtil.subAfter(filePath, "/", false))); zip.putNextEntry(new ZipEntry(StrUtil.subAfter(filePath, "/", false)));
IOUtils.write(FileUtil.readBytes(file), zip); IOUtils.write(FileUtil.readBytes(file), zip);
zip.flush(); zip.flush();
...@@ -330,31 +327,9 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk ...@@ -330,31 +327,9 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
} catch (Exception e) { } catch (Exception e) {
log.error("异常", e); log.error("异常", e);
} }
/* log.info("file:"+file.getPath());
ZipUtil.append(zipFile.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);*/
/*
try {
zip.putNextEntry(new ZipEntry(filePath));
zip.flush();
zip.closeEntry();
} catch (IOException e) {
}*/
} }
/* IOUtils.closeQuietly(zip);
File downloadFile = new File("/home/css.zip");
FileUtil.writeToStream(downloadFile, outputStream);*/
//byte[] bytes = FileUtil.readBytes(zipFile);
IOUtils.closeQuietly(zip); IOUtils.closeQuietly(zip);
return Rest.ok(outputStream.toByteArray()); return Rest.ok(outputStream.toByteArray());
} }
...@@ -365,7 +340,7 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk ...@@ -365,7 +340,7 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
* @return * @return
*/ */
@Override @Override
public Rest<Void> updateResourcePath(SkinBaseEntity query,Context context) { public Rest<Void> updateResourcePath(SkinBaseEntity query, Context context) {
List<SkinBaseEntity> skinBaseEntities = this.find(new SkinBaseEntity()); List<SkinBaseEntity> skinBaseEntities = this.find(new SkinBaseEntity());
for (SkinBaseEntity skinBaseEntity : skinBaseEntities) { for (SkinBaseEntity skinBaseEntity : skinBaseEntities) {
skinBaseEntity.setCssFilePath(StrUtil.appendIfMissing(skinBaseEntity.getCssFilePath(), "/")); skinBaseEntity.setCssFilePath(StrUtil.appendIfMissing(skinBaseEntity.getCssFilePath(), "/"));
......
...@@ -160,6 +160,24 @@ public class SkinBaseController extends BaseCRUDJsonBodyMappingController<SkinBa ...@@ -160,6 +160,24 @@ public class SkinBaseController extends BaseCRUDJsonBodyMappingController<SkinBa
} }
@GetMapping(value = "updateSkinPath")
@UnAuth
public void updateSkinPath() {
JSONObject jsonObject = new JSONObject();
try {
SkinBaseEntity query = new SkinBaseEntity();
this.service.updateResourcePath(query, getContext());
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "更新成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
}
/** /**
* 生成zip文件 * 生成zip文件
*/ */
......
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