24 lines
1015 B
Python
24 lines
1015 B
Python
from sqlalchemy import Integer, String, Column, DateTime, Enum as SQLEnum, Boolean, ForeignKey
|
|
from database import *
|
|
|
|
from enum import Enum
|
|
from datetime import datetime
|
|
|
|
class Sex(Enum):
|
|
w = '女'
|
|
m = '男'
|
|
|
|
class Teacher(Base):
|
|
__tablename__ = 's_teacher'
|
|
id = Column(Integer, primary_key=True,autoincrement=True)
|
|
t_id =Column(Integer,unique=True,nullable=False)
|
|
t_name = Column(String(100),comment='教师名称')
|
|
t_age = Column(Integer,comment='年龄')
|
|
t_phone = Column(String(20),unique=True,comment='电话')
|
|
t_sex = Column(SQLEnum(Sex,values_callable=lambda x: [e.value for e in x]),comment='性别')
|
|
class_id = Column(String(100),ForeignKey('s_class.class_id'),comment='带班编号')
|
|
create_time = Column(DateTime,default=datetime.now,comment='创建时间')
|
|
update_time = Column(DateTime,default=datetime.now,onupdate=datetime.now,comment='更新时间')
|
|
is_deleted = Column(Boolean,default=False,comment='判断是否删除')
|
|
|