Attachment.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\adminapi\attachment;
  12. use app\extra\basic\Base;
  13. use app\extra\service\system\SystemAttachmentService;
  14. use app\middleware\AuthMiddleware;
  15. use DI\Attribute\Inject;
  16. use LinFly\Annotation\Route\Controller;
  17. use LinFly\Annotation\Route\Middleware;
  18. use LinFly\Annotation\Route\Route;
  19. use support\Request;
  20. /**
  21. * 图片管理类
  22. * Class SystemAttachment
  23. */
  24. #[Controller(prefix: "/adminapi/file/"),Middleware(AuthMiddleware::class)]
  25. class Attachment extends Base
  26. {
  27. /**
  28. * @var SystemAttachmentService
  29. */
  30. #[Inject]
  31. protected SystemAttachmentService $service;
  32. /**
  33. * 显示列表
  34. * @return mixed
  35. */
  36. #[Route(path: "",methods: "get")]
  37. public function index(Request $request)
  38. {
  39. $param = $request->get();
  40. return $this->success($this->service->getImageList($param));
  41. }
  42. /**
  43. * 删除指定资源
  44. *
  45. * @param string $ids
  46. */
  47. #[Route(path: "delete",methods: "delete")]
  48. public function delete(Request $request)
  49. {
  50. $ids = $request->post('ids');
  51. $this->service->del($ids);
  52. return $this->success('删除成功');
  53. }
  54. /**
  55. * 移动图片
  56. * @return mixed
  57. */
  58. #[Route(path: "do_move",methods: "put")]
  59. public function moveImageCate(Request $request)
  60. {
  61. $data = $request->get();
  62. $this->service->move($data);
  63. return $this->success('移动成功');
  64. }
  65. // /**
  66. // * 修改文件名
  67. // * @param $id
  68. // * @return mixed
  69. // */
  70. // public function update($id)
  71. // {
  72. // $realName = $this->request->post('real_name', '');
  73. // if (!$realName) {
  74. // return $this->fail('文件名称不能为空');
  75. // }
  76. // $this->service->update($id, ['real_name' => $realName]);
  77. // return $this->success('修改成功');
  78. // }
  79. //
  80. // /**
  81. // * 获取上传类型
  82. // * @return mixed
  83. // */
  84. // public function uploadType()
  85. // {
  86. // $data['upload_type'] = (string)sys_config('upload_type', 1);
  87. // return app('json')->success($data);
  88. // }
  89. }