Home.php
2.0 KB
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
<?php
namespace Controller;
use Lib\Mail\MailFun;
use Model\emailSql;
use Model\listsSql;
use function Swoole\Coroutine\Http\request;
/**
* @author:dc
* @time 2023/2/13 11:28
* Class Home
* @package Controller
*/
class Home extends Base {
/**
* 邮件列表
* @author:dc
* @time 2023/2/17 14:12
*/
public function lists(){
// 分页 页数
$page = app()->request('page',1,'intval');
$page = $page ? $page : 1;
$size = app()->request('size',20,'intval');
$size = $size ? $size : 1;
// 邮件文件夹的id
$folder_id = app()->request('folder_id');
$lists = db()->all(
listsSql::lists(
$this->getEmails('id'),
$page,
$size,
(int) $folder_id
)
);
// 总数
$total = db()->count(
listsSql::listCount(
$this->getEmails('id'),
(int) $folder_id
)
);
app()->_json(listsPage($lists,$total,$page,$size));
}
/**
* 发送邮件
* @author:dc
* @time 2023/2/18 17:32
*/
public function send_mail(){
$ret = MailFun::sendEmail();
if($ret[0]===true) {
app()->_json(['messageId'=>$ret[1]]);
}else {
app()->e($ret[1]);
}
}
/**
* 收到前端的同步请求操作
* @author:dc
* @time 2023/3/10 10:38
*/
public function sync(){
$where['email'] = web_request_emails();
if(empty($where)){
app()->e('sync_request_param_error');
}else{
// 查询id
$ids = db()->all(emailSql::getValues($where));
foreach ($ids as $v){
redis()->rPush('sync_email_lists', $v['id']);
}
// 返回成功的参数值
app()->_json(array_values($where));
}
}
}