P0-1: 修 fix-entity 重复添加 @TableId (CLAUDE.md §13 验证通过 in testspace)
Co-Authored-By: Claude <[email protected]>
This commit is contained in:
1 parent
95d63a4c40
commit
961e5d2479
1 file changed
+3
-2
@@ -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++ }
|
||||
|
||||
Reference in new issue
Block a user