$code, 'message' => $msg, 'data' => $data ]; throw new \think\exception\HttpResponseException(json($json)); return; } public static function success($data = [], $msg = '') { if(is_array($data)){ $data = array_change_line_to_hump($data); } $json = [ 'code' => 0, 'message' => $msg, 'data' => $data ]; throw new \think\exception\HttpResponseException(json($json)); return; } public static function error($msg, $code = 1, $data = []) { $code = $code == 0 ? 1 : $code; // code不能等于0 if(is_array($data)){ $data = array_change_line_to_hump($data); } $json = [ 'code' => $code, 'message' => $msg, 'data' => $data ]; throw new \think\exception\HttpResponseException(json($json)); return; } }