-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
72 lines (55 loc) · 2.09 KB
/
models.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
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
__tablename__ = "user"
__table_args__ = {'mysql_collate':'utf8_general_ci'}
_id = db.Column(db.Integer,primary_key=True)
name = db.Column(db.String(30))
account = db.Column(db.String(11),unique=True)
password = db.Column(db.String(64))
avatar = db.Column(db.String(256))
age = db.Column(db.Integer)
idCard = db.Column(db.String(18))
gneder = db.Column(db.String(2))
createTime = db.Column(db.DateTime)
loginTime = db.Column(db.DateTime)
logoutTime = db.Column(db.DateTime)
balance = db.Column(db.Float(10),default=0)
vip = db.Column(db.Integer,db.ForeignKey("vip._id"))
def __repr__(self):
return "User:%s"%self.name
goodsCourt = db.Table("goodsCourt",
db.Column("goods_id",db.Integer,db.ForeignKey("goods._id")),
db.Column("court_id",db.Integer,db.ForeignKey("court._id"))
)
class Court(db.Model):
__tablename__ = "court"
__table_args__ = {'mysql_collate':'utf8_general_ci'}
_id = db.Column(db.Integer,primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user._id'))
number = db.Column(db.Integer,default=0)#记录商品种类
goods = db.relationship("Goods",secondary=goodsCourt,backref=db.backref("court",lazy="dynamic"),lazy="dynamic")
class Address(db.Model):
__tablename__ = "address"
__table_args__ = {'mysql_collate':'utf8_general_ci'}
_id = db.Column(db.Integer,primary_key=True)
province = db.Column(db.String(18))
town = db.Column(db.String(18))
county = db.Column(db.String(18))
detail = db.Column(db.String(200))
user_id = db.Column(db.Integer,db.ForeignKey("user._id"))
def __repr__(self):
return "Address:%s"%self.detail
class Admin(db.Model):
__tablename__ = "admin"
__table_args__ = {'mysql_collate':'utf8_general_ci'}
_id = db.Column(db.Integer,primary_key=True)
name = db.Column(db.String(30))
account = db.Column(db.String(11))
password = db.Column(db.String(64))
createTime = db.Column(db.DateTime)
loginTime = db.Column(db.DateTime)
logoutTime = db.Column(db.DateTime)
level = db.Column(db.Integer,default=0)
def __repr__(self):
return "Admin:%s"%self.name