Commit 101dc2bc by xmy

feat:模版生成

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