Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Date
|
||||
from sqlalchemy.sql import func
|
||||
from database import Base
|
||||
|
||||
class ClsMgmt(Base):
|
||||
"""
|
||||
班级管理表模型
|
||||
对应 MySQL 中的 cls_mgmt 表
|
||||
"""
|
||||
__tablename__ = "cls_mgmt" # 表名
|
||||
|
||||
# 字段定义
|
||||
id = Column(String(15), primary_key=True, nullable=False) # 班级编号,主键,非空
|
||||
cls_start_date= Column(Date, nullable=False) #开课时间
|
||||
head_tea_id =Column(String(15),nullable=False) # 班主任id
|
||||
lecturer_id=Column(String(15),nullable=False) # 主讲老师id
|
||||
is_deleted=Column(Integer,nullable=False)
|
||||
# created_at:创建时间,自动设置为当前时间(服务器时间)
|
||||
# server_default=func.now() 表示由数据库生成默认值
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
# updated_at:更新时间,当记录更新时自动设置为当前时间(由 SQLAlchemy 的 onupdate 触发)
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
@@ -0,0 +1,34 @@
|
||||
# model/users_api.py
|
||||
# 本文件定义 User 表的结构,映射到 MySQL 数据库
|
||||
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Boolean, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from database import Base
|
||||
|
||||
class Stu_score(Base):
|
||||
"""
|
||||
用户表模型
|
||||
对应 MySQL 中的 users 表
|
||||
"""
|
||||
__tablename__ = "stu_score" # 表名
|
||||
|
||||
# 字段定义
|
||||
id = Column(Integer,primary_key=True, nullable=False,autoincrement=True) #
|
||||
# stu_id = Column(String(10),ForeignKey(stu_info.id),nullable=False) #学生id,非空
|
||||
exam_attempt = Column(Integer, nullable=False) # 考试轮次,非空
|
||||
exam_score = Column(Integer, nullable=False,) # 成绩,非空,设置范围
|
||||
score_level=Column(String(10),nullable=False) #成绩评级
|
||||
is_deleted=Column(Boolean,default=False,nullable=False) #软删除: 0-正常 1-已删除
|
||||
name = relationship("Stu_info", back_populates="score")
|
||||
|
||||
def __repr__(self):
|
||||
return (f"<Stu_info(id={self.stu_id}, exam_attempt='{self.exam_attempt}'"
|
||||
f"exam_score={self.exam_score}, score_level='{self.score_level}'"
|
||||
f"is_deleted={self.is_deleted})>")
|
||||
# created_at:创建时间,自动设置为当前时间(服务器时间)
|
||||
# server_default=func.now() 表示由数据库生成默认值
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
# updated_at:更新时间,当记录更新时自动设置为当前时间(由 SQLAlchemy 的 onupdate 触发)
|
||||
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|
||||
@@ -0,0 +1,17 @@
|
||||
#教师建表语句
|
||||
from sqlalchemy import Column, String, Integer
|
||||
|
||||
from database import Base
|
||||
|
||||
|
||||
class Teacher(Base):
|
||||
__tablename__ = "ted_info" # 表名
|
||||
|
||||
# 字段定义
|
||||
id = Column(Integer, primary_key=True, index=True) # 主键,索引
|
||||
name = Column(String(20),nullable=False) # 用户名,非空
|
||||
phone = Column(String(20),unique=True,nullable=False) # 电话,唯一,非空
|
||||
type = Column(String(20), nullable=False) # 教师职位,非空
|
||||
is_deleted = Column(Integer, default=0) # 逻辑删除(软删除),0是未删除,1是删除,默认为0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user