作者 邓超

1

@@ -365,6 +365,12 @@ class Home extends Base { @@ -365,6 +365,12 @@ class Home extends Base {
365 if(empty($to_folder)){ 365 if(empty($to_folder)){
366 app()->e('folder_move_error'); 366 app()->e('folder_move_error');
367 } 367 }
  368 + if($to_folder == '草稿箱'){
  369 + app()->e('folder_move_to_draft_error');
  370 + }
  371 + if($to_folder == '发件箱'){
  372 + app()->e('folder_move_to_send_error');
  373 + }
368 374
369 $data = db()->all(listsSql::first(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')]),'`id`,`uid`,`email_id`,`folder_id`')); 375 $data = db()->all(listsSql::first(dbWhere(['id'=>$mail_ids,'email_id'=>array_column($emails,'id')]),'`id`,`uid`,`email_id`,`folder_id`'));
370 if($data){ 376 if($data){
@@ -372,6 +378,18 @@ class Home extends Base { @@ -372,6 +378,18 @@ class Home extends Base {
372 $emails = array_column($emails,null,'id'); 378 $emails = array_column($emails,null,'id');
373 $uids = []; 379 $uids = [];
374 foreach ($data as $datum){ 380 foreach ($data as $datum){
  381 + // 只有草稿箱才没有uid
  382 + if(!$datum['uid']){
  383 + // 删除
  384 + if ($to_folder == '回收站'){
  385 + // 删除数据,真实删除
  386 + db()->delete(listsSql::$table,[
  387 + 'id' => $datum['id']
  388 + ]);
  389 + continue;
  390 + }
  391 + }
  392 +
375 if(empty($uids[$datum['email_id']])){ 393 if(empty($uids[$datum['email_id']])){
376 $uids[$datum['email_id']][$datum['folder_id']] = []; 394 $uids[$datum['email_id']][$datum['folder_id']] = [];
377 } 395 }
@@ -88,6 +88,9 @@ return [ @@ -88,6 +88,9 @@ return [
88 88
89 'send_timer_job_error' => '延迟发送失败', 89 'send_timer_job_error' => '延迟发送失败',
90 90
  91 + 'folder_move_to_draft_error' => '无法移动到草稿箱',
  92 + 'folder_move_to_send_error' => '无法移动到发件箱',
  93 +
91 94
92 95
93 96
@@ -183,14 +183,20 @@ class DbPool { @@ -183,14 +183,20 @@ class DbPool {
183 } 183 }
184 184
185 /** 185 /**
186 - * 删除语句 186 + * 删除语句 软删
187 * @param string $table 187 * @param string $table
188 * @param array $where 188 * @param array $where
  189 + * @param null $upFiled
189 * @return int 190 * @return int
190 * @author:dc 191 * @author:dc
191 - * @time 2023/3/17 18:04 192 + * @time 2023/4/11 14:47
192 */ 193 */
193 - public function delete(string $table, array $where){ 194 + public function delete(string $table, array $where,$upFiled=null){
  195 +
  196 + if($upFiled){
  197 + return $this->update($table,[$upFiled === true ? 'deleted_at' : $upFiled =>time()],$where);
  198 + }
  199 +
194 $sql = "delete from `{$table}` where ".dbUpdate($where); 200 $sql = "delete from `{$table}` where ".dbUpdate($where);
195 201
196 $query = $this->query($sql); 202 $query = $this->query($sql);