123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace app\company\controller;
- use app\common\controller\Apic;
- use think\Db;
- /**
- * 操作规范
- */
- class Caozuoguifan extends Apic
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['info'];
- protected $table = 'caozuoguifan';
- public function index(){
- $type_id = input('type_id',0);
- $where = [];
- if($type_id){
- $where['type_id'] = $type_id;
- }
- $list = Db::name($this->table)->field('content',true)->where('company_id',$this->auth->company_id)->where($where)->order('id desc')->paginate();
- $total = $list->total();
- $list = $list->items();
- $list = list_domain_image($list,['image','videofile']);
- $rs = [
- 'list' => $list,
- 'total'=> $total,
- ];
- $this->success(1,$rs);
- }
- public function add(){
- $data = [
- 'company_id' => $this->auth->company_id,
- 'title' => input('title',''),
- 'type_id' => input('type_id',0),
- 'image' => input('image',''),
- 'content' => input('content','','htmlspecialchars_decode'),
- 'videofile' => input('videofile',''),
- 'createtime' => time(),
- 'updatetime' => time(),
- ];
- Db::name($this->table)->insertGetId($data);
- $this->success();
- }
- public function info(){
- $id = input('id',0);
- $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
- $info = info_domain_image($info,['image','videofile']);
- $this->success(1,$info);
- }
- public function edit(){
- $id = input('id',0);
- $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->find();
- if(empty($info)){
- $this->error('没找到该信息,请刷新重试');
- }
- $data = [
- 'title' => input('title',''),
- 'type_id' => input('type_id',0),
- 'image' => input('image',''),
- 'content' => input('content','','htmlspecialchars_decode'),
- 'videofile' => input('videofile',''),
- 'updatetime' => time(),
- ];
- Db::name($this->table)->where('id',$id)->update($data);
- $this->success();
- }
- public function del(){
- $ids = input('ids','');
- $ids = explode(',',$ids);
- if (empty($ids)) {
- $this->error();
- }
- Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->delete();
- $this->success();
- }
- }
|