Merge remote-tracking branch 'origin/main' into zhutt
# Conflicts: # main.py
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
from sqlalchemy import * # 导入sqlalchemy模块下所有的类,以便下面创建班级表模型和声明表的字段
|
||||
from datetime import datetime # 导入datetime模块下的datetime类
|
||||
from core.database import Base # 从core软件包下的database模块导入Base
|
||||
from sqlalchemy.dialects.mysql import TINYINT
|
||||
|
||||
class Classes( Base ): # 在python里的名字
|
||||
__tablename__ = 'class_info_detail' # 在数据库中表的名字
|
||||
@@ -22,7 +23,7 @@ class Classes( Base ): # 在python里的名字
|
||||
)
|
||||
# ————创建班级"开课时间"的字段名————
|
||||
start_date = Column( DATE # 声明是字段数据类型是日期
|
||||
, nullable = True # 声明是'可为空'
|
||||
, nullable = False # 开课时间必填
|
||||
)
|
||||
# ————创建班级"结课时间"的字段名————
|
||||
end_date = Column( DATE # 声明是字段数据类型是'日期'
|
||||
@@ -31,20 +32,23 @@ class Classes( Base ): # 在python里的名字
|
||||
# ————创建班级"创建时间"的字段名————
|
||||
created_at = Column( DATETIME # 声明是字段数据类型是"日期时间"
|
||||
, default=datetime.now # 声明是创建的默认值就是"当前时间"
|
||||
, server_default=text("CURRENT_TIMESTAMP")
|
||||
, nullable = False # 声明是"非空"
|
||||
)
|
||||
# ————创建班级"更新时间"的字段名————
|
||||
update_at = Column( DATETIME # 声明是字段数据类型是"日期时间"
|
||||
, default=datetime.now #声明是第一次更新的时间就是第一次创建的时间一致
|
||||
, onupdate=datetime.now # 声明"最后修改的时间"
|
||||
, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
|
||||
, nullable = False # 声明是"非空"
|
||||
)
|
||||
# ————创建班级"备注信息"的字段名————
|
||||
remark = Column( String(100) # 声明是字段数据类型是"字符串"
|
||||
remark = Column( String(255) # 声明是字段数据类型是"字符串"
|
||||
, nullable = True # 声明是"可以为空"
|
||||
)
|
||||
# ————创建班级"逻辑删除"的字段名————
|
||||
is_deleted = Column( INTEGER # 声明是字段数据类型是"数字"
|
||||
is_deleted = Column( TINYINT # 逻辑删除标记
|
||||
, default = 0 # 声明默认值是"0,未删除"
|
||||
, server_default = text("0")
|
||||
, nullable = False # 声明是"非空"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
from sqlalchemy import *
|
||||
from sqlalchemy.dialects.mysql import TINYINT
|
||||
from datetime import datetime
|
||||
from core.database import Base
|
||||
class Consultant(Base):
|
||||
@@ -8,10 +9,10 @@ class Consultant(Base):
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, comment="主键")
|
||||
consultant_no = Column(String(50), unique=True, nullable=False, comment="顾问编号")
|
||||
consultant_name = Column(String(50), nullable=False, comment="顾问姓名")
|
||||
phone = Column(String(11), nullable=True, comment="联系电话")
|
||||
phone = Column(String(20), nullable=True, comment="联系电话")
|
||||
email = Column(String(100), nullable=True, comment="邮箱")
|
||||
remark = Column(String(255), nullable=True, comment="备注")
|
||||
|
||||
created_at = Column(DateTime, default=datetime.now, nullable=False, comment="创建时间")
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, nullable=False, comment="更新时间")
|
||||
is_deleted = Column(Integer, default=0, nullable=False, comment="逻辑删除:0正常,1删除")
|
||||
created_at = Column(DateTime, default=datetime.now, server_default=text("CURRENT_TIMESTAMP"), nullable=False, comment="创建时间")
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"), nullable=False, comment="更新时间")
|
||||
is_deleted = Column(TINYINT, default=0, server_default=text("0"), nullable=False, comment="逻辑删除:0正常,1删除")
|
||||
|
||||
+2
-1
@@ -10,7 +10,8 @@ class Student(Base):
|
||||
, comment = '学生编号,自增主键'
|
||||
)
|
||||
student_no = Column(VARCHAR(50)
|
||||
, unique = True)
|
||||
,nullable = True
|
||||
,unique = True)
|
||||
student_name = Column(VARCHAR(50))
|
||||
class_id = Column(Integer
|
||||
,ForeignKey('class_info_detail.id')
|
||||
|
||||
Reference in New Issue
Block a user