30 lines
960 B
Python
30 lines
960 B
Python
from sqlalchemy import ( Column,Date,DateTime,
|
|||
|
|
ForeignKey,
|
||
|
|
Integer,
|
||
|
|
SmallInteger,
|
||
|
|
String,
|
||
|
|
func,
|
||
|
|
)
|
||
|
|
from sqlalchemy.orm import relationship
|
||
|
|
|
||
|
|
from database import Base
|
||
|
|
|
||
|
|
|
||
|
|
class Advisor(Base):
|
||
|
|
|
||
|
|
__tablename__ = "advisor"
|
||
|
|
|
||
|
|
id = Column(Integer, primary_key=True, autoincrement=True, comment="顾问编号")
|
||
|
|
name = Column(String(50), nullable=False, index=True, comment="顾问姓名")
|
||
|
|
gender = Column(String(8), comment="性别")
|
||
|
|
phone = Column(String(20), index=True, comment="手机号")
|
||
|
|
email = Column(String(64), comment="邮箱")
|
||
|
|
region = Column(String(64), comment="负责区域/招生渠道")
|
||
|
|
is_deleted = Column(SmallInteger,nullable=False, default=0,server_default="0",
|
||
|
|
index=True,comment="1=已删除",)
|
||
|
|
|
||
|
|
students = relationship("Student",primaryjoin="and_(Advisor.id == Student.advisor_id, Student.is_deleted == 0)",
|
||
|
|
foreign_keys="Student.advisor_id",viewonly=True,lazy="selectin",)
|
||
|
|
|
||
|
|
|