-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit_data.py
More file actions
70 lines (63 loc) · 2.19 KB
/
init_data.py
File metadata and controls
70 lines (63 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from app import app, db
from models import Teacher, SummaryTask
from datetime import datetime, timedelta
def init_sample_data():
with app.app_context():
# 清空现有数据
db.drop_all()
db.create_all()
# 添加示例教师
teachers = [
Teacher(
teacher_name="张教授",
department="计算机科学",
email="zhang@university.edu.cn",
phone="13800138000",
title="教授",
position="系主任"
),
Teacher(
teacher_name="李教授",
department="计算机科学",
email="li@university.edu.cn",
phone="13800138001",
title="教授"
),
Teacher(
teacher_name="王老师",
department="软件工程",
email="wang@university.edu.cn",
phone="13800138002",
title="讲师"
),
Teacher(
teacher_name="赵副教授",
department="人工智能",
email="zhao@university.edu.cn",
phone="13800138003",
title="副教授"
)
]
for teacher in teachers:
db.session.add(teacher)
# 添加示例任务
tasks = [
SummaryTask(
task_name="人工智能应用案例单位推荐汇总表",
description="收集各学院人工智能应用案例推荐信息",
deadline=datetime.now() + timedelta(days=7)
),
SummaryTask(
task_name="基金申报汇总",
description="年度科研基金项目申报信息汇总",
deadline=datetime.now() + timedelta(days=14)
)
]
for task in tasks:
db.session.add(task)
db.session.commit()
print("示例数据初始化完成!")
print(f"- 创建了 {len(teachers)} 名教师")
print(f"- 创建了 {len(tasks)} 个汇总任务")
if __name__ == "__main__":
init_sample_data()