多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
~~~ <?php namespace app\admin\controller; use app\common\controller\AdminBase; use think\Db; use think\Session; class Imgfile extends AdminBase { protected function _initialize() { parent::_initialize(); $file_tag = model('ImgfileTag')->order('sort desc,id asc')->select(); $this->assign('file_tag',$file_tag); } public function index($t_id=1) { return $this->fetch('index',['tag_id' =>$t_id]); //$this->redirect('imgfile/show', ['tag_id' =>1]); //$this->redirect('About/show', ['id' =>$id,'kid'=>$kid]); } public function home() { // return $this->fetch('index',['tag_id' =>$t_id]); $this->redirect('imgfile/index', ['tag_id' =>1]); //$this->redirect('About/show', ['id' =>$id,'kid'=>$kid]); } public function show($tag_id=1) { $url= $_SERVER['HTTP_HOST']; $file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->select(); $this->assign([ 'file'=>$file, 'root'=>$url, 'tag'=>$tag_id ]); return $this->fetch("show", ['tag_id' =>$tag_id]); } //编辑1-1 public function edit($id) { $apage=Db::table('yp_imgfile')->where('id',$id)->find(); $this->assign('apage',$apage); return $this->fetch(); } //编辑1-2 public function update($id) { $status = 0; $message = "更新失败"; $data = $this->request->param(); $data['create_time'] = time(); if (model('Imgfile')->allowField(true)->save($data, ['id' => $data['id']])) { $status = 1; $message = '更新成功'; } return ['status'=>$status,'message'=>$message]; } //编辑1-3 public function edittag() { return $this->fetch(); } //编辑1-4 public function tag() { $status=1; $data = $this->request->param(); $allid = $data['id']; $ids=''; foreach($allid as $k=>$value){ $ids[$k]=$value; } $num = count($allid); return ['status'=>$status,'ids'=> $ids]; } //编辑1-5 public function updatetag() { $status = 0; $message = "更新失败"; $data = $this->request->param(); $tag_id=$data['tag_id']; $ids=$data['ids']; // halt($ids); if(Db::table('yp_imgfile')->where('id','in',$ids)->setField('tag_id',$tag_id)){ $status = 1; $message = "更新成功"; } return ['status'=>$status,'message'=>$message]; } //删除 public function delete($id) { $message="删除失败"; if(model('Imgfile')->destroy($id)){ $message="已删除"; } return $message; } //批量删除 public function delall() { $status=0; $message="删除失败"; $data = $this->request->param(); $allid = $data['id']; $ids=''; foreach($allid as $k=>$value){ $ids[$k]=$value; } $num = count($allid); if(model('Imgfile')->destroy($ids)){ $status=1; $message="删除成功"; } return ['status'=>$status, 'message'=> $message ,'num'=> $num]; } //选择图片1-1 public function simple($tag_id=1) { $count=model('Imgfile')->where('tag_id',$tag_id)->count(); //$file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->paginate(14,false,['query' => request()->param()]); $file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->select(); $this->assign([ 'file'=>$file, 'count'=>$count ]); return $this->fetch('imgfile/simple', ['tag_id' =>1]); } //选择图片1-1 public function more($tag_id=1) { $count=model('Imgfile')->where('tag_id',$tag_id)->count(); //$file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->paginate(14,false,['query' => request()->param()]); $file = model('Imgfile')->where('tag_id',$tag_id)->order('create_time desc,id desc')->select(); $this->assign([ 'file'=>$file, 'count'=>$count ]); return $this->fetch('imgfile/more', ['tag_id' =>1]); } } ~~~