增加获取论文正文链接接口

pdf
pan 4 years ago
parent 493605c56c
commit 51a3439939
  1. 1
      doc/db_table.md
  2. 11
      src/main/java/com/bupt/note/Controller/FileController.java
  3. 9
      src/main/java/com/bupt/note/Model/File.java

@ -12,6 +12,7 @@
| ---- | -------- | -------- | ---- |
| id | bigint | primary key; identity | 文件id |
| file_path | varchar | not null | 文件路径 |
| url_path | varchar | not null | 访问路径 |
# 论文 sys_paper

@ -54,6 +54,7 @@ public class FileController {
file.transferTo(txtFile);
com.bupt.note.Model.File f=new com.bupt.note.Model.File();
f.setFilePath(txtFile.getAbsolutePath());
f.setUrlPath("/txt/"+txtFile.getName());
fileRepository.save(f);
return ResponseDataUtil.buildSuccess(f.getId());
} catch (IOException e) {
@ -66,6 +67,16 @@ public class FileController {
}
}
@GetMapping("find/{id}")
public ResponseData get(@PathVariable Long id){
if(fileRepository.existsById(id)){
com.bupt.note.Model.File file= fileRepository.getOne(id);
return ResponseDataUtil.buildSuccess(file.getUrlPath());
}else{
return ResponseDataUtil.buildError();
}
}
/**
* 删除论文文本文件
* @param id 文件id

@ -11,6 +11,7 @@ public class File {
private Long Id;
private String filePath;
private String urlPath;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ -31,4 +32,12 @@ public class File {
this.filePath = filePath;
}
@Column(nullable = false)
public String getUrlPath() {
return urlPath;
}
public void setUrlPath(String urlPath) {
this.urlPath = urlPath;
}
}

Loading…
Cancel
Save