feat: 完善curd生成控制器时,自动开启关联查询配置

This commit is contained in:
augushong
2025-03-22 17:58:24 +08:00
parent 103998d8ba
commit 4adcc39eda
3 changed files with 14 additions and 0 deletions

View File

@@ -1092,6 +1092,8 @@ class BuildCurdServiceBase
protected function renderController()
{
$controllerFile = "{$this->rootDir}app{$this->DS}admin{$this->DS}controller{$this->DS}{$this->controllerFilename}.php";
$relationSearch = '';
if (empty($this->relationArray)) {
$controllerIndexMethod = '';
$controllerExportMethod = '';
@@ -1116,6 +1118,10 @@ class BuildCurdServiceBase
'relationIndexMethod' => trim($relationCode),
]
);
$relationSearch = $this->replaceTemplate(
$this->getTemplate("controller{$this->DS}relationSearch")
);
}
$selectList = '';
@@ -1137,6 +1143,7 @@ class BuildCurdServiceBase
'indexMethod' => $controllerIndexMethod,
'exportMethod' => $controllerExportMethod,
'selectList' => $selectList,
'relationSearch' => $relationSearch,
]
);
$this->fileList[$controllerFile] = $controllerValue;

View File

@@ -13,6 +13,8 @@ use think\App;
class {{controllerName}} extends AdminController
{
{{relationSearch}}
use \app\admin\traits\Curd;
public function __construct(App $app)

View File

@@ -0,0 +1,5 @@
/**
* 是否关联查询.
* @var bool
*/
protected $relationSearch = true;