This commit is contained in:
z_xl
2026-09-21 20:16:09 +08:00
commit fe44708fa6
91 changed files with 4530 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
from model import wl_student_model
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
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"
adv_id = Column(Integer, primary_key=True, autoincrement=True, comment="顾问编号")
adv_name = Column(String(50), nullable=False, index=True, comment="顾问姓名")
adv_gender = Column(String(8), comment="性别")
adv_phone = Column(String(20), index=True, comment="手机号")
adv_email = Column(String(64), comment="邮箱")
adv_region = Column(String(64), comment="负责区域/招生渠道")
is_deleted = Column(SmallInteger,nullable=False, default=0,server_default="0",
index=True,comment="1=已删除",)
#下面的内容临时注释,在main导入时,SQLAlchemy 在配置映射时就会报错,错误大概是:ArgumentError: Could not locate any relevant foreign key columns for primary join condition ...
# students = relationship("Student",primaryjoin="and_(Advisor.id == stu_id, Student.is_deleted == 0)",
# foreign_keys="stu_id",viewonly=True,lazy="selectin",)
+14
View File
@@ -0,0 +1,14 @@
from sqlalchemy import Column, Integer, Date, String
from sqlalchemy.orm import relationship
from database import Base
class Class_(Base):
__tablename__ = "class_info"
class_id = Column(Integer, primary_key=True, autoincrement=True, comment="班级编号")
start_time = Column(Date, comment="开课时间")
students=relationship("Student", back_populates="class_")
# 逻辑删除标记(0代表正常,1代表已删除)
is_deleted = Column(Integer, default=0, comment="逻辑删除标记")
+23
View File
@@ -0,0 +1,23 @@
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, func
from sqlalchemy.orm import relationship
from database import Base
class Emp(Base):
__tablename__ = "wl_emp"
# 学号做主键,同时做外键指向学生表,长度跟 Student.stu_no 保持一致
stu_no = Column(String(20), ForeignKey('wl_student.stu_no'), primary_key=True)
emp_open_time = Column(DateTime, default="2026-11-30 18:18:18")
offer_time = Column(DateTime, default=func.now())
company_name = Column(String(100), nullable=False)
salary = Column(Integer, nullable=False, default=15000)
student = relationship("Student", back_populates="emp")
# 逻辑删除:0 正常 1 已删除
is_deleted = Column(Integer, default=0, comment='逻辑删除: 0正常 1删除')
def __repr__(self):
return f"<Emp(stu_no={self.stu_no}, company='{self.company_name}')>"
+17
View File
@@ -0,0 +1,17 @@
from sqlalchemy import Column, Integer, Float, ForeignKey, String
from sqlalchemy.orm import relationship
from database import Base
class Score(Base):
__tablename__ = "wl_score"
# 和 wl_emp 一样:学号直接做主键,同时做外键指向学生表的业务学号,
# 不再用内部主键 stu_id。长度跟 Student.stu_no 保持一致。
stu_no = Column(String(20), ForeignKey('wl_student.stu_no'), primary_key=True, comment="学号")
exam_order = Column(Integer, primary_key=True, comment="考核序次")
score = Column(Float, nullable=False, comment="成绩")
student=relationship("Student",back_populates="scores")
+32
View File
@@ -0,0 +1,32 @@
#学生基本信息 周学灵
from database import Base
from sqlalchemy import Column, Integer, String, Date, ForeignKey
from sqlalchemy.orm import relationship
class Student(Base):
__tablename__ = 'wl_student'
# ---------- 内部主键(隐藏,不对外)----------
stu_id = Column(Integer, primary_key=True, autoincrement=True, comment='内部主键')
# ---------- 业务学号(对外,按规则生成)----------
stu_no = Column(String(20), unique=True, nullable=False, index=True, comment='学号')
class_id = Column(Integer, ForeignKey('class_info.class_id'), nullable=True, comment='班级ID')
stu_name = Column(String(30), nullable=True, comment='学生姓名')
native_place = Column(String(50), nullable=True, comment='籍贯')
graduate_school=Column(String(128), nullable=True, comment='毕业学校')
major= Column(String(64), nullable=True, comment='专业')
in_time= Column(Date, nullable=True, comment='入学时间')
out_time= Column(Date, nullable=True, comment='毕业时间')
edu= Column(String(32), nullable=True, comment='学历')
advisor_id = Column(Integer, ForeignKey('advisor.adv_id'), nullable=True, comment='顾问ID')
stu_age = Column(Integer, nullable=True, comment='年龄')
stu_gender = Column(String(8), nullable=True, comment='性别')
class_ = relationship("Class_", back_populates="students")
scores=relationship("Score",back_populates="student")
emp = relationship("Emp", back_populates="student")
# advisor = relationship("Advisor", back_populates="students")
is_deleted = Column(Integer, default=0, comment='逻辑删除: 0正常 1删除')
def __repr__(self):
return f"<Student(id={self.stu_id}, name='{self.stu_name}')>"
+17
View File
@@ -0,0 +1,17 @@
from sqlalchemy import String, Column, ForeignKey, Integer
from database import Base
class Teacher(Base):
__tablename__ = 'wl_teacher'
t_id = Column(Integer, primary_key=True, autoincrement=True)
t_no = Column(String(20), unique=True, nullable=False)
t_name = Column(String(50), nullable=False)
t_phone = Column(String(20), unique=True, nullable=True)
t_email = Column(String(20), unique=False)
#创建老师时必须指定一个存在的班级
class_id = Column(Integer, ForeignKey("class_info.class_id"), nullable=False)
role = Column(String(50), nullable=False)
is_deleted = Column(Integer, default=0)