90 lines
3.0 KiB
PHP
90 lines
3.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
namespace App\System\Controller\DataCenter;
|
|
|
|
use App\System\Service\SystemUploadFileService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\HttpServer\Annotation\Controller;
|
|
use Hyperf\HttpServer\Annotation\DeleteMapping;
|
|
use Hyperf\HttpServer\Annotation\GetMapping;
|
|
use Hyperf\HttpServer\Annotation\PutMapping;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
use Builder\Annotation\Auth;
|
|
use Builder\Annotation\OperationLog;
|
|
use Builder\Annotation\Permission;
|
|
use Builder\MineController;
|
|
|
|
/**
|
|
* 文件管理控制器
|
|
* Class UploadFileController
|
|
* @package App\System\Controller\DataCenter
|
|
*/
|
|
#[Controller(prefix: "system/attachment"), Auth]
|
|
class AttachmentController extends MineController
|
|
{
|
|
#[Inject]
|
|
protected SystemUploadFileService $service;
|
|
|
|
/**
|
|
* 列表数据
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[GetMapping("index"), Permission("system:attachment, system:attachment:index")]
|
|
public function index(): ResponseInterface
|
|
{
|
|
return $this->success($this->service->getPageList($this->request->all()));
|
|
}
|
|
|
|
/**
|
|
* 回收站列表数据
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[GetMapping("recycle"), Permission("system:attachment:recycle")]
|
|
public function recycle(): ResponseInterface
|
|
{
|
|
return $this->success($this->service->getPageListByRecycle($this->request->all()));
|
|
}
|
|
|
|
/**
|
|
* 单个或批量删除附件
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[DeleteMapping("delete"), Permission("system:attachment:delete")]
|
|
public function delete(): ResponseInterface
|
|
{
|
|
return $this->service->delete((array) $this->request->input('ids', [])) ? $this->success() : $this->error();
|
|
}
|
|
|
|
/**
|
|
* 单个或批量真实删除文件 (清空回收站)
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[DeleteMapping("realDelete"), Permission("system:attachment:realDelete"), OperationLog]
|
|
public function realDelete(): ResponseInterface
|
|
{
|
|
return $this->service->realDelete((array) $this->request->input('ids', [])) ? $this->success() : $this->error();
|
|
}
|
|
|
|
/**
|
|
* 单个或批量恢复在回收站的文件
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[PutMapping("recovery"), Permission("system:attachment:recovery")]
|
|
public function recovery(): ResponseInterface
|
|
{
|
|
return $this->service->recovery((array) $this->request->input('ids', [])) ? $this->success() : $this->error();
|
|
}
|
|
}
|