From 7c8ea4b6a9d77df043362ccf6ea38c0089514972 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期一, 28 十一月 2022 14:40:39 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/data/MetaController.java | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lf/server/controller/data/MetaController.java b/src/main/java/com/lf/server/controller/data/MetaController.java index 663138a..685a595 100644 --- a/src/main/java/com/lf/server/controller/data/MetaController.java +++ b/src/main/java/com/lf/server/controller/data/MetaController.java @@ -21,6 +21,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.util.List; /** @@ -279,10 +280,50 @@ } List<MetaFileEntity> list = metaService.selectMetaFiles(reqEntity.getIds()); + if (null == list || list.isEmpty()) { + return fail("娌℃湁鎵惧埌鍏冩暟鎹�"); + } - return success(true); + UserEntity ue = tokenService.getCurrentUser(req); + String guid = downloadService.zipFiles(ue, list, reqEntity.getPwd()); + + return success(guid); } catch (Exception ex) { return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ涓嬭浇鏂囦欢") + @ApiImplicitParams({ + @ApiImplicitParam(name = "guid", value = "鏂囦欢GUID", dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "pwd", value = "瀵嗙爜", dataType = "String", paramType = "query") + }) + @GetMapping(value = "/selectDownloadFile") + public ResponseMsg<Boolean> selectDownloadFile(String guid, String pwd) { + try { + if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) { + return fail("鏂囦欢ID鍜屽瘑鐮佷笉鑳戒负绌�", null); + } + String password = downloadService.decryptPwd(pwd); + if (null == password) { + return fail("瀵嗙爜瑙e瘑澶辫触", null); + } + + DownloadEntity de = downloadService.selectByGuid(guid); + if (null == de) { + return fail("鏂囦欢涓嶅瓨鍦�", null); + } + if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(password, de.getPwd())) { + return fail("瀵嗙爜涓嶆纭�", null); + } + + String filePath = downloadService.getDownloadFilePath(de); + File file = new File(filePath); + + return success(file.exists()); + } catch (Exception ex) { + return fail(ex.getMessage(), false); } } @@ -299,7 +340,6 @@ if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) { WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "鏂囦欢ID鍜屽瘑鐮佷笉鑳戒负绌�", res); } - String password = downloadService.decryptPwd(pwd); if (null == password) { WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "瀵嗙爜瑙e瘑澶辫触", res); -- Gitblit v1.9.3