diff --git a/.agents/skills/ulthon-scheme-definition/SKILL.md b/.agents/skills/ulthon-scheme-definition/SKILL.md index 5641369..0daf561 100644 --- a/.agents/skills/ulthon-scheme-definition/SKILL.md +++ b/.agents/skills/ulthon-scheme-definition/SKILL.md @@ -103,14 +103,14 @@ class YourClassName extends BaseScheme - `level`: 层级 (`province`/`city`/`area`)。 - `options`: 选项数据。支持索引数组 `['禁用', '启用']` 或关联数组 `['1' => '男', '2' => '女']`,对于 `relation`/`table`/`city` 类型,则是配置参数数组。 -## 编写建议 +## 编写规范 1. **命名规范**: 文件名采用大驼峰(PascalCase),且必须与类名一致。 -2. **基础字段**: 建议所有业务表都包含 `id`, `create_time`, `update_time` 字段。如果需要软删除,增加 `delete_time`。 - - `create_time`, `update_time`, `delete_time` 建议设置为 `int` 类型,默认 `0`,非空。 -3. **状态表达**: 避免使用 MySQL ENUM 类型。优先使用 `int` 或 `tinyint` 配合 `#[Component(type: 'radio')]` 或 `#[Component(type: 'switch')]`。 -4. **注释约定**: `Field` 的 `comment` 会直接同步到数据库字段注释,同时也作为后台表单的 Label。 -5. **字段后缀约定**: 框架会根据字段名后缀自动推断部分组件类型(若未显式指定 `#[Component]`): +2. **时间字段**: 统一使用 `int` 存储 Unix 时间戳,默认 `0`,非空。不要使用 `datetime`/`timestamp`。 +3. **软删除**: `delete_time` 字段(`int`,默认 `0`)存在时,模型自动启用软删除机制。查询时不要手写 `delete_time` 条件。 +4. **状态表达**: 避免使用 MySQL ENUM 类型。优先使用 `int` 或 `tinyint` 配合 `#[Component(type: 'radio')]` 或 `#[Component(type: 'switch')]`。 +5. **注释约定**: `Field` 的 `comment` 会直接同步到数据库字段注释,同时也作为后台表单的 Label。 +6. **字段后缀约定**: 框架会根据字段名后缀自动推断部分组件类型(若未显式指定 `#[Component]`): - `image`, `logo`, `photo`, `icon`: 默认为单图片。 - `images`, `photos`, `icons`: 默认为多图片。 - `file`: 默认为单文件。