初始化项目

This commit is contained in:
2025-05-12 00:19:35 +08:00
parent f6e4638ee6
commit fc327e9f48
27 changed files with 11107 additions and 29 deletions

55
app/Enum/ErrorEnum.php Executable file
View File

@@ -0,0 +1,55 @@
<?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 => '资源被删除',
};
}
}

25
app/Enum/ProjectStatusEnum.php Executable file
View File

@@ -0,0 +1,25 @@
<?php
namespace App\Enum;
/**
* 状态码定义
*/
enum ProjectStatusEnum: int
{
// '状态 0:草稿 1:上架 2:下架 3:重构中'
case DRAFT = 0;
case ON_SHELF = 1;
case OFF_SHELF = 2;
case REBUILD = 3;
public function description(): string
{
return match ($this) {
self::DRAFT => '草稿',
self::ON_SHELF => '上架',
self::OFF_SHELF => '下架',
self::REBUILD => '重构中',
default => '未知状态',
};
}
}

20
app/Enum/StatusEnum.php Executable file
View File

@@ -0,0 +1,20 @@
<?php
namespace App\Enum;
/**
* 状态码定义
*/
enum StatusEnum: int
{
// 状态 0:正常 1:禁用
case NORMAL = 0;
case DISABLE = 1;
public function description(): string
{
return match ($this) {
self::NORMAL => '正常',
self::DISABLE => '禁用',
};
}
}

23
app/Enum/UserStatusEnum.php Executable file
View File

@@ -0,0 +1,23 @@
<?php
namespace App\Enum;
/**
* 状态码定义
*/
enum UserStatusEnum: int
{
// 状态 0:正常 1:冻结 2:封号 3:注销
case NORMAL = 0;
case DISABLE = 1;
case DELETED = 2;
public function description(): string
{
return match ($this) {
self::NORMAL => '正常',
self::DISABLE => '冻结',
self::DELETED => '注销',
default => '未知',
};
}
}