1
This commit is contained in:
28
app/admin/service/curd/templates/controller/controller.code
Normal file
28
app/admin/service/curd/templates/controller/controller.code
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace {{controllerNamespace}};
|
||||
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnnotation;
|
||||
use think\App;
|
||||
|
||||
#[ControllerAnnotation(title: '{{controllerAnnotation}}')]
|
||||
class {{controllerName}} extends AdminController
|
||||
{
|
||||
|
||||
private array $notes;
|
||||
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
self::$model = new {{modelFilename}}();
|
||||
$notes = self::$model::$notes;
|
||||
{{constructRelation}}
|
||||
$this->notes =$notes;
|
||||
$this->assign(compact('notes'));
|
||||
}
|
||||
|
||||
{{indexMethod}}
|
||||
|
||||
}
|
||||
21
app/admin/service/curd/templates/controller/indexMethod.code
Normal file
21
app/admin/service/curd/templates/controller/indexMethod.code
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
#[NodeAnnotation(title: '列表', auth: true)]
|
||||
public function index(\app\Request $request): \think\response\Json|string
|
||||
{
|
||||
if ($request->isAjax()) {
|
||||
if (input('selectFields')) {
|
||||
return $this->selectList();
|
||||
}
|
||||
list($page, $limit, $where) = $this->buildTableParams();
|
||||
$count = self::$model::where($where)->{{relationIndexMethod}}->count();
|
||||
$list = self::$model::where($where)->{{relationIndexMethod}}->page($page, $limit)->order($this->sort)->select()->toArray();
|
||||
$data = [
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
'count' => $count,
|
||||
'data' => $list,
|
||||
];
|
||||
return json($data);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
2
app/admin/service/curd/templates/controller/select.code
Normal file
2
app/admin/service/curd/templates/controller/select.code
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
$this->assign('{{name}}', $this->model->{{name}}());
|
||||
Reference in New Issue
Block a user