chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
 
/*
 * $Author :PHPYUN开发团队
 *
 * 官网: http://www.phpyun.com
 *
 * 版权所有 2009-2021 宿迁鑫潮信息技术有限公司,并保留所有权利。
 *
 * 软件声明:未经授权前提下,不得用于商业运营、二次开发以及任何形式的再次发布。
 */
 
class recycle_model extends model
{
 
    /**
     * 获取回收站列表
     * @param $whereData    查询条件
     * @return array|bool|false|string|void
     */
    function getList($whereData)
    {
 
        return $this->select_all('recycle', $whereData);
    }
 
    /**
     * 获取回收站详情
     * @param $whereData    查询条件
     * @param array $data   自定义处理数组
     * @return array|bool|false|string|void
     */
    function getInfo($whereData, $data = array())
    {
 
        if (!empty($whereData)) {
 
            $data['field']  =   empty($data['field']) ? '*' : $data['field'];
 
            $Info           =   $this->select_once('recycle', $whereData, $data['field']);
        }
 
        return $Info;
 
    }
 
    /**
     * 创建回收站
     * @param $data
     * @return mixed
     */
    function addInfo($data)
    {
 
        if (isset($data) && !empty($data)) {
 
            $return['id']       =   $this->insert_into('outside', $data);
            $return['msg']      =   '回收站(ID:' . $return['id'] . ')';
            $return['errcode']  =   $return['id'] ? '9' : '8';
            $return['msg']      =   $return['id'] ? $return['msg'] . '添加成功!' : $return['msg'] . '添加失败!';
 
            return $return;
        }
    }
 
 
    /**
     * @desc    恢复数据,单表恢复
     * @param array $where
     * @return array
     */
    function recoverTb($where = array())
    {
 
        $return =   array(
 
            'errcode'   =>  8,
            'msg'       =>  ''
        );
 
        if (!empty($where)) {
 
            $id         =   $where['id'];
            if (is_array($id)) {
                $ids    =   $id;
            } else {
                $ids    =   @explode(',', $id);
            }
 
            $recycleList    =   $this->getList(array('id' => array('in', pylode(',', $ids))));
 
            if (!empty($recycleList)) {
 
                foreach ($recycleList as $v) {
 
                    $body   =   unserialize($v['body']);
                    $this->insert_into($v['tablename'], $body);
                    $this->delRecycle(array('id' => $v['id']));
                }
 
                $return['errcode']  =                                                                                            9;
                $return['msg']      =   '数据恢复成功!';
            } else {
 
                $return['msg']      =   '请选择有效数据进行恢复!';
            }
        } else {
 
            $return['msg']          =   '参数错误!';
        }
 
        return $return;
    }
 
    /**
     * @desc    恢复数据,一键恢复,通过删除插入的总记录进行查询恢复
     * @param   array $where
     * @return  array
     */
    function recoverByIdent($where = array())
    {
 
        $return =   array(
 
            'errcode'   =>  8,
            'msg'       =>  ''
        );
 
        if (!empty($where)) {
 
            $rLists     =   $this->getList($where);
 
            if (isset($rLists) && !empty($rLists)) {
 
                foreach ($rLists as $v) {
 
                    $body   =   unserialize($v['body']);
                    $this->insert_into($v['tablename'], $body);
 
                    $this->delRecycle(array('id' => $v['id']));
                }
 
                $return['errcode']  =   9;
                $return['msg']      =   '数据恢复成功!';
 
            } else {
 
                $return['msg']      = '请选择有效数据进行恢复!';
            }
        } else {
 
            $return['msg']          =   '参数错误!';
        }
 
        return $return;
    }
 
    /**
     * 删除数据调用
     * @param $whereData 查询条件 istime    是否根据时间删除
     * @return mixed
     */
    function delRecycle($whereData)
    {
        if ($whereData) {
            if (is_array($whereData['id'])) {
 
                $delId  =   $whereData['id'][1];
            } else {
 
                $delId  =   $whereData['id'];
            }
 
            $return['id']   =   $this->delete_all('recycle', $whereData, '', '', '1');
 
            $return['msg']  =   '回收站数据(ID:' . $delId . ')';
 
            $return['errcode']  =   $return['id'] ? '9' : '8';
 
            $return['msg']  =   $return['id'] ? $return['msg'] . '删除成功!' : $return['msg'] . '删除失败!';
        } else {
 
            $return['msg']  =   '请选择您要删除的信息!';
            $return['errcode'] = 8;
        }
 
        return $return;
    }
 
 
}