| | |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.Md5Helper; |
| | | import com.lf.server.helper.RsaHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.data.DownloadService; |
| | |
| | | @SysLog() |
| | | @ApiOperation(value = "下载文件") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query") |
| | | @ApiImplicitParam(name = "guid", value = "文件GUID", dataType = "String", paramType = "query"), |
| | | @ApiImplicitParam(name = "pwd", value = "密码", dataType = "String", paramType = "query") |
| | | }) |
| | | @ResponseBody |
| | | @RequestMapping(value = "/downloadFile", method = RequestMethod.GET) |
| | | public void downloadFile(@RequestBody DownloadReqEntity reqEntity, HttpServletRequest req, HttpServletResponse res) { |
| | | @GetMapping(value = "/downloadFile") |
| | | public void downloadFile(String guid, String pwd, HttpServletRequest req, HttpServletResponse res) { |
| | | try { |
| | | if (null == reqEntity || StringHelper.isEmpty(reqEntity.getPwd())) { |
| | | WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "密码不能为空", res); |
| | | } |
| | | if (StringHelper.isEmpty(reqEntity.getGuid())) { |
| | | WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "找不到文件ID", res); |
| | | return; |
| | | if (StringHelper.isEmpty(guid) || StringHelper.isEmpty(pwd)) { |
| | | WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "文件ID和密码不能为空", res); |
| | | } |
| | | |
| | | DownloadEntity de = downloadService.selectByGuid(reqEntity.getGuid()); |
| | | String password = downloadService.decryptPwd(pwd); |
| | | if (null == password) { |
| | | WebHelper.writeInfo(HttpStatus.BAD_REQUEST, "密码解密失败", res); |
| | | } |
| | | |
| | | DownloadEntity de = downloadService.selectByGuid(guid); |
| | | if (null == de) { |
| | | WebHelper.writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res); |
| | | return; |
| | | } |
| | | if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(reqEntity.getPwd(), de.getPwd())) { |
| | | if (!StringHelper.isNull(de.getPwd()) && !Md5Helper.validatePassword(password, de.getPwd())) { |
| | | WebHelper.writeInfo(HttpStatus.UNAUTHORIZED, "密码不正确", res); |
| | | } |
| | | |