文件查询测试通过
This commit is contained in:
38
API.md
Normal file
38
API.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# API
|
||||||
|
|
||||||
|
###查询文件
|
||||||
|
|
||||||
|
```
|
||||||
|
GET /home/file/findbyname
|
||||||
|
```
|
||||||
|
|
||||||
|
参数
|
||||||
|
|
||||||
|
```
|
||||||
|
fileName: 文件
|
||||||
|
```
|
||||||
|
|
||||||
|
返回
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"code": 0,
|
||||||
|
"msg": "成功",
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"createTime": "2018-06-23 11:46:18",
|
||||||
|
"fileName": "测试Service虚拟文件3",
|
||||||
|
"fileSize": "31kb",
|
||||||
|
"filePath": "/www/Service",
|
||||||
|
"deleteFlag": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"createTime": "2018-06-23 11:43:59",
|
||||||
|
"fileName": "测试Service虚拟文件",
|
||||||
|
"fileSize": "31kb",
|
||||||
|
"filePath": "/www/Service",
|
||||||
|
"deleteFlag": 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
23
src/main/java/top/fjy8018/fileupload/VO/FileInfoVO.java
Normal file
23
src/main/java/top/fjy8018/fileupload/VO/FileInfoVO.java
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package top.fjy8018.fileupload.VO;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回的文件查询对象
|
||||||
|
* @author F嘉阳
|
||||||
|
* @date 2018-06-23 20:59
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FileInfoVO {
|
||||||
|
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
private String fileSize;
|
||||||
|
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
private Integer deleteFlag;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package top.fjy8018.fileupload.controller;
|
||||||
|
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import top.fjy8018.fileupload.VO.FileInfoVO;
|
||||||
|
import top.fjy8018.fileupload.dataobject.es.EsFileInfo;
|
||||||
|
import top.fjy8018.fileupload.service.FileService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author F嘉阳
|
||||||
|
* @date 2018-06-23 20:50
|
||||||
|
*/
|
||||||
|
@RequestMapping("/home/file")
|
||||||
|
@RestController
|
||||||
|
public class FileSearchController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileService fileService;
|
||||||
|
|
||||||
|
@GetMapping("/findbyname")
|
||||||
|
public List<FileInfoVO> searchByFileName(@RequestParam String fileName,
|
||||||
|
@RequestParam(name = "pageNum", required = false, defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(name = "size", required = false, defaultValue = "5") Integer size){
|
||||||
|
|
||||||
|
PageRequest pageRequest = PageRequest.of(page - 1, size);
|
||||||
|
Page<EsFileInfo> productInfoPage = fileService.findByFileName(pageRequest,fileName);
|
||||||
|
List<EsFileInfo> fileInfoList = productInfoPage.getContent();
|
||||||
|
|
||||||
|
List<FileInfoVO> fileInfoVOList = new ArrayList<>();
|
||||||
|
for (EsFileInfo fileInfo: fileInfoList){
|
||||||
|
FileInfoVO fileInfoVO = new FileInfoVO();
|
||||||
|
BeanUtils.copyProperties(fileInfo,fileInfoVO);
|
||||||
|
|
||||||
|
fileInfoVOList.add(fileInfoVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileInfoVOList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@Configuration
|
/*@Configuration*/
|
||||||
public class WebAppConfig implements WebMvcConfigurer {
|
public class WebAppConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user