request = app('request'); $this->initialize(); } public function __z6uxyJQ4xYa5ee1mx5() { return true; } protected function initialize() { } public function checkAuthDecrypt() { return $this->success(); } public function getAuth() { $res = [ 'status' => 200, 'msg' => 'ok', 'data' => ['day' => 3666666, 'status' => -1], ]; return $res; } public function success($msg = [], $data = []) { if (is_array($msg)) { $res = [ 'status' => 200, 'msg' => 'ok', 'data' => $msg, ]; } else { if ($data) { $res = [ 'status' => 200, 'msg' => $msg, 'data' => $data, ]; } else { $res = [ 'status' => 200, 'msg' => $msg, 'data' => [], ]; } } return $res; } public function fail($msg = '', $data = []) { $res = [ 'status' => 400, 'msg' => $msg, 'data' => $data, ]; return $res; } /** * 验证数据 * @access protected * @param array $data 数据 * @param string|array $validate 验证器名或者验证规则数组 * @param string|array $message 验证场景或者提示信息 * @param bool $batch 是否批量验证 * @return array|string|true * @throws ValidateException */ final protected function validate(array $data, $validate, $message = null, bool $batch = false) { if (is_array($validate)) { $v = new Validate(); $v->rule($validate); } else { if (strpos($validate, '.')) { // 支持场景 list($validate, $scene) = explode('.', $validate); } $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); $v = new $class(); if (!empty($scene)) { $v->scene($scene); } if (is_string($message) && empty($scene)) { $v->scene($message); } } if (is_array($message)) $v->message($message); // 是否批量验证 if ($batch) { $v->batch(true); } return $v->failException(true)->check($data); } }