field('id,pid as parentId,title,createtime') ->where('company_id',$this->auth->company_id) ->where('deletetime',NULL)->order('weigh asc,id asc')->select(); $this->success(1,$lists); } public function add(){ $data = [ 'company_id' => $this->auth->company_id, 'pid' => input('pid',0), 'title' => input('title',''), 'type' => input('type',1), 'info' => input('info',''), 'weigh' => input('weigh',0), 'createtime' => time(), ]; if($data['pid'] == 0){ $data['info'] = ''; $data['type'] = 0; } $id = Db::name($this->table)->insertGetId($data); if($data['weigh'] == 0){ Db::name($this->table)->where('id',$id)->update(['weigh'=>$id]); } $this->success(); } public function info(){ $id = input('id',0); $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find(); $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)->where('deletetime',NULL)->find(); if(empty($info)){ $this->error('没找到该信息,请刷新重试'); } // $data = [ 'title' => input('title',''), 'type' => input('type',1), 'info' => input('info',''), 'weigh' => input('weigh',$id), ]; if($info['pid'] == 0){ $data['info'] = ''; $data['type'] = 0; } Db::name($this->table)->where('id',$id)->update($data); $this->success(); } public function del(){ $ids = input('ids',''); if (empty($ids)) { $this->error(); } Db::name($this->table)->where('id',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]); Db::name($this->table)->where('pid',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]); $this->success(); } }