83 lines
2.3 KiB
Python
83 lines
2.3 KiB
Python
# students_model处理数据库模型
|
|
import datetime
|
|
|
|
from students.databases import *
|
|
from datetime import datetime
|
|
from sqlalchemy.dialects.mysql import DATETIME
|
|
from students.schema.students_request import SexEnum
|
|
|
|
class Students(Base):
|
|
__tablename__ = 'students'
|
|
id = Column(Integer
|
|
, primary_key=True
|
|
, autoincrement=True
|
|
, comment='学生ID,自增主键'
|
|
)
|
|
num = Column(String(50)
|
|
, nullable=False
|
|
, unique=True
|
|
, comment='学生编号'
|
|
)
|
|
|
|
name = Column(String(50)
|
|
, comment='学生姓名'
|
|
, nullable=False )
|
|
|
|
age = Column(Integer
|
|
, comment='年龄'
|
|
, nullable=False)
|
|
|
|
sex = Column(Enum(SexEnum)
|
|
, comment='性别'
|
|
, nullable=False)
|
|
|
|
home_Place = Column(String(50)
|
|
, comment='籍贯')
|
|
|
|
college = Column(String(50)
|
|
, comment='毕业院校')
|
|
|
|
specialty = Column(String(50)
|
|
, comment='专业')
|
|
|
|
enrollment_time = Column(DATETIME
|
|
, comment='入学时间')
|
|
|
|
graduate_time = Column(DATETIME
|
|
, comment='毕业时间')
|
|
|
|
education = Column(String(50)
|
|
, comment='学历')
|
|
|
|
# 外键字段
|
|
class_id = Column(Integer
|
|
, comment='学生班级'
|
|
, nullable=False )
|
|
|
|
adnisor_id = Column(Integer
|
|
, comment='顾问ID')
|
|
|
|
# 额外字段
|
|
phone = Column(String(11)
|
|
, comment='学生手机号'
|
|
, nullable=False
|
|
, unique=True )
|
|
|
|
# 通用字段
|
|
create_date = Column(DATETIME(fsp=6)
|
|
, default=datetime.now
|
|
, comment='创建时间' )
|
|
|
|
update_date = Column(DATETIME(fsp=6)
|
|
, default=datetime.now
|
|
, comment='更新时间' )
|
|
|
|
is_deleted = Column(INTEGER
|
|
, default=False
|
|
, comment='是否删除:0-正常,1-已删除' )
|
|
|
|
deleted_date = Column(DATETIME(fsp=6)
|
|
, default=None
|
|
, comment='删除时间' )
|
|
|