作者 邓超

1

... ... @@ -7,6 +7,7 @@ use Lib\Err;
use Lib\Mail\Mail;
use Lib\Mail\MailFun;
use Model\folderSql;
use Model\listsSql;
/**
* 文件夹管理
... ... @@ -158,7 +159,54 @@ class Folder extends Base {
* @time 2023/3/3 17:38
*/
public function delete(){
$email = $this->getEmail();
$folder_id = app()->request('folder_id');
$folder = db()->first(folderSql::first(dbWhere(['id'=>$folder_id,'email_id'=>$email['id']])));
if(!$folder){
app()->e('folder_not_fount');
}
// 是否存在下级
if(db()->count(folderSql::first(dbWhere(['pid'=>$folder['pid'],'email_id'=>$email['id']])))){
app()->e('folder_delete_exist_child');
}
// 是否存在邮件
if(db()->count(listsSql::first(dbWhere(['folder_id'=>$folder['id'],'email_id'=>$email['id']])))){
app()->e('folder_delete_exist_mail');
}
// 远程创建
$mail = new Mail(
$email['email'],
base64_decode($email['password']),
$email['imap']
);
if(!$mail->login()){
app()->e('login_error_imap');
}
// 远程创建
$ret = $mail->client->folderDelete($folder['origin_folder']);
if($ret[0] === false){
app()->e($ret[1]);
}
// 插入数据
$row = db()->delete(folderSql::$table,[
'id' => $folder['id']
]);
if(!$row){
app()->e('folder_delete_error');
}
// 返回数据
app()->_json($folder);
}
... ...
... ... @@ -188,8 +188,7 @@ class Home extends Base {
// 开始远程
$mailInstance = new Mail($emails[$eid]['email'],base64_decode($emails[$eid]['password']),$emails[$eid]['imap']);
$mailInstance->login();
if($mailInstance->login()){
$mailInstance->seen(array_column($uid,'uid'),$folder['origin_folder'],$seen);
$mailInstance = null;
... ... @@ -199,6 +198,7 @@ class Home extends Base {
],dbWhere([
'id' => array_column($uid,'id')
]));
}
}
$folder = null;
... ...
... ... @@ -28,6 +28,10 @@ return [
'folder_tree_max_two' => '文件夹最多2级',
'folder_is_exist' => '文件夹已存在',
'folder_create_save_error' => '文件夹新增失败',
'folder_not_fount' => '文件夹不存在',
'folder_delete_exist_child' => '无法删除带有子文件夹的目录',
'folder_delete_exist_mail' => '无法删除存在邮件的目录',
'folder_delete_error' => '文件夹删除失败',
'sync_request_param_error' => '同步请求参数异常',
... ...
... ... @@ -160,6 +160,26 @@ class DbPool {
return 0;
}
/**
* 删除语句
* @param string $table
* @param array $where
* @return int
* @author:dc
* @time 2023/3/17 18:04
*/
public function delete(string $table, array $where){
$sql = "delete from `{$table}` where ".dbUpdate($where);
$query = $this->query($sql);
if($query){
return $query->rowCount();
}
return 0;
}
/**
* 统计数量
... ...