You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
814 B
PHP
28 lines
814 B
PHP
<?php
|
|
|
|
namespace App\Lib;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class Rs
|
|
{
|
|
public static function success($data = [], string $message = '成功',int $code = 0, int $httpCode = 200): JsonResponse
|
|
{
|
|
return response()->json([
|
|
'success' => true,
|
|
'message' => $message,
|
|
'code' => $code,
|
|
'data' => $data,
|
|
], $httpCode)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
|
|
}
|
|
public static function error( string $message = '失败', int $code = 400, $data = [], int $httpCode = 200): JsonResponse
|
|
{
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => $message,
|
|
'code' => $code,
|
|
'data' => $data,
|
|
], $httpCode)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
|
|
}
|
|
}
|