@@ -0,0 +1,40 @@
|
||||
from sqlalchemy import *
|
||||
from sqlalchemy.orm import declarative_base,sessionmaker
|
||||
from datetime import datetime
|
||||
from core.database import Base, engine
|
||||
|
||||
# 为了符合三范式,就业表只保存 student_id,不保存学生姓名和班级名称。查询返回时通过关联 students 和 classes 带出学生姓名、班级名称。
|
||||
|
||||
class Employment(Base):
|
||||
__tablename__ = "employments" # 实际数据库的表名字
|
||||
id = Column(BigInteger, primary_key=True # 主键
|
||||
, autoincrement=True # 声明是自增主键
|
||||
,comment="就业信息主键id")
|
||||
student_id = Column(BigInteger, ForeignKey("students.id") # 外键 -> students.id
|
||||
, nullable=False # 不允许为null
|
||||
,comment="关联学生id")
|
||||
employment_status = Column(String(50)
|
||||
, default="not_started"
|
||||
,comment="就业状态:not_started/job_hunting/offered/employed")
|
||||
employment_open_date = Column(Date
|
||||
,comment="就业开放时间")
|
||||
offer_date = Column(Date
|
||||
,comment="offer下发时间")
|
||||
company_name = Column(String(100)
|
||||
, comment="就业公司名称")
|
||||
salary = Column(DECIMAL(10, 2) # 高精度浮点数薪资,最多 10 位数字,小数占 2 位
|
||||
, comment="就业薪资")
|
||||
remark = Column(String(255)
|
||||
,default=None
|
||||
, comment="备注信息")
|
||||
created_at = Column(DateTime
|
||||
, default=datetime.now
|
||||
, comment="创建时间")
|
||||
updated_at = Column(DateTime
|
||||
, default=datetime.now
|
||||
, onupdate=datetime.now
|
||||
,comment="更新时间")
|
||||
is_deleted = Column(SmallInteger
|
||||
,default=0
|
||||
,comment="逻辑删除:0正常,1删除")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user