$code, 'msg' => $msg, 'data' => $data]; $response = \think\Response::create($res, 'json'); throw new \think\exception\HttpResponseException($response); } function url(string $url = '', array $vars = [], $suffix = true, $domain = true) { return \think\facade\Route::buildUrl($url, $vars)->suffix($suffix)->domain($domain); } function rand_str($len = 6) { $str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $res = ''; for ($i = 0; $i < $len; $i++) { $key = rand(0, strlen($str)); $res .= $str[$key]; } return $res; } function array_get($array, $key, $default = null) { return isset($array[$key]) ? $array[$key] : $default; } function str_get($str, $default = null) { return isset($str) ? $str : $default; }