-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
121 lines (97 loc) · 5.03 KB
/
model.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from extensions import db
from datetime import datetime
class AdminModel(db.Model):
__tablename__ = 'admin'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(12), nullable=False)
password = db.Column(db.String(200), nullable=False)
join_time = db.Column(db.DateTime, default=datetime.now)
phone_num = db.Column(db.String(100), nullable=False, unique=True)
company = db.Column(db.String(100), nullable=False)
edu_bg = db.Column(db.String(100), nullable=False)
skill = db.Column(db.String(100), nullable=False)
title = db.Column(db.String(100), nullable=False)
sentence = db.Column(db.String(100), nullable=False)
salary = db.Column(db.String(100), nullable=False)
class ResidentModel(db.Model):
__tablename__ = 'resident'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(12), nullable=False)
is_holder = db.Column(db.Boolean, nullable=False)
phone_num = db.Column(db.String(20), nullable=False)
building = db.Column(db.Integer, nullable=False)
room = db.Column(db.Integer, nullable=False)
workplace = db.Column(db.String(100), nullable=False)
le = db.Column(db.String(3), nullable=False)
photo = db.Column(db.String(100), nullable=False)
class VisitorModel(db.Model):
__tablename__ = 'visitor'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
name = db.Column(db.String(12), nullable=False)
reason = db.Column(db.Text)
phone_num = db.Column(db.String(20), nullable=False)
visit_time = db.Column(db.DateTime, default=datetime.now)
le_type = db.Column(db.String(2), nullable=False) # 0 leave, 1 enter
photo = db.Column(db.String(100), nullable=False)
class CaptchaModel(db.Model):
# 给指定邮箱发邮件,物业经理拿着这个验证码给保安注册,验证码与手机号绑定
__tablename__ = 'captcha'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
phone_num = db.Column(db.String(100), nullable=False)
captcha = db.Column(db.String(100), nullable=False)
class CarModel(db.Model):
__tablename__ = 'car'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
vp = db.Column(db.String(12), nullable=False) # vehicleplate
# 外键
owner_id = db.Column(db.Integer, db.ForeignKey("resident.id"), nullable=False)
# 关系
owner = db.relationship(ResidentModel, backref='cars')
class TempVehicleModel(db.Model):
__tablename__ = 'temp_vehicle'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
vp = db.Column(db.String(12), nullable=False) # vehicleplate
# 外键
owner_id = db.Column(db.Integer, db.ForeignKey("visitor.id"), nullable=False)
owner = db.relationship(VisitorModel, backref='temp_vehicles')
class EmailModel(db.Model):
__tablename__ = 'email'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String(100), nullable=False)
content = db.Column(db.Text, nullable=False)
create_time = db.Column(db.DateTime, default=datetime.now)
is_trash = db.Column(db.Boolean, nullable=False)
is_important = db.Column(db.Boolean, nullable=False)
is_read = db.Column(db.Boolean, nullable=False)
is_draft = db.Column(db.Boolean, nullable=False)
sender_id = db.Column(db.Integer, db.ForeignKey("admin.id"), nullable=False)
receiver_id = db.Column(db.Integer, nullable=False)
sender = db.relationship(AdminModel, backref='emails')
class AnnouncementModel(db.Model):
__tablename__ = 'announcement'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String(100), nullable=False)
content = db.Column(db.Text, nullable=False)
create_time = db.Column(db.DateTime, default=datetime.now)
class PARecordModel(db.Model):
__tablename__ = 'parecord' # person access record
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
person_id = db.Column(db.Integer, nullable=False)
name = db.Column(db.String(12), nullable=False)
person_type = db.Column(db.String(2), nullable=False) # 0 visitor, 1 resident
le_type = db.Column(db.String(2), nullable=False) # 0 leave, 1 enter
time = db.Column(db.DateTime, default=datetime.now)
class VARecordModel(db.Model):
__tablename__ = 'varecord' # vehicle access record
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
vehicle_id = db.Column(db.Integer, nullable=False)
vp = db.Column(db.String(12), nullable=False)
vehicle_type = db.Column(db.String(2), nullable=False) # 0 visitor, 1 resident
le_type = db.Column(db.String(2), nullable=False) # 0 leave, 1 enter
time = db.Column(db.DateTime, default=datetime.now)
class MapMarkModel(db.Model):
__tablename__ = 'mapmark'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
long = db.Column(db.Numeric(precision=9, scale=6), nullable=False)
lat = db.Column(db.Numeric(precision=9, scale=6), nullable=False)
content = db.Column(db.String(100), nullable=False)