初始化本地仓库

This commit is contained in:
2026-08-31 11:33:59 +08:00
commit 663f74b633
2390 changed files with 402918 additions and 0 deletions
@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
/**
*+------------------
* madong
*+------------------
* Copyright (c) https://gitee.com/motion-code All rights reserved.
*+------------------
* Author: Mr. April (405784684@qq.com)
*+------------------
* Official Website: http://www.madong.tech
*/
namespace app\schema\response;
use OpenApi\Attributes as OA;
use madong\swagger\schema\BaseResponseDTO;
#[OA\Schema(
title: '错误响应',
description: '错误响应结构'
)]
class ErrorResponse extends BaseResponseDTO
{
#[OA\Property(
property: 'error',
description: '错误信息',
type: 'string',
example: '参数错误'
)]
public string $error;
#[OA\Property(
property: 'code',
description: '错误码',
type: 'string',
example: 'VALIDATION_ERROR'
)]
public ?string $code = null;
#[OA\Property(
property: 'details',
description: '错误详情',
type: 'array',
items: new OA\Items(type: 'string'),
example: []
)]
public ?array $details = null;
public function __construct(
string $error = '操作失败',
?string $code = null,
?array $details = null
)
{
$this->error = $error;
$this->code = $code;
$this->details = $details;
}
public static function make(
string $error,
?string $code = null,
?array $details = null
): self
{
return new self($error, $code, $details);
}
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/**
*+------------------
* madong
*+------------------
* Copyright (c) https://gitee.com/motion-code All rights reserved.
*+------------------
* Author: Mr. April (405784684@qq.com)
*+------------------
* Official Website: http://www.madong.tech
*/
namespace app\schema\response;
use OpenApi\Attributes as OA;
use madong\swagger\schema\BaseResponseDTO;
#[OA\Schema(
title: '列表数据响应',
description: '列表数据响应结构'
)]
class ListResponse extends BaseResponseDTO
{
#[OA\Property(
property: 'list',
description: '数据列表',
type: 'array',
items: new OA\Items(),
example: []
)]
public array $list;
}
@@ -0,0 +1,75 @@
<?php
declare(strict_types=1);
/**
*+------------------
* madong
*+------------------
* Copyright (c) https://gitee.com/motion-code All rights reserved.
*+------------------
* Author: Mr. April (405784684@qq.com)
*+------------------
* Official Website: http://www.madong.tech
*/
namespace app\schema\response;
use OpenApi\Attributes as OA;
use madong\swagger\schema\BaseResponseDTO;
#[OA\Schema(
title: '分页数据响应',
description: '分页数据响应结构'
)]
class PageResponse extends BaseResponseDTO
{
#[OA\Property(
property: 'total',
description: '总记录数',
type: 'integer',
example: 100
)]
public int $total;
#[OA\Property(
property: 'page',
description: '当前页码',
type: 'integer',
example: 1
)]
public int $page;
#[OA\Property(
property: 'limit',
description: '每页条数',
type: 'integer',
example: 15
)]
public int $limit;
#[OA\Property(
property: 'items',
description: '数据列表',
type: 'array',
items: new OA\Items(),
example: []
)]
public array $items;
public function __construct(
int $total = 0,
int $page = 1,
int $limit = 15,
array $items = []
) {
$this->total = $total;
$this->page = $page;
$this->limit = $limit;
$this->items = $items;
}
public static function make(int $total, int $page, int $limit, array $items): self
{
return new self($total, $page, $limit, $items);
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/**
*+------------------
* madong
*+------------------
* Copyright (c) https://gitee.com/motion-code All rights reserved.
*+------------------
* Author: Mr. April (405784684@qq.com)
*+------------------
* Official Website: http://www.madong.tech
*/
namespace app\schema\response;
use Illuminate\Contracts\Support\Arrayable;
use OpenApi\Attributes as OA;
#[OA\Schema(
title: 'API响应结构',
description: '系统统一API响应数据格式'
)]
class Result implements Arrayable
{
public function __construct(
#[OA\Property(ref: 'ResultCode', title: '响应码')]
public ResultCode $code = ResultCode::SUCCESS,
#[OA\Property(title: '响应消息', type: 'string', example: 'success')]
public ?string $msg = null,
#[OA\Property(title: '响应数据', example: [])]
public mixed $data = []
)
{
if ($this->code === ResultCode::SUCCESS) {
$this->msg = $this->msg ?? 'success';
}
}
public function toArray(): array
{
return [
'code' => $this->code->value,
'msg' => $this->msg,
'data' => $this->data,
];
}
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/**
*+------------------
* madong
*+------------------
* Copyright (c) https://gitee.com/motion-code All rights reserved.
*+------------------
* Author: Mr. April (405784684@qq.com)
*+------------------
* Official Website: http://www.madong.tech
*/
namespace app\schema\response;
use OpenApi\Attributes as OA;
#[OA\Schema(
title: 'API响应状态',
type: 'integer',
default: 0
)]
enum ResultCode: int
{
case SUCCESS = 0;
case FAIL = -1;
case UNAUTHORIZED = 401;
case FORBIDDEN = 403;
case NOT_FOUND = 404;
case METHOD_NOT_ALLOWED = 405;
case NOT_ACCEPTABLE = 406;
case UNPROCESSABLE_ENTITY = 422;
case DISABLED = 423;
}
@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
/**
*+------------------
* madong
*+------------------
* Copyright (c) https://gitee.com/motion-code All rights reserved.
*+------------------
* Author: Mr. April (405784684@qq.com)
*+------------------
* Official Website: http://www.madong.tech
*/
namespace app\schema\response;
use OpenApi\Attributes as OA;
use madong\swagger\schema\BaseResponseDTO;
#[OA\Schema(
title: '简单数据响应',
description: '简单数据响应结构,用于返回单个值或简单对象'
)]
class SimpleResponse extends BaseResponseDTO
{
#[OA\Property(
property: 'flag',
description: '操作状态标识',
type: 'boolean',
example: true
)]
public bool $flag;
#[OA\Property(
property: 'message',
description: '操作消息',
type: 'string',
example: '操作成功'
)]
public ?string $message = null;
#[OA\Property(
property: 'data',
description: '附加数据',
type: 'object',
example: []
)]
public mixed $data = null;
public function __construct(
bool $flag = true,
?string $message = null,
mixed $data = null
)
{
$this->flag = $flag;
$this->message = $message ?? ($flag ? '操作成功' : '操作失败');
$this->data = $data;
}
public static function success(?string $message = '操作成功', mixed $data = null): self
{
return new self(true, $message, $data);
}
public static function fail(?string $message = '操作失败', mixed $data = null): self
{
return new self(false, $message, $data);
}
}
@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);
/**
*+------------------
* madong
*+------------------
* Copyright (c) https://gitee.com/motion-code All rights reserved.
*+------------------
* Author: Mr. April (405784684@qq.com)
*+------------------
* Official Website: http://www.madong.tech
*/
namespace app\schema\response;
use OpenApi\Attributes as OA;
use madong\swagger\schema\BaseResponseDTO;
#[OA\Schema(
title: '树形数据响应',
description: '树形结构数据响应,用于菜单、部门等层级数据'
)]
class TreeResponse extends BaseResponseDTO
{
#[OA\Property(
property: 'id',
description: '节点ID',
type: 'string',
example: 1
)]
public string $id;
#[OA\Property(
property: 'pid',
description: '父节点ID',
type: 'string',
example: 0
)]
public string $pid;
#[OA\Property(
property: 'name',
description: '节点名称',
type: 'string',
example: '系统管理'
)]
public string $name;
#[OA\Property(
property: 'children',
description: '子节点列表',
type: 'array',
items: new OA\Items(),
example: []
)]
public array $children = [];
public function __construct(
string|int $id = 0,
string|int $parentId = 0,
string $name = '',
array $children = []
)
{
$this->id = (string)$id;
$this->pid = (string)$parentId;
$this->name = $name;
$this->children = $children;
}
public static function make(
int $id,
int $parentId,
string $name,
array $children = []
): self
{
return new self($id, $parentId, $name, $children);
}
public function hasChildren(): bool
{
return !empty($this->children);
}
}