| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- declare(strict_types=1);
- namespace SixShop\Core;
- use SixShop\Core\Exception\LogicException;
- use think\Paginator;
- use think\Response;
- /**
- * 助手类
- * @deprecated 类已弃用, 请使用函数版本的助手方法
- */
- final class Helper
- {
- /**
- * 返回成功数据
- * @deprecated 函数已弃用, 请使用 success_response()
- */
- public static function success_response(mixed $data = [], string $status = 'ok', int $code = 200, string $msg = 'success', string $type = 'json', string $xslt = ''): Response
- {
- return success_response($data, $status, $code, $msg, $type, $xslt);
- }
- /**
- * 返回分页数据
- * @deprecated 函数已弃用, 请使用 page_response()
- */
- public static function page_response(Paginator $page, mixed $data = [], string $status = 'ok', int $code = 200, string $msg = 'success'): Response
- {
- return json([
- 'code' => $code,
- 'status' => $status,
- 'msg' => $msg,
- 'page' => $page,
- 'data' => $data
- ]);
- }
- /**
- * 抛出逻辑异常
- * @throws LogicException
- * @deprecated 函数已弃用, 请使用 throw_logic_exception()
- */
- public static function throw_logic_exception(string $msg = 'error', int $code = 1, string $status = 'error', mixed $data = [], int $httpCode = 200, $header = [], $options = []): void
- {
- throw new LogicException(error_response($msg, $status, $code, $data, $httpCode, $header, $options));
- }
- /**
- * 返回失败数据
- * @deprecated 函数已弃用, 请使用 error_response()
- */
- public static function error_response(string $msg = 'error', string $status = 'error', int $code = 1, mixed $data = [], int $httpCode = 400, $header = [], $options = []): Response
- {
- return json([
- 'code' => $code,
- 'status' => $status,
- 'msg' => $msg,
- 'data' => $data
- ], $httpCode, $header, $options);
- }
- }
|