完善统计模块及模型

This commit is contained in:
2026-09-21 19:55:51 +08:00
parent 89a10c598b
commit 946d428c8b
11 changed files with 428 additions and 59 deletions
+21 -12
View File
@@ -1,27 +1,30 @@
from core.database import Base
from sqlalchemy import *
from sqlalchemy.dialects.mysql import TINYINT
from datetime import datetime
class Student(Base):
__tablename__ = 'student_info_detail'
__tablename__ = 'students'
id = Column(Integer
, primary_key=True
, autoincrement=True
, comment = '学生编号,自增主键'
)
student_no = Column(VARCHAR(50)
, unique = True)
student_name = Column(VARCHAR(50))
, unique = True
, nullable = False)
student_name = Column(VARCHAR(50), nullable=False)
class_id = Column(Integer
,foreign_key = 'class_info_detail.id'
,ForeignKey('classes.id')
,nullable = False
)#外键约束 班级表的主键id,存在这个班级,学生表才可以输入
consultant_id = Column(Integer
,ForeignKey('consultants.id')
,nullable = True
,foreign_key = 'consultant_info_detail.id'
)#外键约束 顾问表的主键id,存在这个顾问,才可以写入,允许为空
native_place = Column(VARCHAR(100)
,nullable = True)
graduation_school = Column(VARCHAR(100)
graduate_school = Column(VARCHAR(100)
,nullable = True)
major = Column(VARCHAR(100)
,nullable = True)
@@ -35,11 +38,17 @@ class Student(Base):
,nullable = False)
gender = Column(VARCHAR(10)
,nullable = False)
create_at = Column(DATETIME
,default = datetime.now)
update_at = Column(DATETIME
created_at = Column(DATETIME
,default = datetime.now
,onupdate = datetime.now)
is_deleted = Column(Integer
,default = 0)#逻辑删除,默认为0,为1则表示已删除
,server_default = text("CURRENT_TIMESTAMP")
,nullable = False)
updated_at = Column(DATETIME
,default = datetime.now
,onupdate = datetime.now
,server_default = text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
,nullable = False)
is_deleted = Column(TINYINT
,default = 0
,server_default = text("0")
,nullable = False)#逻辑删除,默认为0,为1则表示已删除