248 lines
8.4 KiB
Python
248 lines
8.4 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
|
|||
|
|
import json
|
|||
|
|
import re
|
|||
|
|
|
|||
|
|
def parse_interview_content(content):
|
|||
|
|
"""解析面试题内容,提取问题和答案"""
|
|||
|
|
questions = []
|
|||
|
|
|
|||
|
|
# 按照 "问题:" 分割内容
|
|||
|
|
parts = re.split(r'\n\s*\d+\.\s*问题[::]\s*', content)
|
|||
|
|
|
|||
|
|
for i, part in enumerate(parts):
|
|||
|
|
if i == 0: # 跳过第一个部分(通常是标题)
|
|||
|
|
continue
|
|||
|
|
|
|||
|
|
lines = part.strip().split('\n')
|
|||
|
|
if not lines:
|
|||
|
|
continue
|
|||
|
|
|
|||
|
|
# 第一行是问题
|
|||
|
|
question_text = lines[0].strip()
|
|||
|
|
|
|||
|
|
# 查找答案部分
|
|||
|
|
answer_lines = []
|
|||
|
|
in_answer = False
|
|||
|
|
|
|||
|
|
for line in lines[1:]:
|
|||
|
|
line = line.strip()
|
|||
|
|
if line.startswith('参考回答') or line.startswith('答案'):
|
|||
|
|
in_answer = True
|
|||
|
|
continue
|
|||
|
|
elif line.startswith('问题') or (line and line[0].isdigit() and '问题' in line):
|
|||
|
|
break
|
|||
|
|
elif in_answer and line:
|
|||
|
|
answer_lines.append(line)
|
|||
|
|
|
|||
|
|
answer_text = '\\n'.join(answer_lines).strip()
|
|||
|
|
|
|||
|
|
if question_text and answer_text:
|
|||
|
|
questions.append({
|
|||
|
|
"id": f"q_{i}",
|
|||
|
|
"question": question_text,
|
|||
|
|
"answer": answer_text,
|
|||
|
|
"difficulty": "中等",
|
|||
|
|
"tags": ["专业技能", "实践经验"]
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
return questions
|
|||
|
|
|
|||
|
|
def create_new_mock_data():
|
|||
|
|
"""重新创建完整的mock数据"""
|
|||
|
|
# 读取视觉设计原始数据
|
|||
|
|
with open('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'r', encoding='utf-8') as f:
|
|||
|
|
visual_data = json.load(f)
|
|||
|
|
|
|||
|
|
# 按岗位群分组
|
|||
|
|
position_groups = {}
|
|||
|
|
interview_groups = {}
|
|||
|
|
|
|||
|
|
for position in visual_data:
|
|||
|
|
group_name = position['简历岗位群']
|
|||
|
|
|
|||
|
|
# 收集岗位数据
|
|||
|
|
if group_name not in position_groups:
|
|||
|
|
position_groups[group_name] = []
|
|||
|
|
position_groups[group_name].append(position)
|
|||
|
|
|
|||
|
|
# 收集面试题数据
|
|||
|
|
if group_name not in interview_groups:
|
|||
|
|
interview_detail = position.get('面试题内容', '')
|
|||
|
|
if interview_detail:
|
|||
|
|
questions = parse_interview_content(interview_detail)
|
|||
|
|
interview_groups[group_name] = questions
|
|||
|
|
|
|||
|
|
# 创建industries数据
|
|||
|
|
industries = []
|
|||
|
|
|
|||
|
|
for group_id, (group_name, positions) in enumerate(position_groups.items()):
|
|||
|
|
# 创建positions数据
|
|||
|
|
industry_positions = []
|
|||
|
|
for pos_id, position in enumerate(positions):
|
|||
|
|
level = position.get('岗位等级标签', '普通岗')
|
|||
|
|
pos_obj = {
|
|||
|
|
"id": f"visual_design_{group_id + 1}_{pos_id + 1}",
|
|||
|
|
"title": position['岗位名称'],
|
|||
|
|
"level": level,
|
|||
|
|
"avatar": position.get('简历头像url', '').split(',')[0],
|
|||
|
|
"department": group_name,
|
|||
|
|
"type": "全职",
|
|||
|
|
"experience": "1-3年",
|
|||
|
|
"education": "大专",
|
|||
|
|
"salary": "6-12K",
|
|||
|
|
"location": "苏州",
|
|||
|
|
"updateTime": "2024-01-20",
|
|||
|
|
"description": f"负责{position['岗位名称']}相关工作",
|
|||
|
|
"requirements": [
|
|||
|
|
f"具备{group_name}专业技能",
|
|||
|
|
"熟悉相关设计软件",
|
|||
|
|
"具备良好的沟通协作能力",
|
|||
|
|
"有创新意识和学习能力"
|
|||
|
|
]
|
|||
|
|
}
|
|||
|
|
industry_positions.append(pos_obj)
|
|||
|
|
|
|||
|
|
# 创建面试题数据
|
|||
|
|
interview_questions = interview_groups.get(group_name, [])
|
|||
|
|
if not interview_questions:
|
|||
|
|
# 默认面试题
|
|||
|
|
interview_questions = [
|
|||
|
|
{
|
|||
|
|
"id": f"q_default_1",
|
|||
|
|
"question": f"{group_name}岗位的核心职责是什么?",
|
|||
|
|
"answer": f"负责{group_name}相关工作,包括设计规划、创意实现、项目协作等,确保项目质量和进度。",
|
|||
|
|
"difficulty": "基础",
|
|||
|
|
"tags": ["专业认知", "岗位职责"]
|
|||
|
|
}
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
questions_data = {
|
|||
|
|
"id": f"group_q{group_id + 1}",
|
|||
|
|
"question": f"# 一、专业能力与行业认知",
|
|||
|
|
"subQuestions": interview_questions
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 创建industry对象
|
|||
|
|
industry = {
|
|||
|
|
"id": f"visual_design_{group_id + 1}",
|
|||
|
|
"name": group_name,
|
|||
|
|
"positions": industry_positions,
|
|||
|
|
"questions": [questions_data]
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
industries.append(industry)
|
|||
|
|
|
|||
|
|
return industries
|
|||
|
|
|
|||
|
|
def create_resume_templates():
|
|||
|
|
"""创建简历模板数据"""
|
|||
|
|
with open('网页未导入数据/视觉设计产业/视觉设计岗位简历.json', 'r', encoding='utf-8') as f:
|
|||
|
|
visual_data = json.load(f)
|
|||
|
|
|
|||
|
|
templates = {}
|
|||
|
|
position_groups = {}
|
|||
|
|
|
|||
|
|
# 按岗位群分组
|
|||
|
|
for position in visual_data:
|
|||
|
|
group_name = position['简历岗位群']
|
|||
|
|
if group_name not in position_groups:
|
|||
|
|
position_groups[group_name] = []
|
|||
|
|
position_groups[group_name].append(position)
|
|||
|
|
|
|||
|
|
# 为每个岗位群创建模板
|
|||
|
|
for group_name, positions in position_groups.items():
|
|||
|
|
templates[group_name] = []
|
|||
|
|
|
|||
|
|
for position in positions:
|
|||
|
|
template = {
|
|||
|
|
"id": f"resume_{len(templates[group_name]) + 1}",
|
|||
|
|
"position": position['岗位名称'],
|
|||
|
|
"level": position.get('岗位等级标签', '普通岗'),
|
|||
|
|
"industry": group_name,
|
|||
|
|
"studentInfo": {
|
|||
|
|
"name": "张小同",
|
|||
|
|
"gender": "女",
|
|||
|
|
"age": 22,
|
|||
|
|
"education": "大专",
|
|||
|
|
"major": "数字媒体艺术设计",
|
|||
|
|
"avatar": position.get('简历头像url', '').split(',')[0]
|
|||
|
|
},
|
|||
|
|
"content": {
|
|||
|
|
"original": position.get('简历内容', ''),
|
|||
|
|
"modified": position.get('简历内容', '')
|
|||
|
|
},
|
|||
|
|
"interviewQuestions": position.get('面试题内容', '')
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
templates[group_name].append(template)
|
|||
|
|
|
|||
|
|
return templates
|
|||
|
|
|
|||
|
|
def main():
|
|||
|
|
print("🚀 重新生成完整的面试题数据...")
|
|||
|
|
|
|||
|
|
# 创建备份
|
|||
|
|
import shutil
|
|||
|
|
from datetime import datetime
|
|||
|
|
|
|||
|
|
backup_name = f"src/mocks/resumeInterviewMock.js.backup_fix_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
|||
|
|
shutil.copy('src/mocks/resumeInterviewMock.js', backup_name)
|
|||
|
|
print(f"📦 已创建备份: {backup_name}")
|
|||
|
|
|
|||
|
|
# 重新创建数据
|
|||
|
|
industries = create_new_mock_data()
|
|||
|
|
resume_templates = create_resume_templates()
|
|||
|
|
|
|||
|
|
# 创建完整的mock数据
|
|||
|
|
my_resume = {
|
|||
|
|
"name": "张小同",
|
|||
|
|
"studentId": "2024001",
|
|||
|
|
"major": "数字媒体艺术设计",
|
|||
|
|
"education": "大专",
|
|||
|
|
"avatar": "https://ddcz-1315997005.cos.ap-nanjing.myqcloud.com/static/img/butler_position_avatar/default_student.jpeg"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 生成新的JS文件内容
|
|||
|
|
js_content = f"""// 简历与面试题Mock数据
|
|||
|
|
|
|||
|
|
// 岗位群列表
|
|||
|
|
const industries = {json.dumps(industries, ensure_ascii=False, indent=2)};
|
|||
|
|
|
|||
|
|
// 简历模板数据
|
|||
|
|
const resumeTemplates = {json.dumps(resume_templates, ensure_ascii=False, indent=2)};
|
|||
|
|
|
|||
|
|
// 我的简历数据
|
|||
|
|
const myResume = {json.dumps(my_resume, ensure_ascii=False, indent=2)};
|
|||
|
|
|
|||
|
|
// 获取页面数据
|
|||
|
|
export const getMockPageData = () => {{
|
|||
|
|
return {{
|
|||
|
|
industries,
|
|||
|
|
resumeTemplates,
|
|||
|
|
myResume
|
|||
|
|
}};
|
|||
|
|
}};
|
|||
|
|
|
|||
|
|
// 导出各个数据模块
|
|||
|
|
export {{ industries, resumeTemplates, myResume }};
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
# 写入文件
|
|||
|
|
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
|||
|
|
f.write(js_content)
|
|||
|
|
|
|||
|
|
print("✅ 已重新生成 resumeInterviewMock.js")
|
|||
|
|
print(f"\\n📊 数据统计:")
|
|||
|
|
print(f" - 岗位群数量: {len(industries)}")
|
|||
|
|
print(f" - 岗位总数: {sum(len(industry['positions']) for industry in industries)}")
|
|||
|
|
|
|||
|
|
# 显示每个岗位群的面试题数量
|
|||
|
|
for industry in industries:
|
|||
|
|
group_name = industry['name']
|
|||
|
|
question_count = len(industry['questions'][0]['subQuestions'])
|
|||
|
|
print(f" - {group_name}: {question_count} 道面试题")
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
main()
|