Files
xs_system/model/statistics_model.py
T
2026-09-22 19:00:51 +08:00

119 lines
7.4 KiB
Python

from sqlalchemy import *
from database import DATETIME,Base,Column,Integer,String
class StudentInfo(Base):
"""学生基本信息表"""
__tablename__ = 'student_info'
student_id = Column(String(20), primary_key=True, comment='学生id')
student_name = Column(String(50), nullable=False, comment='学生姓名')
gender = Column(Enum('男', '女'), nullable=False, comment='性别')
id_card = Column(String(18), nullable=False, comment='身份证号')
birthday = Column(Date, nullable=False, comment='出生日期')
ethnicity = Column(String(20), nullable=False, comment='民族')
region_id = Column(String(20), ForeignKey('region.regio_id'),nullable=False, comment='籍贯编码,连接地区表')
phone = Column(String(11), nullable=False, comment='手机号')
major = Column(String(20), nullable=False, comment='就读专业')
class_id = Column(String(20), nullable=False, comment='班级,连接班级表')
enrollment_date = Column(Date, nullable=False, comment='入学日期')
graduation_date = Column(Date, nullable=False, comment='毕业日期')
student_status = Column(Enum('在读', '休学', '退学', '毕业'), nullable=False, comment='学籍状态')
education_level = Column(Enum('大专', '本科', '硕士研究生', '博士研究生'), nullable=False, comment='学历')
is_deleted = Column(Enum('0', '1'), nullable=False, comment='逻辑删除,0=未删除, 1=已删除')
create_time = Column(Date, nullable=False, comment='创建时间')
update_time = Column(Date, nullable=False, comment='更新时间')
class Region(Base):
"""地区维度表"""
__tablename__ = 'region'
regio_id = Column(String(50), primary_key=True, comment='地区编码')
province = Column(String(50), nullable=False, comment='省/直辖市')
city = Column(String(50), nullable=False, comment='市')
district = Column(String(50), nullable=False, comment='区,县')
is_deleted = Column(Enum('0', '1'), nullable=False, comment='逻辑删除:0=未删除, 1=已删除')
create_time = Column(DATETIME, nullable=False, comment='创建时间')
update_time = Column(DATETIME, nullable=False, comment='更新时间')
class EmploymentInfo(Base):
"""学生就业信息表"""
__tablename__ = 'employment_info'
emp_id = Column(String(50), primary_key=True, comment='就业记录ID')
student_id = Column(String(20), ForeignKey('student_info.student_id'), nullable=False,
comment='学号,连接学生表')
regio_id = Column(String(50), ForeignKey('region.regio_id'), nullable=False, comment='就业地区编码,连接地区表')
job_name = Column(String(50), nullable=False, comment='就业岗位名称')
company_name = Column(String(50), nullable=False, comment='就业公司名称')
salary = Column(Float, nullable=False, comment='就业月薪(元)')
offer_date = Column(Date, nullable=False, comment='offer下发/签约时间')
part_time = Column(Date, nullable=False, comment='就业时间')
resume_open_date = Column(Date, nullable=True, comment='开放简历时间')
employment_status = Column(Enum('1', '2', '3', '4'), nullable=False,
comment='就业状态:1=未就业, 2,=已就业,3=升学, 4=灵活就业')
is_deleted = Column(Enum('0', '1'), nullable=False, comment='逻辑删除:0=未删除, 1=已删除')
create_time = Column(DATETIME, nullable=False, comment='创建时间')
update_time = Column(DATETIME, nullable=False, comment='更新时间')
class StudentScore(Base):
"""学生考核成绩表"""
__tablename__ = 'student_score'
score_id = Column(Integer, primary_key=True, autoincrement=True, comment='成绩记录自增主键')
student_id = Column(String(20), ForeignKey('student_info.student_id'),nullable=False,
comment='学号,连接学生表')
course_id = Column(String(20), ForeignKey('course_info.course_id'),nullable=False, comment='课程编号,连接课程表')
exam_type = Column(Enum('期中', '期末', '月考', '周考', '模拟考'), nullable=False,
comment='考试类型:1=期中, 2=期末, 3=月考, 4=周考,5=模拟考')
score = Column(Float, nullable=True, comment='考试分数0~100,缺考为NULL')
score_level = Column(String(10), nullable=False, comment='成绩等级')
is_pass = Column(Enum('0', '1'), nullable=False, comment='是否及格:1=及格, 0=不及格(可由score>=60判断)')
exam_date = Column(Date, nullable=False, comment='考试日期')
exam_category = Column(Enum('首考', '重考', '补考'), nullable=False, comment='考试分类:1=首考, 2=补考, 3=重考')
is_deleted = Column(Enum('0', '1'), nullable=False, comment='逻辑删除:0=未删除, 1=已删除')
create_time = Column(DATETIME, nullable=False, comment='创建时间')
update_time = Column(DATETIME, nullable=False, comment='更新时间')
class ClassInfo(Base):
"""班级信息表"""
__tablename__ = 'class_info'
class_id = Column(String(50), primary_key=True, comment='班级业务编码')
class_name = Column(String(50), nullable=False, comment='班级名称')
grade_year = Column(Date, nullable=False, comment='入学年级')
status = Column(Enum('1', '2', '3'), nullable=False, comment='班级状态:1=在读 2=已毕业 3=已停用')
tags = Column(String(100), nullable=False, comment='存储多维标签,例如:["重点班", "科技特长", "2026届"]')
is_deleted = Column(Enum('0', '1'), nullable=False, comment='逻辑删除:0=未删除, 1=已删除')
create_time = Column(DATETIME, nullable=False, comment='创建时间')
update_time = Column(DATETIME, nullable=False, comment='更新时间')
class TeacherInfo(Base):
"""教师基本信息表"""
__tablename__ = 'teacher_info'
teacher_id = Column(String(20), primary_key=True, comment='教师编号')
teacher_name = Column(String(20), nullable=False, comment='教师姓名')
gender = Column(Enum('男', '女'), nullable=False, comment='性别')
birthday = Column(Date, nullable=False, comment='出生日期')
region_id = Column(String(50), ForeignKey('region.regio_id'), nullable=False, comment='籍贯地区编码')
email = Column(String(50), nullable=False, comment='邮箱')
phone = Column(String(11), nullable=False, comment='手机号码')
graduation_school = Column(String(50), nullable=False, comment='毕业学校')
teacher_rank = Column(Enum('1', '2', '3', '4'), nullable=False, comment='职称:1=初级, 2=中级, 3=高级, 4=特级')
is_deleted = Column(Enum('0', '1'), nullable=False, comment='逻辑删除:0=未删除, 1=已删除')
create_time = Column(DATETIME, nullable=False, comment='创建时间')
update_time = Column(DATETIME, nullable=False, comment='更新时间')
class CourseInfo(Base):
"""课程基础信息"""
__tablename__ = 'course_info'
course_id = Column(String(30), primary_key=True, comment='课程编号')
course_name = Column(String(30), nullable=False, comment='课程名称')
course_type = Column(Enum('1', '2', '3'), nullable=False, comment='课程类型:1 必修课 2 选修课 3 实训课')
is_deleted = Column(Enum('0', '1'), nullable=False, comment='逻辑删除:0=未删除, 1=已删除')
create_time = Column(DATETIME, nullable=False, comment='创建时间')
update_time = Column(DATETIME, nullable=False, comment='更新时间')