mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-05 17:42:49 +08:00
调整admin下的类库代码,将主要逻辑调整到extend下
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace {{controllerNamespace}};
|
||||
|
||||
use app\common\controller\AdminController;
|
||||
use app\admin\service\annotation\ControllerAnnotation;
|
||||
use app\admin\service\annotation\NodeAnotation;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* @ControllerAnnotation(title="{{controllerAnnotation}}")
|
||||
*/
|
||||
class {{controllerName}} extends AdminController
|
||||
{
|
||||
|
||||
use \app\admin\traits\Curd;
|
||||
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new {{modelFilename}}();
|
||||
{{selectList}}
|
||||
}
|
||||
|
||||
{{indexMethod}}
|
||||
|
||||
|
||||
{{exportMethod}}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="导出")
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
list($page, $limit, $where) = $this->buildTableParames();
|
||||
|
||||
|
||||
$this->model = $this->model{{relationIndexMethod}};
|
||||
|
||||
$fields = $this->request->param('fields', '{}', null);
|
||||
$image_fields = $this->request->param('image_fields', '{}', null);
|
||||
$select_fields = $this->request->param('select_fields', '{}', null);
|
||||
$date_fields = $this->request->param('date_fields', '{}', null);
|
||||
|
||||
$fields = json_decode($fields, true);
|
||||
$image_fields = json_decode($image_fields, true);
|
||||
$select_fields = json_decode($select_fields, true);
|
||||
$date_fields = json_decode($date_fields, true);
|
||||
|
||||
$content = \app\common\tools\ExportTools::excel($this->model, $where, $fields, $image_fields, $select_fields, $date_fields);
|
||||
|
||||
$export_file_name = $this->exportFileName;
|
||||
|
||||
if (empty($export_file_name)) {
|
||||
$export_file_name = $this->model->getName();
|
||||
}
|
||||
|
||||
return download($content, $export_file_name . date('YmdHis') . '.xlsx', true);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
/**
|
||||
* @NodeAnotation(title="列表")
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
if (input('selectFields')) {
|
||||
return $this->selectList();
|
||||
}
|
||||
list($page, $limit, $where) = $this->buildTableParames();
|
||||
$count = $this->model
|
||||
{{relationIndexMethod}}
|
||||
->where($where)
|
||||
->count();
|
||||
$list = $this->model
|
||||
{{relationIndexMethod}}
|
||||
->where($where)
|
||||
->page($page, $limit)
|
||||
->order($this->sort)
|
||||
->select();
|
||||
$data = [
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
'count' => $count,
|
||||
'data' => $list,
|
||||
];
|
||||
return json($data);
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
$this->assign('{{var_name}}', $this->model::{{name}}, true);
|
||||
Reference in New Issue
Block a user