上传文件至「model」
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from sqlalchemy import *
|
||||
from datetime import datetime
|
||||
from database import Base
|
||||
class Class(Base):
|
||||
'''
|
||||
班级信息数据库类模型
|
||||
'''
|
||||
__tablename__ = "s_class"
|
||||
id = Column(Integer,
|
||||
primary_key=True,
|
||||
autoincrement=True,
|
||||
index=True,#为该列创建索引,加快查询速度
|
||||
comment='班级主键id')
|
||||
class_id = Column(String(32),
|
||||
nullable=False,
|
||||
index=True,
|
||||
unique=True,
|
||||
comment='班级编号')
|
||||
class_name = Column(String(32),
|
||||
nullable=False,
|
||||
index=True,
|
||||
comment='班级名字')
|
||||
ht_id = Column(Integer,nullable=False,
|
||||
comment='班主任ID')
|
||||
t_id = Column(Integer,nullable=False,
|
||||
comment='授课老师ID')
|
||||
start_time = Column(DATETIME,default=datetime.now,comment='开课时间')
|
||||
update_time = Column(DATETIME,default=datetime.now,onupdate=datetime.now)
|
||||
is_deleted = Column(Integer,default=0,index=True)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
from sqlalchemy import *
|
||||
from datetime import datetime
|
||||
from database import *
|
||||
class Employment(Base):
|
||||
__tablename__ = 's_employment'
|
||||
id = Column(Integer
|
||||
, primary_key=True
|
||||
, autoincrement=True
|
||||
, comment='编号,自增主键')
|
||||
stu_id = Column(String(20),
|
||||
ForeignKey('s_student.stu_id')
|
||||
, unique=True
|
||||
, nullable=True
|
||||
, comment='学生学号,唯一')
|
||||
class_name = Column(String(32))
|
||||
company = Column(String(100))
|
||||
salary = Column(Integer
|
||||
, default=0)
|
||||
open_date = Column(DATETIME
|
||||
, default=datetime.now())
|
||||
offer_date = Column(DATETIME
|
||||
, default=datetime.now())
|
||||
work_date = Column(DATETIME
|
||||
, default=datetime.now()
|
||||
, onupdate=datetime.now)
|
||||
is_deleted = Column(Integer
|
||||
, default=0
|
||||
)
|
||||
@@ -0,0 +1,40 @@
|
||||
from sqlalchemy import *
|
||||
from datetime import datetime
|
||||
from database import *
|
||||
|
||||
class Scores(Base):
|
||||
__tablename__ = 's_scores'
|
||||
id=Column( Integer
|
||||
, primary_key=True
|
||||
,autoincrement=True
|
||||
,comment='成绩编号'
|
||||
)
|
||||
stu_id=Column(String(50)
|
||||
, ForeignKey('s_student.stu_id')
|
||||
,comment='学生编号'
|
||||
, nullable=False
|
||||
)
|
||||
exam_seq=Column(Integer
|
||||
|
||||
, nullable=True
|
||||
,comment='考试序次'
|
||||
)
|
||||
score=Column(Float
|
||||
,comment='分数'
|
||||
)
|
||||
create_date=Column(DATETIME
|
||||
, default=datetime.now
|
||||
,comment='创建时间'
|
||||
)
|
||||
update_date=Column(DATETIME
|
||||
, default=datetime.now
|
||||
,onupdate=datetime.now
|
||||
,comment='更新时间'
|
||||
)
|
||||
deleted=Column(Integer
|
||||
,default=1
|
||||
, comment='软删除'
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from database import Base
|
||||
from sqlalchemy import Column,Integer,String,Date,Boolean, Enum as SQLEnum,ForeignKey
|
||||
from enum import Enum
|
||||
class Sex(Enum):
|
||||
m= "男"
|
||||
w= "女"
|
||||
class Student(Base):
|
||||
__tablename__ = 's_student'
|
||||
id=Column(Integer, primary_key=True,autoincrement=True,comment="数据库主键id")
|
||||
stu_id=Column(String(50),unique=True,nullable=False,comment='学生id')
|
||||
class_id=Column(String(50),ForeignKey("s_class.class_id"),
|
||||
comment='学生班级')
|
||||
stu_name=Column(String(30),nullable=False,comment='学生姓名')
|
||||
native_place = Column(String(100), comment="籍贯")
|
||||
graduate_school = Column(String(100), comment="毕业院校")
|
||||
major = Column(String(50), comment="专业")
|
||||
enroll_date = Column(Date, comment="入学时间")
|
||||
graduate_date = Column(Date, comment="毕业时间")
|
||||
education = Column(String(30), comment="学历")
|
||||
advisor_no = Column(String(50), comment="顾问编号")
|
||||
age = Column(Integer, comment="年龄")
|
||||
gender = Column(
|
||||
SQLEnum(Sex, values_callable=lambda x: [e.value for e in x]),
|
||||
comment="性别")
|
||||
is_deleted = Column(Boolean, default=False, comment="逻辑删除标记:False未删除,True已删除")
|
||||
@@ -0,0 +1,23 @@
|
||||
from sqlalchemy import Integer, String, Column, DateTime, Enum as SQLEnum, Boolean, ForeignKey
|
||||
from database import *
|
||||
|
||||
from enum import Enum
|
||||
from datetime import datetime
|
||||
|
||||
class Sex(Enum):
|
||||
w = '女'
|
||||
m = '男'
|
||||
|
||||
class Teacher(Base):
|
||||
__tablename__ = 's_teacher'
|
||||
id = Column(Integer, primary_key=True,autoincrement=True)
|
||||
t_id =Column(Integer,unique=True,nullable=False)
|
||||
t_name = Column(String(100),comment='教师名称')
|
||||
t_age = Column(Integer,comment='年龄')
|
||||
t_phone = Column(String(20),unique=True,comment='电话')
|
||||
t_sex = Column(SQLEnum(Sex,values_callable=lambda x: [e.value for e in x]),comment='性别')
|
||||
class_id = Column(String(100),ForeignKey('s_class.class_id'),comment='带班编号')
|
||||
create_time = Column(DateTime,default=datetime.now,comment='创建时间')
|
||||
update_time = Column(DateTime,default=datetime.now,onupdate=datetime.now,comment='更新时间')
|
||||
is_deleted = Column(Boolean,default=False,comment='判断是否删除')
|
||||
|
||||
Reference in New Issue
Block a user