| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | @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("密码解密失败", 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); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query"), |
| | |
| | | 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, "密码解密失败", res); |