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(); } }