| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 | 
							- <?php namespace Manage\Api\Page;
 
- use Dever;
 
- use Manage\Lib\Page;
 
- # 操作
 
- class Oper extends Page
 
- {
 
-     public function __construct()
 
-     {
 
-         parent::__construct('oper');
 
-         $this->id = Dever::input('id');
 
-         if (!$this->id) {
 
-             Dever::error('无效数据');
 
-         }
 
-         $this->checkFunc();
 
-     }
 
-     # 更改某个字段的值
 
-     public function up_commit(){}
 
-     public function up()
 
-     {
 
-         $input = Dever::input();
 
-         $field = explode(',', Dever::input('field'));
 
-         foreach ($field as $k => $v) {
 
-             if (isset($input[$v]) && $value = $input[$v]) {
 
-                 if (is_array($value)) {
 
-                     $value = implode(',', $value);
 
-                 }
 
-                 $data[$v] = $value;
 
-             }
 
-         }
 
-         if (isset($this->config['up_start']) && $this->config['up_start']) {
 
-             list($this->id, $data) = Dever::call($this->config['up_start'], array($this->id, $data));
 
-         }
 
-         $where['id'] = array('in', $this->id);
 
-         $state = $this->db->update($where, $data);
 
-         if ($state) {
 
-             if (isset($this->config['up_end']) && $this->config['up_end']) {
 
-                 Dever::call($this->config['up_end'], array($this->id, $data));
 
-             }
 
-             return '操作成功';
 
-         } else {
 
-             Dever::error('操作失败');
 
-         }
 
-     }
 
-     # 删除 删除到回收站
 
-     public function recycle_commit(){}
 
-     public function recycle()
 
-     {
 
-         $where['id'] = array('in', $this->id);
 
-         $data = $this->db->select($where);
 
-         if ($data) {
 
-             foreach ($data as $k => $v) {
 
-                 $insert['table'] = $this->db->config['load'];
 
-                 $insert['table_id'] = $v['id'];
 
-                 $insert['content'] = Dever::json_encode($v);
 
-                 $state = Dever::db('manage/recycler')->insert($insert);
 
-                 if (!$state) {
 
-                     Dever::error('删除失败,请重试');
 
-                 }
 
-                 $state = $this->db->delete($v['id']);
 
-                 if (!$state) {
 
-                     Dever::error('删除失败,请重试');
 
-                 }
 
-             }
 
-         }
 
-         return '操作成功';
 
-     }
 
-     # 从回收站恢复
 
-     public function recover_commit(){}
 
-     public function recover()
 
-     {
 
-         $where['id'] = array('in', $this->id);
 
-         $data = $this->db->select($where);
 
-         if ($data) {
 
-             foreach ($data as $k => $v) {
 
-                 $v['content'] = Dever::json_decode($v['content']);
 
-                 $state = Dever::db($v['table'])->insert($v['content']);
 
-                 if (!$state) {
 
-                     Dever::error('恢复失败,请重试');
 
-                 }
 
-                 $state = $this->db->delete($v['id']);
 
-                 if (!$state) {
 
-                     Dever::error('恢复失败,请重试');
 
-                 }
 
-             }
 
-         }
 
-         return '操作成功';
 
-     }
 
-     # 直接删除
 
-     public function delete_commit(){}
 
-     public function delete()
 
-     {
 
-         $where['id'] = array('in', $this->id);
 
-         $state = $this->db->delete($where);
 
-         if (!$state) {
 
-             Dever::error('删除失败,请重试');
 
-         }
 
-         return '操作成功';
 
-     }
 
- }
 
 
  |