Home.php
1.5 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
<?php
namespace Controller\v2;
use Controller\Base;
use Lib\Mail\Mail;
use Lib\Mail\MailFun;
use Lib\UploadFile;
use Lib\Verify;
use Model\bodySql;
use Model\emailSql;
use Model\folderSql;
use Model\listsSql;
use Model\sendJobsSql;
/**
 * @author:dc
 * @time 2023/2/13 11:28
 * Class Home
 * @package Controller
 */
class Home extends Base {
    /**
     * 邮件列表 针对aicc应用那边
     * @author:dc
     * @time 2023/2/17 14:12
     */
    public function lists(){
        $limit   =   app()->request('limit',20,['intval','abs']);
        $last_id   =   app()->request('last_id',0,['intval','abs']);
        $folder_ids   =   app()->request('folder_ids',[],['intval','abs']);
        $where = ['email_id'    =>  $this->getEmail('id')];
        // 默认查询 inbox
        if(!is_array($folder_ids)){
            $folder_ids = db()->value(
                sprintf(
                    "select `id` from `%s` where `email_id` = %d and `origin_folder` = 'INBOX'",
                    folderSql::$table
                    ,$where['email_id']
                )
            );
        }
        //目录
        $where['folder_id'] = $folder_ids;
        $lists = db()->all(
            sprintf(
                "select `id`,`subject`,`seen`,`udate` from `%s` where `id` > %d %s order by `id` asc limit %d"
                ,listsSql::$table
                ,$last_id
                ,dbWhere($where)
                ,$limit
            )
        );
        app()->_json($lists);
    }
}