update mooc/schemas/core.py.

Signed-off-by: 雨过 <zxx1747362695@qq.com>
This commit is contained in:
雨过 2025-01-05 16:37:34 +00:00 committed by Gitee
parent 1fb0680418
commit a9d6331483
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -1,365 +1,320 @@
from pydantic import BaseModel from sqlalchemy import Column, Integer, String, Text, BigInt,CHAR,ForeignKey, UnsignedInteger, TinyInt, Decimal
from typing import Optional from sqlalchemy.dialects.mysql import BIGINT
from mooc.db.database import Base
# 数据模型基类: ImsCoreCacheBase用于描述基础字段的类型、用途和注意点
class ImsCoreCacheBase(BaseModel): # CoreAttachment模型用于映射数据库表ims_core_attachment
acid: str # 对应数据库表中主键acid class CoreAttachment(Base):
__tablename__ = "ims_core_attachment"
class ImsCoreCacheCreate(ImsCoreCacheBase): acid = Column(UnsignedInteger, primary_key=True) # 将id改为acid
""" uniacid = Column(UnsignedInteger, nullable=False)
用于创建新的ims_core_cache记录: uid = Column(UnsignedInteger, nullable=False)
- 继承自ImsCoreCacheBase不额外添加字段 filename = Column(String(255), nullable=False)
- 仅表示此Schema专用于'创建'场景 attachment = Column(String(255), nullable=False)
""" type = Column(UnsignedInteger, nullable=False)
pass createtime = Column(UnsignedInteger, nullable=False)
module_upload_dir = Column(String(100), nullable=False)
group_id = Column(Integer, nullable=False)
class ImsCoreCacheUpdate(BaseModel): displayorder = Column(Integer, nullable=False)
"""
用于更新已有ims_core_cache记录: class Config:
- 只包含可选字段未在此处的内容将保持不变 from_attributes = True
- 注意: exclude_unset=True 可以避免更新空值
""" # CoreCache模型用于映射数据库表ims_core_cache
acid: Optional[str] class CoreCache(Base):
__tablename__ = "ims_core_cache"
class ImsCoreCache(ImsCoreCacheBase): acid = Column(String(100), primary_key=True) # 将key视为一种特殊的主键这里用acid替代原本的命名方式
""" value = Column(Text, nullable=False)
表示完整的ims_core_cache记录: class Config:
- acid: 数据库主键ID from_attributes = True
- 包含所有字段的最终模型ORM转换时使用
"""
# CoreCron模型用于映射数据库表ims_core_cron
class Config: class CoreCron(Base):
orm_mode = True __tablename__ = "ims_core_cron"
acid = Column(UnsignedInteger, primary_key=True) # 将id改为acid
cloudid = Column(UnsignedInteger, nullable=False)
# 数据模型基类: ImsCoreCronBase用于描述基础字段的类型、用途和注意点 module = Column(String(50), nullable=False)
class ImsCoreCronBase(BaseModel): uniacid = Column(UnsignedInteger, nullable=False)
acid: int type = Column(TinyInt, nullable=False)
createtime: Optional[int] name = Column(String(50), nullable=False)
nextruntime: Optional[int] filename = Column(String(50), nullable=False)
uniacid: Optional[int] lastruntime = Column(UnsignedInteger, nullable=False)
cloudid: Optional[int] nextruntime = Column(UnsignedInteger, nullable=False)
weekday = Column(TinyInt, nullable=False)
day = Column(TinyInt, nullable=False)
class ImsCoreCronCreate(ImsCoreCronBase): hour = Column(TinyInt, nullable=False)
""" minute = Column(String(255), nullable=False)
用于创建新的ims_core_cron记录: extra = Column(String(5000), nullable=False)
- 继承自ImsCoreCronBase不额外添加字段 status = Column(TinyInt, nullable=False)
- 仅表示此Schema专用于'创建'场景 createtime = Column(UnsignedInteger, nullable=False)
"""
pass class Config:
from_attributes = True
class ImsCoreCronUpdate(BaseModel):
"""
用于更新已有ims_core_cron记录:
- 只包含可选字段未在此处的内容将保持不变 # CoreCronRecord模型用于映射数据库表ims_core_cron_record
- 注意: exclude_unset=True 可以避免更新空值 class CoreCronRecord(Base):
""" __tablename__ = "ims_core_cron_record"
acid: Optional[int] acid = Column(UnsignedInteger, primary_key=True) # 将id改为acid
createtime: Optional[int] uniacid = Column(UnsignedInteger, nullable=False)
nextruntime: Optional[int] module = Column(String(50), nullable=False)
uniacid: Optional[int] type = Column(String(50), nullable=False)
cloudid: Optional[int] tid = Column(UnsignedInteger, nullable=False)
note = Column(String(500), nullable=False)
tag = Column(String(5000), nullable=False)
class ImsCoreCron(ImsCoreCronBase): createtime = Column(UnsignedInteger, nullable=False)
"""
表示完整的ims_core_cron记录: class Config:
- acid: 数据库主键ID from_attributes = True
- 包含所有字段的最终模型ORM转换时使用
"""
# CoreJob模型用于映射数据库表ims_core_job
class Config: class CoreJob(Base):
orm_mode = True __tablename__ = "ims_core_job"
acid = Column(Integer, primary_key=True) # 将id改为acid
type = Column(TinyInt, nullable=False)
# 数据模型基类: ImsCoreCronRecordBase用于描述基础字段的类型、用途和注意点 uniacid = Column(Integer, nullable=False)
class ImsCoreCronRecordBase(BaseModel): payload = Column(String(255), nullable=False)
acid: int status = Column(TinyInt, nullable=False)
uniacid: Optional[int] title = Column(String(22), nullable=False)
tid: Optional[int] handled = Column(Integer, nullable=False)
module: Optional[str] total = Column(Integer, nullable=False)
createtime = Column(Integer, nullable=False)
updatetime = Column(Integer, nullable=False)
class ImsCoreCronRecordCreate(ImsCoreCronRecordBase): endtime = Column(Integer, nullable=False)
""" uid = Column(Integer, nullable=False)
用于创建新的ims_core_cron_record记录: isdeleted = Column(TinyInt, nullable=True)
- 继承自ImsCoreCronRecordBase不额外添加字段
- 仅表示此Schema专用于'创建'场景 class Config:
""" from_attributes = True
pass
class ImsCoreCronRecordUpdate(BaseModel): # CoreMenu模型用于映射数据库表ims_core_menu
""" class CoreMenu(Base):
用于更新已有ims_core_cron_record记录: __tablename__ = "ims_core_menu"
- 只包含可选字段未在此处的内容将保持不变 acid = Column(UnsignedInteger, primary_key=True) # 将id改为acid
- 注意: exclude_unset=True 可以避免更新空值 pid = Column(UnsignedInteger, nullable=False)
""" title = Column(String(20), nullable=False)
acid: Optional[int] name = Column(String(20), nullable=False)
uniacid: Optional[int] url = Column(String(255), nullable=False)
tid: Optional[int] append_title = Column(String(30), nullable=False)
module: Optional[str] append_url = Column(String(255), nullable=False)
displayorder = Column(TinyInt, nullable=False)
type = Column(String(15), nullable=False)
class ImsCoreCronRecord(ImsCoreCronRecordBase): is_display = Column(TinyInt, nullable=False)
""" is_system = Column(TinyInt, nullable=False)
表示完整的ims_core_cron_record记录: permission_name = Column(String(50), nullable=False)
- acid: 数据库主键ID group_name = Column(String(30), nullable=False)
- 包含所有字段的最终模型ORM转换时使用 icon = Column(String(20), nullable=False)
"""
class Config:
class Config: from_attributes = True
orm_mode = True
# CoreMenuShortcut模型用于映射数据库表ims_core_menu_shortcut
# 数据模型基类: ImsCoreJobBase用于描述基础字段的类型、用途和注意点 class CoreMenuShortcut(Base):
class ImsCoreJobBase(BaseModel): __tablename__ = "ims_core_menu_shortcut"
acid: int acid = Column(Integer, primary_key=True) # 将id改为acid
uid = Column(Integer, nullable=False)
uniacid = Column(Integer, nullable=False)
class ImsCoreJobCreate(ImsCoreJobBase): modulename = Column(String(100), nullable=False)
""" displayorder = Column(Integer, nullable=False)
用于创建新的ims_core_job记录: position = Column(String(100), nullable=False)
- 继承自ImsCoreJobBase不额外添加字段 updatetime = Column(Integer, nullable=False)
- 仅表示此Schema专用于'创建'场景
""" class Config:
pass from_attributes = True
class ImsCoreJobUpdate(BaseModel):
""" # CorePaylog模型用于映射数据库表ims_core_paylog
用于更新已有ims_core_job记录: class CorePaylog(Base):
- 只包含可选字段未在此处的内容将保持不变 __tablename__ = "ims_core_paylog"
- 注意: exclude_unset=True 可以避免更新空值 acid = Column(BigInt, primary_key=True, nullable=False) # 将plid改为acid注意类型为BigInt
""" type = Column(String(20), nullable=False)
acid: Optional[int] uniacid = Column(Integer, nullable=False)
acid_original = Column(Integer, nullable=False) # 原表中还有个acid字段这里为避免混淆改名可按需调整
openid = Column(String(40), nullable=False)
class ImsCoreJob(ImsCoreJobBase): uniontid = Column(String(64), nullable=False)
""" tid = Column(String(128), nullable=False)
表示完整的ims_core_job记录: fee = Column(Decimal(10, 2), nullable=False)
- acid: 数据库主键ID status = Column(TinyInt, nullable=False)
- 包含所有字段的最终模型ORM转换时使用 module = Column(String(50), nullable=False)
""" tag = Column(String(2000), nullable=False)
is_usecard = Column(TinyInt, nullable=False)
class Config: card_type = Column(TinyInt, nullable=False)
orm_mode = True card_id = Column(String(50), nullable=False)
card_fee = Column(Decimal(10, 2), nullable=False)
encrypt_code = Column(String(100), nullable=False)
# 数据模型基类: ImsCoreMenuBase用于描述基础字段的类型、用途和注意点 is_wish = Column(TinyInt, nullable=False)
class ImsCoreMenuBase(BaseModel):
acid: int class Config:
from_attributes = True
class ImsCoreMenuCreate(ImsCoreMenuBase):
""" # CorePerformance模型用于映射数据库表ims_core_performance
用于创建新的ims_core_menu记录: class CorePerformance(Base):
- 继承自ImsCoreMenuBase不额外添加字段 __tablename__ = "ims_core_performance"
- 仅表示此Schema专用于'创建'场景 acid = Column(UnsignedInteger, primary_key=True) # 将id改为acid
""" type = Column(TinyInt, nullable=False)
pass runtime = Column(String(10), nullable=False)
runurl = Column(String(512), nullable=False)
runsql = Column(String(512), nullable=False)
class ImsCoreMenuUpdate(BaseModel): createtime = Column(Integer, nullable=False)
"""
用于更新已有ims_core_menu记录: class Config:
- 只包含可选字段未在此处的内容将保持不变 from_attributes = True
- 注意: exclude_unset=True 可以避免更新空值
"""
acid: Optional[int]
# CoreQueue模型用于映射数据库表ims_core_queue
class CoreQueue(Base):
class ImsCoreMenu(ImsCoreMenuBase): __tablename__ = "ims_core_queue"
""" acid = Column(BigInt, primary_key=True) # 将qid改为acid类型对应BigInt
表示完整的ims_core_menu记录: uniacid = Column(UnsignedInteger, nullable=False)
- acid: 数据库主键ID acid_original = Column(UnsignedInteger, nullable=False) # 原表中还有acid字段这里改名避免混淆可按需调整
- 包含所有字段的最终模型ORM转换时使用 message = Column(String(2000), nullable=False)
""" params = Column(String(1000), nullable=False)
keyword = Column(String(1000), nullable=False)
class Config: response = Column(String(2000), nullable=False)
orm_mode = True module = Column(String(50), nullable=False)
type = Column(TinyInt, nullable=False)
dateline = Column(UnsignedInteger, nullable=False)
# 数据模型基类: ImsCoreMenuShortcutBase用于描述基础字段的类型、用途和注意点
class ImsCoreMenuShortcutBase(BaseModel): class Config:
acid: int from_attributes = True
uid: Optional[int]
# CoreRefundlog模型用于映射数据库表ims_core_refundlog
class ImsCoreMenuShortcutCreate(ImsCoreMenuShortcutBase): class CoreRefundlog(Base):
""" __tablename__ = "ims_core_refundlog"
用于创建新的ims_core_menu_shortcut记录: acid = Column(Integer, primary_key=True) # 将id改为acid
- 继承自ImsCoreMenuShortcutBase不额外添加字段 uniacid = Column(Integer, nullable=False)
- 仅表示此Schema专用于'创建'场景 refund_uniontid = Column(String(64), nullable=False)
""" reason = Column(String(80), nullable=False)
pass uniontid = Column(String(64), nullable=False)
fee = Column(Decimal(10, 2), nullable=False)
status = Column(Integer, nullable=False)
class ImsCoreMenuShortcutUpdate(BaseModel): is_wish = Column(TinyInt, nullable=False)
"""
用于更新已有ims_core_menu_shortcut记录: class Config:
- 只包含可选字段未在此处的内容将保持不变 from_attributes = True
- 注意: exclude_unset=True 可以避免更新空值
"""
acid: Optional[int] # CoreResource模型用于映射数据库表ims_core_resource
uid: Optional[int] class CoreResource(Base):
__tablename__ = "ims_core_resource"
acid = Column(Integer, primary_key=True) # 将mid改为acid
class ImsCoreMenuShortcut(ImsCoreMenuShortcutBase): uniacid = Column(UnsignedInteger, nullable=False)
""" media_id = Column(String(100), nullable=False)
表示完整的ims_core_menu_shortcut记录: trunk = Column(UnsignedInteger, nullable=False)
- acid: 数据库主键ID type = Column(String(10), nullable=False)
- 包含所有字段的最终模型ORM转换时使用 dateline = Column(UnsignedInteger, nullable=False)
"""
class Config:
class Config: from_attributes = True
orm_mode = True
# 数据模型基类: ImsCorePaylogBase用于描述基础字段的类型、用途和注意点 # CoreQueue模型用于映射数据库表ims_core_queue
class ImsCorePaylogBase(BaseModel): class CoreQueue(Base):
acid: int __tablename__ = "ims_core_queue"
openid: Optional[str] acid = Column(BigInt, primary_key=True) # 将qid改为acid类型对应BigInt
tid: Optional[int] uniacid = Column(UnsignedInteger, nullable=False)
uniacid: Optional[int] acid_original = Column(UnsignedInteger, nullable=False) # 原表中还有acid字段这里改名避免混淆可按需调整
uniontid: Optional[str] message = Column(String(2000), nullable=False)
params = Column(String(1000), nullable=False)
keyword = Column(String(1000), nullable=False)
class ImsCorePaylogCreate(ImsCorePaylogBase): response = Column(String(2000), nullable=False)
""" module = Column(String(50), nullable=False)
用于创建新的ims_core_paylog记录: type = Column(TinyInt, nullable=False)
- 继承自ImsCorePaylogBase不额外添加字段 dateline = Column(UnsignedInteger, nullable=False)
- 仅表示此Schema专用于'创建'场景
""" class Config:
pass from_attributes = True
class ImsCorePaylogUpdate(BaseModel): # CoreRefundlog模型用于映射数据库表ims_core_refundlog
""" class CoreRefundlog(Base):
用于更新已有ims_core_paylog记录: __tablename__ = "ims_core_refundlog"
- 只包含可选字段未在此处的内容将保持不变 acid = Column(Integer, primary_key=True) # 将id改为acid
- 注意: exclude_unset=True 可以避免更新空值 uniacid = Column(Integer, nullable=False)
""" refund_uniontid = Column(String(64), nullable=False)
acid: Optional[int] reason = Column(String(80), nullable=False)
openid: Optional[str] uniontid = Column(String(64), nullable=False)
tid: Optional[int] fee = Column(Decimal(10, 2), nullable=False)
uniacid: Optional[int] status = Column(Integer, nullable=False)
uniontid: Optional[str] is_wish = Column(TinyInt, nullable=False)
class Config:
class ImsCorePaylog(ImsCorePaylogBase): from_attributes = True
"""
表示完整的ims_core_paylog记录:
- acid: 数据库主键ID
- 包含所有字段的最终模型ORM转换时使用 # CoreResource模型用于映射数据库表ims_core_resource
""" class CoreResource(Base):
__tablename__ = "ims_core_resource"
class Config: acid = Column(Integer, primary_key=True) # 将mid改为acid
orm_mode = True uniacid = Column(UnsignedInteger, nullable=False)
media_id = Column(String(100), nullable=False)
trunk = Column(UnsignedInteger, nullable=False)
# 数据模型基类: ImsCorePerformanceBase用于描述基础字段的类型、用途和注意点 type = Column(String(10), nullable=False)
class ImsCorePerformanceBase(BaseModel): dateline = Column(UnsignedInteger, nullable=False)
acid: int
class Config:
from_attributes = True
class ImsCorePerformanceCreate(ImsCorePerformanceBase):
"""
用于创建新的ims_core_performance记录:
- 继承自ImsCorePerformanceBase不额外添加字段
- 仅表示此Schema专用于'创建'场景 # CoreResource模型用于映射数据库表ims_core_resource
""" class CoreResource(Base):
pass __tablename__ = "ims_core_resource"
acid = Column(Integer, primary_key=True) # 将mid改为acid
uniacid = Column(UnsignedInteger, nullable=False)
class ImsCorePerformanceUpdate(BaseModel): media_id = Column(String(100), nullable=False)
""" trunk = Column(UnsignedInteger, nullable=False)
用于更新已有ims_core_performance记录: type = Column(String(10), nullable=False)
- 只包含可选字段未在此处的内容将保持不变 dateline = Column(UnsignedInteger, nullable=False)
- 注意: exclude_unset=True 可以避免更新空值
""" class Config:
acid: Optional[int] from_attributes = True
# CoreSendsmsLog模型用于映射数据库表ims_core_sendsms_log
class ImsCorePerformance(ImsCorePerformanceBase): class CoreSendsmsLog(Base):
""" __tablename__ = "ims_core_sendsms_log"
表示完整的ims_core_performance记录: acid = Column(UnsignedInteger, primary_key=True) # 将id改为acid
- acid: 数据库主键ID uniacid = Column(UnsignedInteger, nullable=False)
- 包含所有字段的最终模型ORM转换时使用 mobile = Column(String(11), nullable=False)
""" content = Column(String(255), nullable=False)
result = Column(String(255), nullable=False)
class Config: createtime = Column(UnsignedInteger, nullable=False)
orm_mode = True
class Config:
from_attributes = True
# 数据模型基类: ImsCoreQueueBase用于描述基础字段的类型、用途和注意点
class ImsCoreQueueBase(BaseModel):
acid: int # CoreSessions模型用于映射数据库表ims_core_sessions
uniacid: Optional[int] class CoreSessions(Base):
module: Optional[str] __tablename__ = "ims_core_sessions"
dateline: Optional[int] acid = Column(CHAR(32), primary_key=True) # 将sid作为主键对应类型为CHAR(32)
uniacid = Column(UnsignedInteger, nullable=False)
openid = Column(String(50), nullable=False)
class ImsCoreQueueCreate(ImsCoreQueueBase): data = Column(String(2000), nullable=False)
""" expiretime = Column(UnsignedInteger, nullable=False)
用于创建新的ims_core_queue记录:
- 继承自ImsCoreQueueBase不额外添加字段 class Config:
- 仅表示此Schema专用于'创建'场景 from_attributes = True
""" # CoreSettings模型用于映射数据库表ims_core_settings
pass class CoreSettings(Base):
__tablename__ = "ims_core_settings"
acid = Column(String(255), primary_key=True) # 将主键key改为acid
class ImsCoreQueueUpdate(BaseModel):
""" class Config:
用于更新已有ims_core_queue记录: from_attributes = True
- 只包含可选字段未在此处的内容将保持不变
- 注意: exclude_unset=True 可以避免更新空值
"""
acid: Optional[int]
uniacid: Optional[int]
module: Optional[str]
dateline: Optional[int]
class ImsCoreQueue(ImsCoreQueueBase):
"""
表示完整的ims_core_queue记录:
- acid: 数据库主键ID
- 包含所有字段的最终模型ORM转换时使用
"""
class Config:
orm_mode = True
# 数据模型基类: ImsCoreRefundlogBase用于描述基础字段的类型、用途和注意点
class ImsCoreRefundlogBase(BaseModel):
acid: int
refund_uniontid: Optional[str]
uniontid: Optional[str]
class ImsCoreRefundlogCreate(ImsCoreRefundlogBase):
"""
用于创建新的ims_core_refundlog记录:
- 继承自ImsCoreRefundlogBase不额外添加字段
- 仅表示此Schema专用于'创建'场景
"""
pass
class ImsCoreRefundlogUpdate(BaseModel):
"""
用于更新已有ims_core_refundlog记录:
- 只包含可选字段未在此处的内容将保持不变
- 注意: exclude_unset=True 可以避免更新空值
"""
acid: Optional[int]
refund_uniontid: Optional[str]
uniontid: Optional[str]