class Doctor(db.Model): __tablename__ = 'doctor' id = db.Column(db.Integer, primary_key=True) doctor_name = db.Column(db.String(150), unique=False) doctor_email = db.Column(db.String(50), unique=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Doctor('{self.doctor_name}', '{self.doctor_email}')"
class usergroup(db.Model,BaseModel): ''' 定义用户角色关系表 ''' __tablename__ = 'usergroup' guid = db.Column(Integer, unique=True, primary_key=True, autoincrement=True) user_code = db.Column('user_code',db.String(50)) groupid = db.Column('groupid',db.String(50)) def __int__(self, user_code=None, groupid=None): self.user_code = user_code self.groupid = groupid
class mission_user(db.Model, BaseModel): ''' 定义了任务与用户关系 ''' __tablename__ = 'mission_user' guid = db.Column(Integer, unique=True, primary_key=True, autoincrement=True) missionid = db.Column('missionid',db.String(10)) user_code = db.Column('user_code', db.String(50)) def __int__(self, missionid=None, user_code=None): self.missionid = missionid self.user_code = user_code
class User(Base, UserMixin): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(15), unique=True) email = db.Column(db.String(50), unique=True) password = db.Column(db.String(80)) join_date = db.Column(db.DateTime) picture = db.Column(db.String(20), nullable=False, default='default.jpg') readings = db.relationship('Readings', backref='creator', lazy=True) def __repr__(self): # return '<User %r>' % self.username, self.email, self.picture return f"User('{self.username}', '{self.email}', '{self.picture}')"
class mission_barcode(db.Model, BaseModel): ''' 定义任务与资产标签号关系 ''' __tablename__ = 'mission_barcode' guid = db.Column(Integer, unique=True, primary_key=True, autoincrement=True) missionid = db.Column('missionid', db.String(10)) barcode = db.Column('barcode', db.String(100)) msgid = db.Column('msgid') def __int__(self, missionid=None, barcode=None, msgid=None): self.missionid = missionid self.barcode = barcode self.msgid = msgid
class Readings(db.Model): __tablename__ = 'readings' id = db.Column(db.Integer, primary_key=True) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow()) #date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) systolic = db.Column(db.Integer()) diastolic = db.Column(db.Integer()) notes = db.Column(db.String(250)) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Readings('{self.date_posted}', '{self.systolic}', '{self.diastolic}', '{self.notes}')"
class mission(db.Model, BaseModel): ''' 定义了任务 ''' __tablename__ = 'mission' guid = db.Column(Integer, unique=True, primary_key=True, autoincrement=True) missionname = db.Column('missionname', db.String(100)) startdate = db.Column('startdate',db.DATE) enddate = db.Column('enddate',db.DATE) def __int__(self, missionname=None, startdate=None, enddate=None): self.missionname = missionname self.startdate = startdate self.enddate = enddate
class Doctor(Base): __tablename__ = 'doctor' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(150), unique=False) email = db.Column(db.String(50), unique=False) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)