审查视图

controller/Base.php 1.4 KB
1  
邓超 authored
1 2 3 4 5
<?php

namespace Controller;

1  
邓超 authored
6 7
use Model\emailSql;
1  
邓超 authored
8 9 10 11 12 13 14 15 16
/**
 * 基础控制器,根据需求 可以不继承此类
 * @author:dc
 * @time 2023/2/18 16:34
 * Class Base
 * @package Controller
 */
abstract class Base {
1  
邓超 authored
17 18

    /**
1  
邓超 authored
19
     * 多个邮箱前端提交
1  
邓超 authored
20 21 22 23 24
     * @param string $filed
     * @return mixed|null
     * @throws \Lib\Err
     * @author:dc
     * @time 2023/3/10 15:15
1  
邓超 authored
25
     */
1  
邓超 authored
26 27 28
    protected final function getEmails($filed='*'){
        static $data;
        if(empty($data)){
1  
邓超 authored
29
            $data = db()->all(emailSql::all(dbWhere(['email'=>web_request_emails()])));
1  
邓超 authored
30 31 32
            if(empty($data)){
                app()->e('email_request_required');
            }
1  
邓超 authored
33 34
        }
1  
邓超 authored
35 36 37 38 39
        if($filed == '*'){
            return $data;
        }

        return array_column($data,$filed);
1  
邓超 authored
40
1  
邓超 authored
41
    }
1  
邓超 authored
42
1  
邓超 authored
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
    /**
     * 一个邮箱前端提交
     * @param string $filed
     * @return mixed|string|null
     * @throws \Lib\Err
     * @author:dc
     * @time 2023/3/10 16:07
     */
    protected final function getEmail($filed='*'){
        static $data;
        if(empty($data)){
            $data = db()->first(emailSql::first(web_request_email()));
            if(empty($data)){
                app()->e('email_request_required');
            }
1  
邓超 authored
58 59 60
            if($data['pwd_error']){
                app()->e('imap_password_error',403);
            }
1  
邓超 authored
61 62 63 64 65 66 67 68
        }

        if($filed == '*'){
            return $data;
        }

        return $data[$filed]??'';
    }
1  
邓超 authored
69 70 71


}