生成代码新增回滚功能
This commit is contained in:
@@ -18,11 +18,9 @@ class Controller extends Factory
|
||||
public function done($params)
|
||||
{
|
||||
// 写入成功之后
|
||||
if (file_put_contents($this->getGeneratePath($params['controller']), $this->getContent($params))) {
|
||||
return (new Route())->controller($params['controller'])
|
||||
->restful($params['restful'])
|
||||
->methods($this->parseOtherMethods($params['other_function']))
|
||||
->done();
|
||||
$controllerPath = $this->getGeneratePath($params['controller']);
|
||||
if (file_put_contents($controllerPath, $this->getContent($params))) {
|
||||
return $controllerPath;
|
||||
}
|
||||
|
||||
throw new FailedException($params['controller'] . ' generate failed~');
|
||||
|
@@ -89,7 +89,7 @@ abstract class Factory
|
||||
* @param $table
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasTableExists($table)
|
||||
public function hasTableExists($table)
|
||||
{
|
||||
$tables = Db::getConnection()->getTables();
|
||||
|
||||
|
@@ -48,6 +48,6 @@ class Migration extends Factory
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return $file;
|
||||
}
|
||||
}
|
@@ -12,13 +12,15 @@ class Model extends Factory
|
||||
{
|
||||
$content = $this->getContent($params);
|
||||
|
||||
file_put_contents($this->getGeneratePath($params['model']), $content);
|
||||
$modelPath = $this->getGeneratePath($params['model']);
|
||||
|
||||
if (!file_exists($this->getGeneratePath($params['model']))) {
|
||||
file_put_contents($modelPath, $content);
|
||||
|
||||
if (!file_exists($modelPath)) {
|
||||
throw new FailedException('create model failed');
|
||||
}
|
||||
|
||||
return true;
|
||||
return $modelPath;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,7 +19,7 @@ class SQL extends Factory
|
||||
throw new FailedException(sprintf('create table [%s] failed', $params['table']));
|
||||
}
|
||||
|
||||
return true;
|
||||
return $params['table'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user