优化CURD代码生成关联

This commit is contained in:
2026-04-01 15:27:23 +08:00
parent effde58a53
commit 0429cf62c4
3 changed files with 9 additions and 0 deletions

View File

@@ -581,6 +581,13 @@ class Crud extends Backend
private function parseModelMethods($field, &$modelData): void
{
// MySQL bigint/int 时间戳字段:显式声明为 integer避免 ThinkORM 自动时间戳写入 'now' 字符串
if (in_array($field['name'] ?? '', ['create_time', 'update_time', 'createtime', 'updatetime'], true)
&& in_array($field['type'] ?? '', ['int', 'bigint'], true)
) {
$modelData['fieldType'][$field['name']] = 'integer';
}
if (($field['designType'] ?? '') == 'array') {
$modelData['fieldType'][$field['name']] = 'json';
} elseif (!in_array($field['name'], ['create_time', 'update_time', 'updatetime', 'createtime'])