add:新增catchTable

This commit is contained in:
JaguarJack 2021-03-31 20:20:47 +08:00
parent 2b96f3b650
commit f56cb943ff

View File

@ -0,0 +1,45 @@
<?php
namespace catcher;
use catcher\library\table\Table;
abstract class CatchTable
{
abstract protected function table();
abstract protected function form();
/**
* 渲染
*
* @time 2021年03月29日
* @param $only => form || table
* @return array|\think\response\Json
*/
public function render($only)
{
if ($only) {
return CatchResponse::success([
$only => $this->{$only}()
]);
}
return CatchResponse::success([
'table' => $this->table(),
'form' => $this->form()
]);
}
/**
* 获取表对象
*
* @time 2021年03月30日
* @param string $tableName
* @return Table
*/
protected function getTable(string $tableName): Table
{
return new Table($tableName);
}
}