生成crud增加数据验证

This commit is contained in:
liaofei 2023-04-20 12:18:33 +08:00
parent 2402d0f796
commit 95f361def9
4 changed files with 7 additions and 2 deletions

View File

@ -536,6 +536,7 @@ class SystemCrudServices extends BaseServices
$controller = app()->make(Controller::class);
$controller->setFilePathName($filePath['controller'] ?? '')->setbasePath($basePath)->handle($tableName, [
'usePath' => $service->getUsePath(),
'validateName' => '\\' . $validate->getUsePath() . '::class',
'field' => array_column($options['fromField'], 'field'),
]);
//生成路由

View File

@ -53,8 +53,8 @@ class Controller extends Make
{
$path = $options['path'] ?? '';
$contentPhp = '';
$var = ["{%date%}"];
$fieldPhp = [$this->value['date']];
$var = ["{%date%}", '{%validateName%}'];
$fieldPhp = [$this->value['date'], $options['validateName'] ?? ''];
$action = $options['action'] ?? [];
$field = $options['field'] ?? [];

View File

@ -9,6 +9,8 @@
{%field-php%}
]);
validate({%validateName%})->check($data);
$this->service->crudSave($data);
return app('json')->success(100021);

View File

@ -14,6 +14,8 @@
{%field-php%}
]);
validate({%validateName%})->check($data);
$this->service->crudUpdate((int)$id, $data);
return app('json')->success(100001);