131 lines
4.3 KiB
PHP
131 lines
4.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
namespace App\System\Controller\DataCenter;
|
|
|
|
use App\System\Request\SystemNoticeRequest;
|
|
use App\System\Service\SystemNoticeService;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\HttpServer\Annotation\Controller;
|
|
use Hyperf\HttpServer\Annotation\DeleteMapping;
|
|
use Hyperf\HttpServer\Annotation\GetMapping;
|
|
use Hyperf\HttpServer\Annotation\PostMapping;
|
|
use Hyperf\HttpServer\Annotation\PutMapping;
|
|
use Builder\Annotation\Auth;
|
|
use Builder\Annotation\OperationLog;
|
|
use Builder\Annotation\Permission;
|
|
use Builder\MineController;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
/**
|
|
* 通知管理控制器
|
|
* Class NoticeController
|
|
*/
|
|
#[Controller(prefix: "system/notice"), Auth]
|
|
class NoticeController extends MineController
|
|
{
|
|
#[Inject]
|
|
protected SystemNoticeService $service;
|
|
|
|
/**
|
|
* 列表
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[GetMapping("index"), Permission("system:notice, system:notice: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:notice:recycle")]
|
|
public function recycle(): ResponseInterface
|
|
{
|
|
return $this->success($this->service->getPageListByRecycle($this->request->all()));
|
|
}
|
|
|
|
/**
|
|
* 新增
|
|
* @param SystemNoticeRequest $request
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
* @throws \Throwable
|
|
*/
|
|
#[PostMapping("save"), Permission("system:notice:save"), OperationLog]
|
|
public function save(SystemNoticeRequest $request): ResponseInterface
|
|
{
|
|
return $this->success(['id' => $this->service->save($request->all())]);
|
|
}
|
|
|
|
/**
|
|
* 读取数据
|
|
* @param int $id
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[GetMapping("read/{id}"), Permission("system:notice:read")]
|
|
public function read(int $id): ResponseInterface
|
|
{
|
|
return $this->success($this->service->read($id));
|
|
}
|
|
|
|
/**
|
|
* 更新
|
|
* @param int $id
|
|
* @param SystemNoticeRequest $request
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[PutMapping("update/{id}"), Permission("system:notice:update"), OperationLog]
|
|
public function update(int $id, SystemNoticeRequest $request): ResponseInterface
|
|
{
|
|
return $this->service->update($id, $request->all()) ? $this->success() : $this->error();
|
|
}
|
|
|
|
/**
|
|
* 单个或批量删除数据到回收站
|
|
* @return ResponseInterface
|
|
* @throws \Psr\Container\ContainerExceptionInterface
|
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
|
*/
|
|
#[DeleteMapping("delete"), Permission("system:notice: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:notice: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:notice:recovery")]
|
|
public function recovery(): ResponseInterface
|
|
{
|
|
return $this->service->recovery((array) $this->request->input('ids', [])) ? $this->success() : $this->error();
|
|
}
|
|
}
|