mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 10:32:48 +08:00
feat(scheme): 新增数据库表结构同步方案
This commit is contained in:
8
extend/base/common/scheme/BaseScheme.php
Normal file
8
extend/base/common/scheme/BaseScheme.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace base\common\scheme;
|
||||
|
||||
abstract class BaseScheme
|
||||
{
|
||||
// 可以在这里添加一些通用的方法,例如获取所有字段定义的反射方法等
|
||||
}
|
||||
21
extend/base/common/scheme/attribute/Component.php
Normal file
21
extend/base/common/scheme/attribute/Component.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace base\common\scheme\attribute;
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_PROPERTY)]
|
||||
class Component
|
||||
{
|
||||
/**
|
||||
* @param string $type 组件类型 (e.g. radio, image, editor)
|
||||
* @param array $options 选项数据 (e.g. ['1'=>'男', '2'=>'女'])
|
||||
* @param array $extra 额外参数
|
||||
*/
|
||||
public function __construct(
|
||||
public string $type,
|
||||
public array $options = [],
|
||||
public array $extra = []
|
||||
) {
|
||||
}
|
||||
}
|
||||
23
extend/base/common/scheme/attribute/Field.php
Normal file
23
extend/base/common/scheme/attribute/Field.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace base\common\scheme\attribute;
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_PROPERTY)]
|
||||
class Field
|
||||
{
|
||||
public function __construct(
|
||||
public string $type = 'varchar',
|
||||
public ?int $length = null,
|
||||
public int $precision = 0,
|
||||
public int $scale = 0,
|
||||
public bool $nullable = true,
|
||||
public mixed $default = null,
|
||||
public string $comment = '',
|
||||
public bool $unsigned = false,
|
||||
public bool $autoIncrement = false,
|
||||
public bool $primary = false
|
||||
) {
|
||||
}
|
||||
}
|
||||
21
extend/base/common/scheme/attribute/Index.php
Normal file
21
extend/base/common/scheme/attribute/Index.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace base\common\scheme\attribute;
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_CLASS | Attribute::IS_REPEATABLE)]
|
||||
class Index
|
||||
{
|
||||
/**
|
||||
* @param string|array $columns 索引包含的列,单个字符串或数组
|
||||
* @param string $name 索引名称,留空则自动生成
|
||||
* @param string $type 索引类型:NORMAL, UNIQUE, FULLTEXT
|
||||
*/
|
||||
public function __construct(
|
||||
public string|array $columns,
|
||||
public string $name = '',
|
||||
public string $type = 'NORMAL'
|
||||
) {
|
||||
}
|
||||
}
|
||||
19
extend/base/common/scheme/attribute/Table.php
Normal file
19
extend/base/common/scheme/attribute/Table.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace base\common\scheme\attribute;
|
||||
|
||||
use Attribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_CLASS)]
|
||||
class Table
|
||||
{
|
||||
public function __construct(
|
||||
public string $name = '',
|
||||
public string $comment = '',
|
||||
public string $engine = 'InnoDB',
|
||||
public string $charset = 'utf8mb4',
|
||||
public string $collation = 'utf8mb4_general_ci',
|
||||
public ?string $connection = null
|
||||
) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user