Files
nl-mall-api/app/Enum/ErrorEnum.php
2025-05-12 00:19:35 +08:00

56 lines
1.1 KiB
PHP
Executable File

<?php
namespace App\Enum;
/**
* 状态码定义
*/
enum ErrorEnum: int
{
/**
* 成功
*/
case SUCCESS = 0;
/**
* 登录过期
*/
case NOT_AUTH = 401;
/**
* 权限不足
*/
case NOT_PERMISSION = 403;
/**
* 未找到资源的错误
*/
case NOT_FOUND = 404;
/**
* 失败状态的错误
*/
case FAIL = 500;
/**
* 验证失败的错误
*/
case NOT_VALID = 2001;
/**
* 不存在的错误
*/
case NOT_EXIST = 2002;
/**
* 不存在或已删除的错误
*/
case NOT_EXIST_OR_DELETED = 2003;
public function description(): string
{
return match ($this) {
self::SUCCESS => '请求成功',
self::FAIL => '服务器异常',
self::NOT_FOUND => '未找到资源',
self::NOT_AUTH => '未授权',
self::NOT_PERMISSION => '您没有权限',
self::NOT_VALID => '字段验证失败',
self::NOT_EXIST => '资源不存在',
self::NOT_EXIST_OR_DELETED => '资源被删除',
};
}
}