初始化前后端学生管理系统项目
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# model/users.py
|
||||
# 本文件定义 User 表的结构,映射到 MySQL 数据库
|
||||
|
||||
from sqlalchemy import Column, Integer, String, Float, ForeignKey,DateTime,Date
|
||||
from sqlalchemy.orm import declarative_base,relationship
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy_fastapi_demo_1.database import Base
|
||||
|
||||
|
||||
# model 类,对应 student表
|
||||
class Student(Base):
|
||||
__tablename__ = "student" #指定表名
|
||||
|
||||
stu_id = Column(Integer, primary_key = True) #主键,学生编号
|
||||
stu_name = Column(String(10),nullable = False) #学生名字,非空约束
|
||||
native_place = Column(String(30),nullable = False) #籍贯,非空
|
||||
graduate_school = Column(String(50),nullable = False) #毕业院校
|
||||
major = Column(String(20),nullable = False) #专业
|
||||
enroll_time = Column(Date, comment = "入学时间",nullable = False)
|
||||
graduate_time = Column(Date, comment = "毕业时间",nullable = False)
|
||||
education = Column(String(10),nullable = False) #学历,非空
|
||||
age = Column(Integer,nullable = False) #年龄
|
||||
gender = Column(String(10),nullable = False) #性别
|
||||
# employment_open_time = Column(Date,nullable = False) #简历开放时间
|
||||
# company_name = Column(String(100),nullable = False) #公司名称
|
||||
# salary = Column(Float,nullable = False) #薪资
|
||||
# # 逻辑删除标记
|
||||
is_deleted = Column(Integer, nullable=False,default=0, comment="0正常;1逻辑删除")
|
||||
# 外键:关联 C_lass 的 id
|
||||
class_id = Column(Integer, ForeignKey("c_lass.class_id"), nullable=False)
|
||||
# 关系属性:关联 Classinfo
|
||||
my_class = relationship("Classinfo", back_populates="students")
|
||||
# 外键:关联Advisor的id
|
||||
advisor_id = Column(Integer,ForeignKey("advisor.advisor_id"),nullable=False)
|
||||
# 关系属性:关联Advisor
|
||||
advisor = relationship("Advisor", back_populates="students")
|
||||
# 关系属性:关联成绩(Score.student 的对端)
|
||||
score = relationship("Score", back_populates="student")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user