Commit 101dc2bc by xmy

feat:模版生成

parent 8caaa4a0
......@@ -28,10 +28,10 @@ class GenData
public function generate($params)
{
list($db, $table, $path, $tplFile, $tplDir) = $params;
$this->generateData($table, $path, $tplFile, $tplDir);
$this->generateData($db, $table, $path, $tplFile, $tplDir);
}
public function generateData($table, $path, $tplFile, $tplDir)
public function generateData($db, $table, $path, $tplFile, $tplDir)
{
$config = [
'tplFilename' => $tplFile,
......@@ -44,19 +44,15 @@ class GenData
$columnSchemas = $this->getColumns($table);
$data = [
'dbName' => $db,
'className' => ucfirst($table),
'tableName' => $table,
'namespace' => "App\\Models\\$tplFile",
'columns' => $columnSchemas
];
$gen = new FileGenerator($config);
$gen->getParser()->setOpenCloseTagChars("{{","}}");
$gen->getParser()->setOpenCloseTagChars("{{", "}}");
$gen->renderas($file, $data);
}
public function generateSave()
{
}
}
......@@ -4,7 +4,6 @@ namespace App\Controllers\Api;
use App\Middlewares\UserMiddleware;
use App\Models\Logic\{{= className}}Logic;
use App\Models\Validate\{{= className}}Validate;
use Hdll\Services\Auth\Enum\AuthEnum;
use Hdll\Services\Common\Bean\Annotation\Auth;
use Hdll\Services\Common\Controller\CommonController;
......@@ -17,7 +16,7 @@ use Swoft\Http\Server\Bean\Annotation\RequestMapping;
use Swoft\Http\Server\Bean\Annotation\RequestMethod;
/**
* @Controller(prefix="/v1/lottery")
* @Controller(prefix="/v1/{{= dbName}}/{{= tableName}}")
* @Auth(scope=AuthEnum::SCOPE_BUYER)
* @Middlewares({
* @Middleware(UserMiddleware::class)
......@@ -40,11 +39,6 @@ class {{= className}}Controller extends CommonController
*/
private $user;
/**
* @Inject()
* @var {{= className}}Validate
*/
private $validate;
/**
* @Auth(scope=AuthEnum::SCOPE_BUYER, option=">=")
......@@ -69,7 +63,6 @@ class {{= className}}Controller extends CommonController
public function save()
{
$param = request()->json();
$this->validate->check($param);
$data = $this->{{= tableName}}->save($this->user->getStoreId(), $param);
return $this->success($data);
}
......@@ -83,7 +76,6 @@ class {{= className}}Controller extends CommonController
public function update()
{
$param = request()->json();
$this->validate->check($param);
$data = $this->{{= tableName}}->update($this->user->getStoreId(), $param);
return $this->success($data);
}
......
......@@ -37,7 +37,7 @@ class {{= className}}Logic
return $data;
}
public function list($storeId, $type, $page, $limit)
public function list($storeId, $page, $limit)
{
$condition['storeId'] = $storeId;
$list = $this->{{= tableName}}->list($condition, ['*'], $page, $limit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment