<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                1.驗證器中BaseValidate.php ~~~ <?php namespace app\api\validate; use app\lib\exception\ParameterException; use think\Exception; use think\Request; use think\Validate; class BaseValidate extends Validate { public function goCheck() { // 獲取http傳入的參數 // 對這些參數做檢驗 $request = Request::instance(); $params = $request->param(); $result = $this->batch()->check($params); if(!$result){ $e =new ParameterException(); $e->msg=$this->error; throw $e; //$error = $this->error; //throw new Exception($error); } else{ return true; } } } ~~~ 2.BaseException.php文件 ~~~ <?php namespace app\lib\exception; use think\Exception; /** * Class BaseException * 自定義異常類的基類 */ class BaseException extends Exception { public $code = 400; //public $msg = 'invalid parameters'; public $msg = '參數錯誤'; public $errorCode = 999; /** * 構造函數,接收一個關聯數組 * @param array $params 關聯數組只應包含code、msg和errorCode,且不應該是空值 */ public function __construct($params=[]) { if(!is_array($params)){ return; } if(array_key_exists('code',$params)){ $this->code = $params['code']; } if(array_key_exists('msg',$params)){ $this->msg = $params['msg']; } if(array_key_exists('errorCode',$params)){ $this->errorCode = $params['errorCode']; } } } ~~~ 驗證器IDMustBePostiveInt.php中 ~~~ <?php namespace app\api\validate; use think\Validate; class IDMustBePostiveInt extends BaseValidate { protected $rule = [ 'id' => 'require|isPositiveInteger', 'num'=>'in:1,2,3' ]; protected function isPositiveInteger($value, $rule = '', $data = '', $field = '') { if (is_numeric($value) && is_int($value + 0) && ($value + 0) > 0) { return true; } else{ return $field.'必須是正整數'; } } } ~~~ ![](https://box.kancloud.cn/8af1f2422de4ba88499e0b079b1680bf_1357x605.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看