2025-09-11 14:14:45 +08:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
# 读取清理后的数据
|
|
|
|
|
|
with open('resume_updates_cleaned.json', 'r', encoding='utf-8') as f:
|
|
|
|
|
|
updates = json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
# 读取resumeInterviewMock.js
|
|
|
|
|
|
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
|
|
|
|
|
content = f.read()
|
|
|
|
|
|
|
|
|
|
|
|
print("开始更新缺失的project_experience字段...")
|
|
|
|
|
|
|
|
|
|
|
|
# 需要更新project_experience的岗位
|
|
|
|
|
|
positions_to_update = [
|
|
|
|
|
|
'文创产品设计师',
|
|
|
|
|
|
'文创产品策划师',
|
|
|
|
|
|
'文创产品设计师助理',
|
|
|
|
|
|
'品牌策划运营专员',
|
|
|
|
|
|
'品牌公关',
|
|
|
|
|
|
'品牌推广专员',
|
|
|
|
|
|
'ip运营',
|
2025-10-15 15:55:25 +08:00
|
|
|
|
'ip运营总监助理',
|
2025-09-11 14:14:45 +08:00
|
|
|
|
'品牌公关管培生'
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
for position in positions_to_update:
|
|
|
|
|
|
update_data = next((u for u in updates if u['position'] == position), None)
|
|
|
|
|
|
if not update_data:
|
|
|
|
|
|
print(f"⚠ 未找到{position}的更新数据")
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
# 准备project_experience数据
|
|
|
|
|
|
project_exp = update_data['studentInfo']['project_experience']
|
|
|
|
|
|
|
|
|
|
|
|
# 查找该岗位的studentInfo位置
|
|
|
|
|
|
# 使用更精确的模式匹配
|
|
|
|
|
|
pattern = rf'(position:\s*"{re.escape(position)}"[^}}]*?studentInfo:\s*{{)'
|
|
|
|
|
|
|
|
|
|
|
|
match = re.search(pattern, content, re.DOTALL)
|
|
|
|
|
|
if match:
|
|
|
|
|
|
# 找到studentInfo开始位置
|
|
|
|
|
|
start_pos = match.end()
|
|
|
|
|
|
|
|
|
|
|
|
# 找到对应的结束大括号
|
|
|
|
|
|
brace_count = 1
|
|
|
|
|
|
end_pos = start_pos
|
|
|
|
|
|
while brace_count > 0 and end_pos < len(content):
|
|
|
|
|
|
if content[end_pos] == '{':
|
|
|
|
|
|
brace_count += 1
|
|
|
|
|
|
elif content[end_pos] == '}':
|
|
|
|
|
|
brace_count -= 1
|
|
|
|
|
|
end_pos += 1
|
|
|
|
|
|
|
|
|
|
|
|
# 获取当前的studentInfo内容
|
|
|
|
|
|
student_info_content = content[start_pos:end_pos-1]
|
|
|
|
|
|
|
|
|
|
|
|
# 检查是否有project_experience: null
|
|
|
|
|
|
if 'project_experience: null' in student_info_content:
|
|
|
|
|
|
# 构建新的project_experience
|
|
|
|
|
|
new_project_exp = f'''project_experience: {{
|
|
|
|
|
|
project_name: "{project_exp['project_name']}",
|
|
|
|
|
|
position: "{project_exp['position']}",
|
|
|
|
|
|
time_period: "{project_exp['time_period']}",
|
|
|
|
|
|
company: "{project_exp['company']}",
|
|
|
|
|
|
description: `{project_exp['description']}`
|
|
|
|
|
|
}}'''
|
|
|
|
|
|
|
|
|
|
|
|
# 替换project_experience: null
|
|
|
|
|
|
new_content = student_info_content.replace('project_experience: null', new_project_exp)
|
|
|
|
|
|
|
|
|
|
|
|
# 更新content
|
|
|
|
|
|
content = content[:start_pos] + new_content + content[end_pos-1:]
|
|
|
|
|
|
print(f"✓ {position} project_experience已更新")
|
|
|
|
|
|
else:
|
|
|
|
|
|
print(f"ℹ {position} 已有project_experience或结构异常")
|
|
|
|
|
|
|
|
|
|
|
|
# 保存更新后的文件
|
|
|
|
|
|
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
|
|
|
|
|
f.write(content)
|
|
|
|
|
|
|
|
|
|
|
|
print("\n✓ 所有project_experience更新完成!")
|