初始化本地仓库

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,80 @@
<?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\request\traits;
use OpenApi\Attributes as OA;
trait WithDateRange
{
#[OA\Property(
property: 'start_date',
description: '开始日期 (YYYY-MM-DD)',
type: 'string',
format: 'date',
example: '2024-01-01',
nullable: true
)]
public ?string $startDate = null;
#[OA\Property(
property: 'end_date',
description: '结束日期 (YYYY-MM-DD)',
type: 'string',
format: 'date',
example: '2024-12-31',
nullable: true
)]
public ?string $endDate = null;
public function getStartDate(): ?string
{
return $this->startDate;
}
public function getEndDate(): ?string
{
return $this->endDate;
}
public function hasDateRange(): bool
{
return !empty($this->startDate) && !empty($this->endDate);
}
/**
* 获取日期范围数组
*/
public function getDateRange(): array
{
return [
'start' => $this->startDate,
'end' => $this->endDate,
];
}
/**
* 验证日期范围是否有效
*/
public function isValidDateRange(): bool
{
if (!$this->hasDateRange()) {
return false;
}
$start = strtotime($this->startDate);
$end = strtotime($this->endDate);
return $start && $end && $start <= $end;
}
}
@@ -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\request\traits;
use OpenApi\Attributes as OA;
trait WithId
{
#[OA\Property(
property: 'id',
description: '主键ID',
type: 'integer',
minimum: 1,
example: 1
)]
public ?int $id = null;
public function getId(): ?int
{
return $this->id;
}
public function hasId(): bool
{
return !empty($this->id);
}
public function isUpdate(): bool
{
return $this->hasId();
}
public function isCreate(): bool
{
return !$this->hasId();
}
}
@@ -0,0 +1,54 @@
<?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\request\traits;
use OpenApi\Attributes as OA;
trait WithPagination
{
#[OA\Property(
property: 'page',
description: '当前页码',
type: 'integer|null',
minimum: 1,
example: 1
)]
public ?int $page = 1;
#[OA\Property(
property: 'limit',
description: '每页条数',
type: 'integer',
maximum: 999999,
minimum: 1,
example: 15
)]
public ?int $limit = 15;
public function getPage(): int
{
return $this->page ?? 1;
}
public function getLimit(): int
{
$limit = $this->limit ?? 15;
return min(max($limit, 1), 100);
}
public function getOffset(): int
{
return ($this->getPage() - 1) * $this->getLimit();
}
}
@@ -0,0 +1,37 @@
<?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\request\traits;
use OpenApi\Attributes as OA;
trait WithSearch
{
#[OA\Property(
property: 'keyword',
description: '关键词搜索',
type: 'string',
example: ''
)]
public ?string $keyword = null;
public function getKeyword(): ?string
{
return $this->keyword;
}
public function hasKeyword(): bool
{
return !empty($this->keyword);
}
}
@@ -0,0 +1,77 @@
<?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\request\traits;
use OpenApi\Attributes as OA;
trait WithSorting
{
#[OA\Property(
property: 'sort_field',
description: '排序字段',
type: 'string',
example: 'id'
)]
public ?string $sortField = null;
#[OA\Property(
property: 'sort_order',
description: '排序方式',
type: 'string',
enum: ['asc', 'desc'],
example: 'desc'
)]
public ?string $sortOrder = 'desc';
#[OA\Property(
property: 'order',
description: '排序规则 (例: sort asc, id desc)',
type: 'string',
example: 'id desc'
)]
public ?string $order = null;
public function getSortField(): ?string
{
return $this->sortField;
}
public function getSortOrder(): string
{
return in_array(strtolower($this->sortOrder ?? ''), ['asc', 'desc'])
? strtolower($this->sortOrder)
: 'desc';
}
public function getOrder(): ?string
{
return $this->order;
}
/**
* 获取排序字符串 (用于数据库查询)
*/
public function getOrderBy(): string
{
if (!empty($this->order)) {
return $this->order;
}
if (!empty($this->sortField)) {
return $this->sortField . ' ' . $this->getSortOrder();
}
return 'id desc';
}
}
@@ -0,0 +1,59 @@
<?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\request\traits;
use OpenApi\Attributes as OA;
trait WithStatus
{
#[OA\Property(
property: 'status',
description: '状态(0:禁用,1:启用)',
type: 'integer',
enum: [0, 1],
example: 1,
nullable: true
)]
public ?int $status = null;
public function getStatus(): ?int
{
return $this->status;
}
public function hasStatus(): bool
{
return $this->status !== null;
}
public function isEnable(): bool
{
return $this->status === 1;
}
public function isDisable(): bool
{
return $this->status === 0;
}
public function setEnable(): void
{
$this->status = 1;
}
public function setDisable(): void
{
$this->status = 0;
}
}
@@ -0,0 +1,80 @@
<?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\request\traits;
use OpenApi\Attributes as OA;
trait WithTimeRange
{
#[OA\Property(
property: 'start_time',
description: '开始时间 (YYYY-MM-DD HH:mm:ss)',
type: 'string',
format: 'date-time',
example: '2024-01-01 00:00:00',
nullable: true
)]
public ?string $startTime = null;
#[OA\Property(
property: 'end_time',
description: '结束时间 (YYYY-MM-DD HH:mm:ss)',
type: 'string',
format: 'date-time',
example: '2024-12-31 23:59:59',
nullable: true
)]
public ?string $endTime = null;
public function getStartTime(): ?string
{
return $this->startTime;
}
public function getEndTime(): ?string
{
return $this->endTime;
}
public function hasTimeRange(): bool
{
return !empty($this->startTime) && !empty($this->endTime);
}
/**
* 获取时间范围数组
*/
public function getTimeRange(): array
{
return [
'start' => $this->startTime,
'end' => $this->endTime,
];
}
/**
* 验证时间范围是否有效
*/
public function isValidTimeRange(): bool
{
if (!$this->hasTimeRange()) {
return false;
}
$start = strtotime($this->startTime);
$end = strtotime($this->endTime);
return $start && $end && $start <= $end;
}
}