From 961e5d24797bf9fe75fb6cf0976e3449a49347aa Mon Sep 17 00:00:00 2001 From: ssw Date: Wed, 15 Jul 2026 21:57:23 +0800 Subject: [PATCH] =?UTF-8?q?P0-1:=20=E4=BF=AE=20fix-entity=20=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=B7=BB=E5=8A=A0=20@TableId=20(CLAUDE.md=20=C2=A713?= =?UTF-8?q?=20=E9=AA=8C=E8=AF=81=E9=80=9A=E8=BF=87=20in=20testspace)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude --- src/commands/form/fix_entity.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/form/fix_entity.ts b/src/commands/form/fix_entity.ts index 709975f..3e4d60f 100644 --- a/src/commands/form/fix_entity.ts +++ b/src/commands/form/fix_entity.ts @@ -35,6 +35,7 @@ interface Opts { } const TARGET_ANNOTATION = '@TableId(value = "f_id", type = IdType.ASSIGN_ID)' +const TABLE_ID_PATTERN = /@TableId\s*\(/ /** 找 entity 目录(boot/ssw-{app}-entity/src/main/java/ssw/{app}/entity/) */ function findAppDirs(): { app: string; entityDir: string; bizDir: string | null }[] { @@ -62,7 +63,7 @@ function fixEntityFile(filePath: string, tableName?: string): { changed: boolean return { changed: false, reason: 'skip (not target table)' } } let content = readFileSync(filePath, 'utf-8') - if (content.includes(TARGET_ANNOTATION)) { + if (TABLE_ID_PATTERN.test(content)) { return { changed: false, reason: 'already fixed' } } const fIdMatch = content.match(/@JSONField\(name\s*=\s*"f_id"\)\s*\n\s*private\s+String\s+id\s*;/) @@ -131,7 +132,7 @@ export function buildFormFixEntityCommand(): Command { const full = join(dir, f) if (opts.dryRun) { const c = readFileSync(full, 'utf-8') - if (!c.includes(TARGET_ANNOTATION) && c.includes('@JSONField(name = "f_id")')) { + if (!TABLE_ID_PATTERN.test(c) && c.includes('@JSONField(name = "f_id")')) { log.ok(`[DRY] ${f}: 需要加 @TableId`) totalFixed++ } else { totalSkipped++ }