47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
批量修复XgStudentInfo实体类中的字段映射
|
|
将不存在的字段标记为 exist = false
|
|
"""
|
|
|
|
import re
|
|
import os
|
|
|
|
# 需要标记为不存在的字段
|
|
NON_EXISTENT_FIELDS = [
|
|
'name_english', 'former_name', 'name_pinyin', 'marital_status', 'religion',
|
|
'photo_url', 'photo_path', 'enrollment_year', 'school_system', 'education_level',
|
|
'training_type', 'admission_category', 'source_region', 'middle_school',
|
|
'major_code', 'major_name', 'class_code', 'grade', 'college_code',
|
|
'counselor_id', 'counselor_name', 'class_teacher_id', 'class_teacher_name',
|
|
'current_address', 'postal_code', 'household_register_type', 'hukou_location',
|
|
'info_status', 'data_source', 'last_batch_id', 'last_audit_time',
|
|
'is_complete', 'completion_rate', 'ext_field1', 'ext_field2', 'ext_field3',
|
|
'ext_field4', 'ext_field5'
|
|
]
|
|
|
|
def fix_entity_file():
|
|
file_path = '../ruoyi-modules/ruoyi-xg-xx/src/main/java/org/dromara/xg/domain/XgStudentInfo.java'
|
|
|
|
if not os.path.exists(file_path):
|
|
print(f"文件不存在: {file_path}")
|
|
return
|
|
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# 修复每个字段
|
|
for field in NON_EXISTENT_FIELDS:
|
|
# 查找 @TableField("field_name") 并替换为 @TableField(value = "field_name", exist = false)
|
|
pattern = f'@TableField\\("{field}"\\)'
|
|
replacement = f'@TableField(value = "{field}", exist = false)'
|
|
content = re.sub(pattern, replacement, content)
|
|
|
|
# 保存修改后的文件
|
|
with open(file_path, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
|
|
print("实体类字段映射修复完成")
|
|
|
|
if __name__ == '__main__':
|
|
fix_entity_file() |