123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <?php
- namespace app\admin\controller\template;
- use app\admin\model\template\TemplateModel;
- use app\admin\service\template\TemplateService;
- use app\common\controller\Backend;
- use think\Db;
- use think\Exception;
- use think\exception\PDOException;
- use think\exception\ValidateException;
- use think\Session;
- /**
- * 私有模板
- * @icon fa fa-circle-o
- */
- class PrivateTmp extends Backend
- {
- protected $model = null;
- protected $service = null;
- protected $noNeedRight = ['parentindex','childindex'];
- /**
- * 快速搜索时执行查找的字段
- */
- protected $searchFields = ['title'];
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new TemplateModel();
- $this->service = new TemplateService();
- }
- /**
- * 模板列表
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- return $this->view->fetch();
- }
- /**
- * 父级列表
- * @return string|\think\response\Json
- * @throws \think\Exception
- * @author matielong
- */
- public function parentIndex()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax()) {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $my_where = [
- 'is_public' => 2,
- 'parent_id' => 0
- ];
- $total = $this->model
- ->where($where)
- ->where($my_where)
- ->order($sort, $order)
- ->count();
- $list = $this->model
- ->where($where)
- ->where($my_where)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $list = collection($list)->toArray();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 子级列表
- * @return string|\think\response\Json
- * @throws Exception
- * @author matielong
- */
- public function childIndex()
- {
- $pid = $this->request->param('pid');
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax()) {
- list($where, $sort, $order, $offset, $limit) = $this->buildparams($this->searchFields, true);
- $my_where = [
- 'is_public' => 2,
- 'parent_id' => $pid
- ];
- $total = $this->model->alias('tmp')
- ->where($where)
- ->where($my_where)
- ->order($sort, $order)
- ->count();
- $list = $this->model->alias('tmp')
- ->where($where)
- ->where($my_where)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $list = collection($list)->toArray();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- }
|