file.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // 文件模块相关接口
  2. import { get, post } from './http'
  3. /**
  4. * 以登录接口为例
  5. * export const login = p => get('/user/login', p);
  6. *
  7. * login ---------- 接口名称
  8. * p -------------- 传参,若需要在url中拼接其他信息,传参可以改为(p, other)
  9. * get ------------ 接口调用的方法,来自 http.js 中封装好的四个axios方法 get/post/put/axiosDelete
  10. * '/user/login' -- 接口url,若需要在url中拼接其他信息:
  11. * 首先需要在传参处改为(p, other1, other2)
  12. * 然后将url改为`/user/${other1}/login/${other2}`
  13. * p -------------- 传递给 get/post/put/axiosDelete 中的查询参数/请求体
  14. *
  15. *
  16. *
  17. * 除此之外,POST 请求支持请求体格式为 FormData,那么就需要多传递一个参数,true,如下示例:
  18. * export const example = p => post('/test/example', p, true);
  19. */
  20. /**
  21. * 获取文件列表相关接口
  22. */
  23. // 获取文件列表(区分文件路径)
  24. export const getFileListByPath = (p) => get('/file/getfilelist', p)
  25. // 获取文件列表(区分文件类型)
  26. export const getFileListByType = (p) => get('/file/selectfilebyfiletype', p)
  27. // 获取回收站文件列表
  28. export const getRecoveryFile = (p) => post('/recoveryfile/list', p)
  29. // 获取我已分享的文件列表
  30. export const getMyShareFileList = (p) => get('/share/shareList', p)
  31. // 获取存储占用
  32. export const getStorage = (p) => get('/filetransfer/getstorage', p)
  33. // 获取文件目录树
  34. export const getFoldTree = (p) => get('/file/getfiletree', p)
  35. /**
  36. * 单文件操作相关接口
  37. */
  38. // 创建文件
  39. export const createFold = (p) => post('/file/createfile', p)
  40. // 删除文件
  41. export const deleteFile = (p) => post('/file/deletefile', p)
  42. // 复制文件
  43. export const copyFile = (p) => post('/file/copyfile', p)
  44. // 移动文件
  45. export const moveFile = (p) => post('/file/movefile', p)
  46. // 重命名文件
  47. export const renameFile = (p) => post('/file/renamefile', p)
  48. // 解压文件
  49. export const unzipFile = (p) => post('/file/unzipfile', p)
  50. // 全局搜索文件
  51. export const searchFile = (p) => get('/file/search', p)
  52. // 分享文件
  53. export const shareFile = (p) => post('/share/sharefile', p)
  54. // 校验分享链接过期时间
  55. export const checkShareLinkEndtime = (p) => get('/share/checkendtime', p)
  56. // 校验分享链接是否需要提取码
  57. export const checkShareLinkType = (p) => get('/share/sharetype', p)
  58. // 校验分享链接提取码是否正确
  59. export const checkShareLinkCode = (p) => get('/share/checkextractioncode', p)
  60. // 获取分享文件列表
  61. export const getShareFileList = (p) => get('/share/sharefileList', p)
  62. // 保存分享文件
  63. export const saveShareFile = (p) => post('/share/savesharefile', p)
  64. /**
  65. * 文件批量操作相关接口
  66. */
  67. // 批量删除文件
  68. export const batchDeleteFile = (p) => post('/file/batchdeletefile', p)
  69. // 批量移动文件
  70. export const batchMoveFile = (p) => post('/file/batchmovefile', p)
  71. /**
  72. * 回收站文件操作相关接口
  73. */
  74. // 回收站文件删除
  75. export const deleteRecoveryFile = (p) =>
  76. post('/recoveryfile/deleterecoveryfile', p)
  77. // 回收站文件还原
  78. export const restoreRecoveryFile = (p) => post('/recoveryfile/restorefile', p)
  79. // 回收站文件批量删除
  80. export const batchDeleteRecoveryFile = (p) =>
  81. post('/recoveryfile/batchdelete', p)
  82. /**
  83. * 文件公共接口
  84. */
  85. // 文件预览
  86. export const getFilePreview = (p) => get('/filetransfer/preview', p)