40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
# -*- coding: utf-8 -*-
|
||
|
|
"""
|
||
|
|
同步更新 companyJobsData.json 的截止时间字段
|
||
|
|
"""
|
||
|
|
|
||
|
|
import json
|
||
|
|
|
||
|
|
def main():
|
||
|
|
target_path = 'src/mocks/companyJobsData.json'
|
||
|
|
|
||
|
|
# 读取当前数据
|
||
|
|
print(f"读取文件: {target_path}")
|
||
|
|
with open(target_path, 'r', encoding='utf-8') as f:
|
||
|
|
jobs_data = json.load(f)
|
||
|
|
|
||
|
|
print(f"共有 {len(jobs_data)} 个岗位")
|
||
|
|
|
||
|
|
# 修复字段名
|
||
|
|
fixed_count = 0
|
||
|
|
for job in jobs_data:
|
||
|
|
# 确保有截止时间字段
|
||
|
|
if "岗位招聘截止时间" in job and "截止时间" not in job:
|
||
|
|
job["截止时间"] = job["岗位招聘截止时间"]
|
||
|
|
elif "截止时间" not in job:
|
||
|
|
# 如果都没有,使用默认值
|
||
|
|
job["截止时间"] = "2025/12/31"
|
||
|
|
fixed_count += 1
|
||
|
|
|
||
|
|
print(f"更新了 {fixed_count} 个岗位的截止时间字段")
|
||
|
|
|
||
|
|
# 写回文件
|
||
|
|
print(f"写入更新后的数据到: {target_path}")
|
||
|
|
with open(target_path, 'w', encoding='utf-8') as f:
|
||
|
|
json.dump(jobs_data, f, ensure_ascii=False, indent=2)
|
||
|
|
|
||
|
|
print("✅ 同步完成!")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|