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