hyperf-view/app/System/Controller/DataCenter/DataMaintainController.php

77 lines
2.4 KiB
PHP

<?php
namespace App\System\Controller\DataCenter;
use App\System\Service\DataMaintainService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Builder\Annotation\Auth;
use Builder\Annotation\OperationLog;
use Builder\Annotation\Permission;
use Builder\BaseController;
use Psr\Http\Message\ResponseInterface;
/**
* Class DataMaintainController
* @package App\System\Controller\DataCenter
*/
#[Controller(prefix: "system/dataMaintain"), Auth]
class DataMaintainController extends BaseController
{
#[Inject]
protected DataMaintainService $service;
/**
* 列表
* @return ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[GetMapping("index"), Permission("system:dataMaintain, system:dataMaintain: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("detailed"), Permission("system:dataMaintain:detailed")]
public function detailed(): ResponseInterface
{
return $this->success($this->service->getColumnList($this->request->input('table', null)));
}
/**
* 优化表
* @return ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[PostMapping("optimize"), Permission("system:dataMaintain:optimize"), OperationLog]
public function optimize(): ResponseInterface
{
$tables = $this->request->input('tables', []);
return $this->service->optimize($tables) ? $this->success() : $this->error();
}
/**
* 清理表碎片
* @return ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[PostMapping("fragment"), Permission("system:dataMaintain:fragment"), OperationLog]
public function fragment(): ResponseInterface
{
$tables = $this->request->input('tables', []);
return $this->service->fragment($tables) ? $this->success() : $this->error();
}
}