|
|
@@ -0,0 +1,242 @@
|
|
|
+package cn.reghao.dfs.store.netdisk.controller;
|
|
|
+
|
|
|
+import cn.reghao.dfs.store.netdisk.db.mapper.FileListMapper;
|
|
|
+import cn.reghao.dfs.store.netdisk.model.po.FileListBean;
|
|
|
+import cn.reghao.dfs.store.netdisk.model.po.MenuBean;
|
|
|
+import cn.reghao.dfs.store.netdisk.model.po.TreeJson;
|
|
|
+import cn.reghao.jutil.jdk.db.PageList;
|
|
|
+import cn.reghao.jutil.jdk.result.WebBody;
|
|
|
+import com.thoughtworks.xstream.XStream;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
+import org.springframework.core.io.InputStreamResource;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author reghao
|
|
|
+ * @date 2022-12-26 10:16:28
|
|
|
+ */
|
|
|
+@Api(tags = "网盘接口")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/file")
|
|
|
+public class NetDiskController {
|
|
|
+ private final FileListMapper fileListMapper;
|
|
|
+
|
|
|
+ public NetDiskController(FileListMapper fileListMapper) {
|
|
|
+ this.fileListMapper = fileListMapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("返回文件分类列表列表")
|
|
|
+ @PostMapping(value = "/menu/findList", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String fileMenus() throws IOException {
|
|
|
+ XStream stream=new XStream();
|
|
|
+ stream.alias("menu", MenuBean.class);
|
|
|
+ stream.alias("menus", List.class);
|
|
|
+
|
|
|
+ ClassPathResource resource = new ClassPathResource("menu-user.xml");
|
|
|
+ InputStream input =resource.getInputStream();
|
|
|
+ List<MenuBean> lists=(List<MenuBean>)stream.fromXML(input);
|
|
|
+ return WebBody.success(lists);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("返回列表模式文件列表")
|
|
|
+ @PostMapping(value = "/disk/file/findList", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String fileList() {
|
|
|
+ List<FileListBean> list = fileListMapper.findAll1();
|
|
|
+ PageList<FileListBean> pageList = PageList.pageList(list);
|
|
|
+ return WebBody.success(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("返回卡片模式文件列表")
|
|
|
+ @PostMapping(value = "/disk/file/findListCard", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String findListCard() {
|
|
|
+ List<FileListBean> list = fileListMapper.findAll2();
|
|
|
+ PageList<FileListBean> pageList = PageList.pageList(list);
|
|
|
+ return WebBody.success(pageList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取图片文件的缩略图")
|
|
|
+ @GetMapping(value = "/disk/fileopen/previewThumbnail")
|
|
|
+ public ResponseEntity<InputStreamResource> previewThumbnail() throws FileNotFoundException {
|
|
|
+ InputStream in = new FileInputStream("/home/reghao/Downloads/file/010.jpeg");
|
|
|
+ InputStreamResource inputStreamResource = new InputStreamResource(in);
|
|
|
+
|
|
|
+ HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
+ httpHeaders.set("Pragma", "No-cache");
|
|
|
+ httpHeaders.set("Cache-Control", "no-cache");
|
|
|
+ return ResponseEntity.status(HttpStatus.OK).headers(httpHeaders).contentType(MediaType.IMAGE_JPEG)
|
|
|
+ .body(inputStreamResource);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("检查待上传文件的 MD5")
|
|
|
+ @PostMapping(value = "/disk/fileupload/checkFile", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String checkFile() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("上传文件")
|
|
|
+ @PostMapping(value = "/disk/fileupload/uploadChunk", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String uploadChunk() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("合并上传的文件分片")
|
|
|
+ @PostMapping(value = "/disk/fileupload/mergeChunk", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String mergeChunk() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取文件属性")
|
|
|
+ @PostMapping(value = "/disk/filecommon/findOne", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String findOne() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取 Album 属性")
|
|
|
+ @PostMapping(value = "/disk/filealbum/findOne", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String findOneFileAlbum() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取当前用户的好友列表")
|
|
|
+ @PostMapping(value = "/disk/filecommon/findUserTree", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String findUserTree() {
|
|
|
+ String type = "position";
|
|
|
+ String pid = "3";
|
|
|
+
|
|
|
+ List<TreeJson> trees = new ArrayList<>();
|
|
|
+ if("root".equals(type)){
|
|
|
+ if("0".equals(pid)){
|
|
|
+ TreeJson tree=new TreeJson();
|
|
|
+ tree.setId("1");
|
|
|
+ tree.setLabel("测试部门");
|
|
|
+ tree.setType("org");
|
|
|
+ tree.setDisabled(true);
|
|
|
+ trees.add(tree);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if("org".equals(type)){
|
|
|
+ if("1".equals(pid)){
|
|
|
+ TreeJson tree1=new TreeJson();
|
|
|
+ tree1.setId("2");
|
|
|
+ tree1.setLabel("项目经理");
|
|
|
+ tree1.setType("position");
|
|
|
+ tree1.setDisabled(true);
|
|
|
+ trees.add(tree1);
|
|
|
+
|
|
|
+ TreeJson tree2=new TreeJson();
|
|
|
+ tree2.setId("3");
|
|
|
+ tree2.setLabel("开发人员");
|
|
|
+ tree2.setType("position");
|
|
|
+ tree2.setDisabled(true);
|
|
|
+ trees.add(tree2);
|
|
|
+ }
|
|
|
+ }else if("position".equals(type)){
|
|
|
+ if("2".equals(pid)){
|
|
|
+ TreeJson tree=new TreeJson();
|
|
|
+ tree.setId("1");
|
|
|
+ tree.setLabel("超级管理员");
|
|
|
+ tree.setType("user");
|
|
|
+ tree.setDisabled(false);
|
|
|
+ trees.add(tree);
|
|
|
+
|
|
|
+ }else if("3".equals(pid)){
|
|
|
+ TreeJson tree=new TreeJson();
|
|
|
+ tree.setId("2");
|
|
|
+ tree.setLabel("测试账号");
|
|
|
+ tree.setType("user");
|
|
|
+ tree.setDisabled(false);
|
|
|
+ trees.add(tree);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return WebBody.success(trees);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("分享给好友")
|
|
|
+ @PostMapping(value = "/disk/filecommon/shareFriends", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String shareFriends() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("私密链接分享")
|
|
|
+ @PostMapping(value = "/disk/filecommon/shareSecret", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String shareSecret() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取本人分享的文件列表")
|
|
|
+ @PostMapping(value = "/disk/sharebyself/findList", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String shareBySelf() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取好友分享的文件列表")
|
|
|
+ @PostMapping(value = "/disk/sharebyfriends/findList", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String shareByFriend() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取文件下载信息")
|
|
|
+ @PostMapping(value = "/disk/filedownload/getDownloadInfo", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String getDownloadInfo() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("文件批量下载")
|
|
|
+ @PostMapping(value = "/disk/filedownload/mergeFiles", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String mergeFiles() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取目录列表")
|
|
|
+ @PostMapping(value = "/disk/filecommon/findFolderList", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String findFolderList() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("新建目录")
|
|
|
+ @PostMapping(value = "/disk/filecommon/addFolder", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String addFolder() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("新增文件")
|
|
|
+ @PostMapping(value = "/disk/fileedit/addFile", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String addFile() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("文件重命名")
|
|
|
+ @PostMapping(value = "/disk/filecommon/rename", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String rename() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("回收站文件列表")
|
|
|
+ @PostMapping(value = "/disk/rubbish/findList", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String rubbishList() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("通知列表")
|
|
|
+ @PostMapping(value = "/disk/notice/findList", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+ public String noticeList() {
|
|
|
+ return WebBody.success();
|
|
|
+ }
|
|
|
+}
|