Commit e7243de1 by 龙于生

云盘 查询文件是否存在、新增文件查看记录 接口

parent daf83d2f
...@@ -226,16 +226,17 @@ public class DiskFilesController { ...@@ -226,16 +226,17 @@ public class DiskFilesController {
@GetMapping(value = "/exportContract") @GetMapping(value = "/exportContract")
public void exportContract(@CurrentUser UserBean userBean, @ApiParam("文件ID") @RequestParam(required = true) Integer fileId, public void exportContract(@CurrentUser UserBean userBean, @ApiParam("文件ID") @RequestParam(required = true) Integer fileId,
@ApiParam("下载通道默认不传:我收到的列表下载传type=1") @RequestParam(required = false) Integer type, HttpServletResponse resp) { @ApiParam("下载通道默认不传:我收到的列表下载传type=1") @RequestParam(required = false) Integer type, HttpServletResponse resp) {
if (fileId == null || fileId <= 0) { DiskFiles diskFiles = DiskFiles.builder().id(fileId).build().selectById();
/*if (fileId == null || fileId <= 0) {
throw new CustomException("下载失败,请选择文件下载"); throw new CustomException("下载失败,请选择文件下载");
} }
DiskFiles diskFiles = DiskFiles.builder().id(fileId).build().selectById();
if(StringUtils.isEmpty(diskFiles)){ if(StringUtils.isEmpty(diskFiles)){
throw new CustomException("下载失败,文件不存在"); throw new CustomException("下载失败,文件不存在");
} }
if(diskFiles.getDeleteFlag() == 1 && StringUtils.isEmpty(type)){ if(diskFiles.getDeleteFlag() == 1 && StringUtils.isEmpty(type)){
throw new CustomException("下载失败,该文件已删除"); throw new CustomException("下载失败,该文件已删除");
} }*/
InputStream fis = null; InputStream fis = null;
BufferedInputStream bis = null; BufferedInputStream bis = null;
OutputStream os; OutputStream os;
...@@ -285,10 +286,17 @@ public class DiskFilesController { ...@@ -285,10 +286,17 @@ public class DiskFilesController {
@ApiOperation(value = "新增文件查看记录", httpMethod = "GET", notes = "新增文件查看记录") @ApiOperation(value = "新增文件查看记录", httpMethod = "GET", notes = "新增文件查看记录")
@GetMapping(value = "/look_log/{fileId}") @GetMapping(value = "/add_look_log")
public Result<Object> lookLog(@CurrentUser UserBean userBean, @ApiParam("文件ID") @PathVariable Integer fileId){ public Result<Object> lookLog(@CurrentUser UserBean userBean,@ApiParam("文件ID") @RequestParam(required = true) Integer fileId,
@ApiParam("默认不传,我收到的列表查看传type=1") @RequestParam(required = false) Integer type){
DiskFiles diskFiles = DiskFiles.builder().id(fileId).build().selectById(); DiskFiles diskFiles = DiskFiles.builder().id(fileId).build().selectById();
DiskFilesLog diskFilesLog = DiskFilesLog.builder().build(); DiskFilesLog diskFilesLog = DiskFilesLog.builder().build();
if(StringUtils.isEmpty(diskFiles)){
throw new CustomException("查看失败,文件不存在");
}
if(diskFiles.getDeleteFlag() == 1 && StringUtils.isEmpty(type)){
throw new CustomException("查看失败,该文件已删除");
}
//新增 文件浏览记录 //新增 文件浏览记录
diskFilesLog.setFilePath(diskFiles.getUrlPath()); diskFilesLog.setFilePath(diskFiles.getUrlPath());
diskFilesLog.setFilesId(diskFiles.getId()); diskFilesLog.setFilesId(diskFiles.getId());
...@@ -301,4 +309,19 @@ public class DiskFilesController { ...@@ -301,4 +309,19 @@ public class DiskFilesController {
return ResultUtil.success(); return ResultUtil.success();
} }
@ApiOperation(value = "查询文件是否存在", httpMethod = "GET", notes = "查询文件是否存在")
@GetMapping(value = "/query_file_isExist")
public Result<Object> queryFileIsExist(@CurrentUser UserBean userBean,@ApiParam("文件ID") @RequestParam(required = true) Integer fileId,
@ApiParam("默认不传,我收到的列表查询传type=1") @RequestParam(required = false) Integer type){
DiskFiles diskFiles = DiskFiles.builder().id(fileId).build().selectById();
DiskFilesLog diskFilesLog = DiskFilesLog.builder().build();
if(StringUtils.isEmpty(diskFiles)){
throw new CustomException("文件不存在");
}
if(diskFiles.getDeleteFlag() == 1 && StringUtils.isEmpty(type)){
throw new CustomException("该文件已删除");
}
return ResultUtil.success();
}
} }
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