- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸 - 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB - 配置完善的.gitignore文件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
124 lines
5.6 KiB
Python
124 lines
5.6 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
修复面试题数据结构
|
||
移除所有position级别的questions,确保只在industry级别有questions
|
||
"""
|
||
|
||
import re
|
||
from datetime import datetime
|
||
|
||
def fix_interview_structure():
|
||
"""修复面试题数据结构"""
|
||
try:
|
||
# 读取文件
|
||
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
|
||
# 创建备份
|
||
backup_filename = f'src/mocks/resumeInterviewMock.js.backup_{datetime.now().strftime("%Y%m%d_%H%M%S")}'
|
||
with open(backup_filename, 'w', encoding='utf-8') as f:
|
||
f.write(content)
|
||
print(f"已创建备份文件: {backup_filename}")
|
||
|
||
# 1. 移除所有position对象内的questions字段(包括逗号和缩进)
|
||
updated_content = re.sub(
|
||
r',\s*"questions": \[[^\]]*\](?:\s*,\s*"questions": \[[^\]]*\])*',
|
||
'',
|
||
content,
|
||
flags=re.DOTALL
|
||
)
|
||
|
||
# 2. 清理可能的语法错误(多余的逗号)
|
||
updated_content = re.sub(r',(\s*\})', r'\1', updated_content)
|
||
|
||
# 3. 确保健康管理行业有questions字段
|
||
health_mgmt_questions = '''[
|
||
{
|
||
"id": "q1",
|
||
"question": "你认为健康顾问和传统医生的区别是什么?",
|
||
"answer": "医生主要负责疾病诊疗,而健康顾问更多聚焦于疾病预防和健康促进。健康顾问通过营养、运动、心理等多维度干预,帮助客户建立良好的生活习惯,与医生形成互补关系,共同提升客户健康水平。"
|
||
},
|
||
{
|
||
"id": "q2",
|
||
"question": "健康管理中最具挑战性的部分是什么?",
|
||
"answer": "最大的挑战是客户的依从性。很多客户虽然知道健康的重要性,但难以坚持。我会通过阶段性目标、数据化追踪和正向反馈来增强客户信心,提高健康干预的执行力。"
|
||
},
|
||
{
|
||
"id": "q3",
|
||
"question": "如果客户长期忽视健康管理建议,你会怎么办?",
|
||
"answer": "我会先分析原因,可能是方案过于复杂、目标过高或缺乏动力。我会调整为更小、更容易实现的目标,比如\\"每天走5000步\\"而不是\\"立即跑10公里\\"。同时,通过定期沟通和数据反馈,让客户看到小进步,逐步增强信心。"
|
||
}
|
||
]'''
|
||
|
||
# 4. 为健康管理行业添加questions字段(如果还没有的话)
|
||
if '"name": "健康管理"' in updated_content:
|
||
# 检查是否已经有industry级别的questions
|
||
health_start = updated_content.find('"name": "健康管理"')
|
||
health_end = updated_content.find('},', health_start)
|
||
if health_end == -1:
|
||
health_end = updated_content.find('}]', health_start)
|
||
|
||
health_section = updated_content[health_start:health_end]
|
||
|
||
# 如果industry级别没有questions,添加它
|
||
if '"questions":' not in health_section or health_section.count('"questions":') == 0:
|
||
# 在positions数组后添加questions
|
||
pattern = r'("name": "健康管理"[^}]*?"positions": \[[^\]]*?\]\s*)'
|
||
replacement = r'\1,\n "questions": ' + health_mgmt_questions
|
||
|
||
updated_content = re.sub(
|
||
pattern,
|
||
replacement,
|
||
updated_content,
|
||
flags=re.DOTALL
|
||
)
|
||
|
||
# 5. 为健康检查行业添加questions字段
|
||
health_check_questions = '''[
|
||
{
|
||
"id": "q1",
|
||
"question": "常见的健康检查项目有哪些?",
|
||
"answer": "包括基础检查(身高、体重、血压、心率)、实验室检测(血常规、肝肾功能、血脂血糖)、影像学检查(X光、彩超、CT/MRI)、心电图检查、癌症筛查(肿瘤标志物、低剂量螺旋CT)、以及女性乳腺/宫颈筛查、男性前列腺检查等。"
|
||
},
|
||
{
|
||
"id": "q2",
|
||
"question": "为什么说健康检查应因人而异?",
|
||
"answer": "因为健康风险与性别、年龄、职业、遗传背景和生活方式密切相关。例如,年轻人更需关注代谢异常和传染病筛查,中老年人则更需重视心血管疾病和肿瘤筛查。因人制宜的体检方案能提高检查的针对性和有效性,避免资源浪费。"
|
||
}
|
||
]'''
|
||
|
||
if '"name": "健康检查"' in updated_content:
|
||
health_check_start = updated_content.find('"name": "健康检查"')
|
||
health_check_end = updated_content.find('},', health_check_start)
|
||
if health_check_end == -1:
|
||
health_check_end = updated_content.find('}]', health_check_start)
|
||
|
||
health_check_section = updated_content[health_check_start:health_check_end]
|
||
|
||
if '"questions":' not in health_check_section:
|
||
pattern = r'("name": "健康检查"[^}]*?"positions": \[[^\]]*?\]\s*)'
|
||
replacement = r'\1,\n "questions": ' + health_check_questions
|
||
|
||
updated_content = re.sub(
|
||
pattern,
|
||
replacement,
|
||
updated_content,
|
||
flags=re.DOTALL
|
||
)
|
||
|
||
# 写回文件
|
||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||
f.write(updated_content)
|
||
|
||
print("面试题数据结构修复完成!")
|
||
return True
|
||
|
||
except Exception as e:
|
||
print(f"修复失败: {e}")
|
||
import traceback
|
||
traceback.print_exc()
|
||
return False
|
||
|
||
if __name__ == "__main__":
|
||
fix_interview_structure() |