attachment.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * 附件管理
  3. * @see https://api.halo.run/admin-api.html#tag/attachment-controller
  4. */
  5. import HttpHandler from '@/common/http/request.js'
  6. export default {
  7. /**
  8. * 分页获取附件列表
  9. * {
  10. * "attachmentType": "ALIOSS" "BAIDUBOS" "HUAWEIOBS" "LOCAL" "MINIO" "QINIUOSS" "SMMS" "TENCENTCOS" "UPOSS",
  11. * "keyword": "string"
  12. * "mediaType": "string"
  13. * "page": "string"
  14. * "size": "string"
  15. * "sort": "string"
  16. * }
  17. */
  18. getAttachmentsByPage: (params) => {
  19. return HttpHandler.Get('/api/admin/attachments', params, {})
  20. },
  21. /**
  22. * 获取所有的附件类型
  23. */
  24. getAttachmentsMediaTypes: () => {
  25. return HttpHandler.Get('/api/admin/attachments/media_types')
  26. },
  27. /**
  28. * 根据附件类型获取所有的附件列表
  29. */
  30. getAttachmentsTypes: () => {
  31. return HttpHandler.Get('/api/admin/attachments/types')
  32. },
  33. /**
  34. * 根据附件Id获取附件详情
  35. */
  36. getAttachmentsById: (attachmentId) => {
  37. return HttpHandler.Get(`/api/admin/attachments/${attachmentId}`)
  38. },
  39. /**
  40. * 上传附件-单文件(file)
  41. * {
  42. * file:文件对象
  43. * }
  44. */
  45. uploadAttachment: (data) => {
  46. return HttpHandler.Upload(`/api/admin/attachments/upload`, data)
  47. },
  48. /**
  49. * 上传附件-多文件(files)
  50. * {
  51. * files:文件对象集合
  52. * }
  53. */
  54. uploadAttachments: (data) => {
  55. return HttpHandler.Upload(`/api/admin/attachments/uploads`, data)
  56. },
  57. /**
  58. * 修改一个附件信息
  59. */
  60. updateAttachmentById: (attachmentId, name) => {
  61. return HttpHandler.Put(`/api/admin/attachments/${attachmentId}`, {
  62. name: name
  63. })
  64. },
  65. /**
  66. * 批量删除附件(id集合)
  67. */
  68. deleteAttachmentByIds: (attachmentIds = []) => {
  69. return HttpHandler.Delete(`/api/admin/attachments`, attachmentIds)
  70. },
  71. /**
  72. * 删除单个附件
  73. */
  74. deleteAttachmentById: (attachmentId) => {
  75. return HttpHandler.Delete(`/api/admin/attachments/${attachmentId}`)
  76. },
  77. }