first commit

This commit is contained in:
liu
2026-07-13 15:23:29 +08:00
commit 50885a98c8
473 changed files with 33772 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace App\Exceptions;
use Modules\Common\Enum\ShowType;
use RuntimeException;
class HttpResponseException extends RuntimeException
{
/**
* 响应消息
*/
private string $msg;
/**
* 响应类型
*/
private ShowType $showType;
/**
* 响应数据
*/
private array $data;
/**
* 响应状态
*/
private bool $success;
public function __construct(array $data, int $code = 200)
{
$this->msg = $data['msg'] ?? '';
$this->success = $data['success'] ?? true;
if (empty($data['showType']) && $this->success) {
$this->showType = ShowType::SUCCESS_MESSAGE;
} elseif (empty($data['showType']) && ! $this->success) {
$this->showType = ShowType::ERROR_MESSAGE;
} else {
$this->showType = ShowType::from($data['showType']);
}
$this->data = $data['data'] ?? [];
parent::__construct($data['msg'] ?? '', $code);
}
public function toArray(): array
{
return [
'data' => $this->data,
'success' => $this->success,
'msg' => $this->msg,
'showType' => $this->showType->value,
];
}
}