1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use think\db\Query;
- class Ad extends Backend
- {
- protected $noNeedLogin=['pos'];
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\Ad;
- $this->view->assign('pos',\app\common\model\Ad::$pos);
- }
- public function index()
- {
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- $this->relationSearch=true;
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = $this->model
- ->with(['admin','upload_admin'])
- ->where($where)
- ->where(function (Query $query){
- if($this->admin('is_sub')){
- $query->where('admin_id',$this->auth->id);
- }
- })
- ->order($sort, $order)
- ->paginate($limit);
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- public function import()
- {
- parent::import();
- }
-
- public function pos(){
- return \app\common\model\Ad::$pos;
- }
- public function edit($ids = null)
- {
- $this->check($ids);
- return parent::edit($ids);
- }
- protected function check($ids){
- if($this->admin('is_sub')){
- $check=$this->model->where('id',$ids)->where('upload_admin_id',$this->auth->id)->find();
- if(!$check){
- $this->error('无权操作');
- }
- }
- }
- public function del($ids = "")
- {
- $this->check($ids);
- parent::del($ids);
- }
- }
|