seed_solutions.py 920 B

12345678910111213141516171819202122232425262728293031
  1. import json
  2. from app import create_app, db
  3. from app.models import PageContent
  4. app = create_app()
  5. with app.app_context():
  6. solution_data = [
  7. {
  8. "title": "产教融合",
  9. "items": ["产业学院", "数智工坊", "高校实验室(训战)", "AI人才认证"]
  10. },
  11. {
  12. "title": "产业服务",
  13. "items": ["AI+政务服务解决方案", "智慧安防", "AI+医疗诊断解决方案"]
  14. }
  15. ]
  16. existing = PageContent.query.filter_by(page_key='solutions').first()
  17. if existing:
  18. existing.content = json.dumps(solution_data, ensure_ascii=False)
  19. else:
  20. new_page = PageContent(
  21. page_key='solutions',
  22. page_name='解决方案',
  23. content=json.dumps(solution_data, ensure_ascii=False)
  24. )
  25. db.session.add(new_page)
  26. db.session.commit()
  27. print("Solutions page data seeded successfully.")