Files
ALL-teach_sys/frontend_大健康/restructure_questions.py
KQL cd2e307402 初始化12个产业教务系统项目
主要内容:
- 包含12个产业的完整教务系统前端代码
- 智能启动脚本 (start-industry.sh)
- 可视化产业导航页面 (index.html)
- 项目文档 (README.md)

优化内容:
- 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB
- 添加.gitignore文件避免上传不必要的文件
- 自动依赖管理和智能启动系统

产业列表:
1. 文旅产业 (5150)
2. 智能制造 (5151)
3. 智能开发 (5152)
4. 财经商贸 (5153)
5. 视觉设计 (5154)
6. 交通物流 (5155)
7. 大健康 (5156)
8. 土木水利 (5157)
9. 食品产业 (5158)
10. 化工产业 (5159)
11. 能源产业 (5160)
12. 环保产业 (5161)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 14:14:14 +08:00

153 lines
5.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import json
print("重新构建Mock文件结构...")
# 读取文件
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
content = f.read()
# 备份
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js.backup_restructure', 'w', encoding='utf-8') as f:
f.write(content)
# 处理每个岗位群
# 1. 移除错误嵌套的questions
# 2. 在正确位置添加questions
industries_data = {
'health_1': 'health_2',
'health_2': 'health_3',
'health_3': 'health_4',
'health_4': 'health_5',
'health_5': 'health_6',
'health_6': 'health_7',
'health_7': 'health_8',
'health_8': 'health_9',
'health_9': 'health_10',
'health_10': 'health_11',
'health_11': None # 最后一个
}
fixed_count = 0
for industry_id, next_id in industries_data.items():
print(f"处理 {industry_id}...")
# 查找industry块
pattern = rf'"id":\s*"{industry_id}"'
match = re.search(pattern, content)
if not match:
print(f" 未找到 {industry_id}")
continue
start_pos = match.start()
# 找结束位置
if next_id:
next_pattern = rf'"id":\s*"{next_id}"'
next_match = re.search(next_pattern, content[start_pos + 10:])
if next_match:
end_pos = start_pos + 10 + next_match.start()
else:
continue
else:
# 最后一个industry
end_match = re.search(r'\n\];', content[start_pos:])
if end_match:
end_pos = start_pos + end_match.start()
else:
end_pos = len(content)
# 获取industry内容
industry_content = content[start_pos:end_pos]
# 检查是否有错误嵌套的questions在第一个position内部
# 查找第一个position对象的结束
first_position_pattern = r'"requirements":\s*\[[^\]]*?\]\s*,\s*"questions":\s*\['
if re.search(first_position_pattern, industry_content):
print(f" 发现错误嵌套的questions")
# 找到questions数组的完整内容
questions_start_match = re.search(r'"questions":\s*\[', industry_content)
if questions_start_match:
qs_start = questions_start_match.start()
# 使用括号计数找到questions的结束
bracket_count = 0
in_questions = False
qs_end = -1
for i in range(qs_start, len(industry_content)):
if industry_content[i] == '[':
if not in_questions and '"questions"' in industry_content[max(0, i-20):i]:
in_questions = True
bracket_count = 1
elif in_questions:
bracket_count += 1
elif industry_content[i] == ']' and in_questions:
bracket_count -= 1
if bracket_count == 0:
qs_end = i + 1
break
if qs_end > 0:
# 提取questions内容
questions_content = industry_content[qs_start:qs_end].strip()
# 移除错误的questions和后面多余的']'
# 找到"requirements": [...],后面的内容
req_end_match = re.search(r'"requirements":\s*\[[^\]]*?\]', industry_content)
if req_end_match:
req_end = req_end_match.end()
# 查找questions后面的多余']'
extra_bracket_match = re.search(r'\]\s*\n\]', industry_content[qs_end:qs_end + 50])
if extra_bracket_match:
# 移除从requirements后的逗号到多余']'的内容
clean_part1 = industry_content[:req_end]
clean_part2 = industry_content[qs_end + extra_bracket_match.end() - 1:] # -1 保留一个']'
clean_industry = clean_part1 + '\n }' + clean_part2
else:
# 简单移除questions部分
clean_industry = industry_content[:req_end] + '\n }' + industry_content[qs_end:]
# 现在在positions数组后添加questions
# 找到positions数组的结束
positions_end_pattern = r'"positions":\s*\[[^\]]*?\n\s*\]'
positions_match = re.search(positions_end_pattern, clean_industry, re.DOTALL)
if positions_match:
pos_end = positions_match.end() - 1 # 在']'之前
# 构建新的industry内容
new_industry = clean_industry[:pos_end] + '\n ],\n ' + questions_content + clean_industry[pos_end:]
# 替换原内容
content = content[:start_pos] + new_industry + content[end_pos:]
fixed_count += 1
print(f" ✓ 修复了 {industry_id}")
else:
print(f" 无法找到positions数组结束")
else:
print(f" 无法找到questions结束")
else:
print(f" 无法找到questions开始")
else:
print(f" 结构正常")
# 清理多余的符号
content = re.sub(r',\s*,', ',', content)
content = re.sub(r',\s*\]', ']', content)
content = re.sub(r',\s*\}', '}', content)
content = re.sub(r'\}\s*\]', '}]', content)
# 写回文件
with open('/Users/apple/Documents/cursor/教务系统/frontend_大健康/src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
f.write(content)
print(f"\n✓ 完成!修复了 {fixed_count} 个岗位群")