110 lines
3.6 KiB
Python
110 lines
3.6 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
|
|||
|
|
import json
|
|||
|
|
import datetime
|
|||
|
|
import shutil
|
|||
|
|
|
|||
|
|
def generate_resume_templates():
|
|||
|
|
"""生成简历模板数据"""
|
|||
|
|
|
|||
|
|
# 读取能源岗位简历数据
|
|||
|
|
with open("网页未导入数据/能源产业/能源岗位简历.json", 'r', encoding='utf-8') as f:
|
|||
|
|
energy_jobs = json.load(f)
|
|||
|
|
|
|||
|
|
# 按岗位群分组
|
|||
|
|
resume_templates = {}
|
|||
|
|
|
|||
|
|
for job in energy_jobs:
|
|||
|
|
group_name = job.get("简历岗位群", "")
|
|||
|
|
position_name = job.get("岗位名称", "")
|
|||
|
|
|
|||
|
|
if group_name and position_name:
|
|||
|
|
if group_name not in resume_templates:
|
|||
|
|
resume_templates[group_name] = []
|
|||
|
|
|
|||
|
|
# 添加模板数据
|
|||
|
|
template = {
|
|||
|
|
"position": position_name,
|
|||
|
|
"level": job.get("岗位级别", "基础岗"),
|
|||
|
|
"avatar": job.get("岗位头像", ""),
|
|||
|
|
"content": {
|
|||
|
|
"original": job.get("简历模板", ""),
|
|||
|
|
"modified": job.get("修改后简历", "")
|
|||
|
|
},
|
|||
|
|
"studentInfo": {
|
|||
|
|
"project_experience": {
|
|||
|
|
"project_name": "",
|
|||
|
|
"position": "",
|
|||
|
|
"time_period": "XXXXXX",
|
|||
|
|
"company": "XXXXXX",
|
|||
|
|
"description": ""
|
|||
|
|
},
|
|||
|
|
"core_skills": [],
|
|||
|
|
"compound_skills": [],
|
|||
|
|
"personal_summary": ""
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
resume_templates[group_name].append(template)
|
|||
|
|
|
|||
|
|
return resume_templates
|
|||
|
|
|
|||
|
|
def update_mock_file():
|
|||
|
|
"""更新mock文件,添加resumeTemplates"""
|
|||
|
|
|
|||
|
|
mock_file = "src/mocks/resumeInterviewMock.js"
|
|||
|
|
|
|||
|
|
# 备份文件
|
|||
|
|
backup_path = f"{mock_file}.backup_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
|||
|
|
shutil.copy(mock_file, backup_path)
|
|||
|
|
print(f"✅ 已备份文件到:{backup_path}")
|
|||
|
|
|
|||
|
|
# 生成resumeTemplates
|
|||
|
|
resume_templates = generate_resume_templates()
|
|||
|
|
|
|||
|
|
# 读取当前文件
|
|||
|
|
with open(mock_file, 'r', encoding='utf-8') as f:
|
|||
|
|
content = f.read()
|
|||
|
|
|
|||
|
|
# 在industries定义后添加resumeTemplates
|
|||
|
|
industries_end = content.find('];')
|
|||
|
|
if industries_end > 0:
|
|||
|
|
# 在industries数组结束后插入resumeTemplates
|
|||
|
|
insert_pos = industries_end + 2
|
|||
|
|
|
|||
|
|
# 生成resumeTemplates的JS代码
|
|||
|
|
templates_js = "\n\n// 简历模板数据\nconst resumeTemplates = " + json.dumps(resume_templates, ensure_ascii=False, indent=2) + ";\n"
|
|||
|
|
|
|||
|
|
# 插入resumeTemplates
|
|||
|
|
new_content = content[:insert_pos] + templates_js + content[insert_pos:]
|
|||
|
|
|
|||
|
|
# 更新getMockPageData函数
|
|||
|
|
new_content = new_content.replace(
|
|||
|
|
'export function getMockPageData() {\n return {\n industries,\n positions: []\n };\n}',
|
|||
|
|
'''export function getMockPageData() {
|
|||
|
|
return {
|
|||
|
|
industries,
|
|||
|
|
resumeTemplates,
|
|||
|
|
positions: [],
|
|||
|
|
myResume
|
|||
|
|
};
|
|||
|
|
}'''
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
# 写回文件
|
|||
|
|
with open(mock_file, 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(new_content)
|
|||
|
|
|
|||
|
|
print("✅ 成功添加resumeTemplates数据")
|
|||
|
|
|
|||
|
|
# 统计
|
|||
|
|
print("\n📊 简历模板统计:")
|
|||
|
|
for group_name, templates in resume_templates.items():
|
|||
|
|
print(f" - {group_name}: {len(templates)}个模板")
|
|||
|
|
print(f"\n📈 总计:{len(resume_templates)}个岗位群,{sum(len(t) for t in resume_templates.values())}个简历模板")
|
|||
|
|
else:
|
|||
|
|
print("❌ 未找到industries数组结束位置")
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
update_mock_file()
|