# ============================================================================= # 企微IT智能服务台 — 终端-会议室绑定模型 # ============================================================================= # 说明:存储小鱼易联终端SN与企微会议室ID的映射关系 # 这是企微API不提供的关系数据,需要在本地维护 # ============================================================================= from datetime import datetime from sqlalchemy import Boolean, DateTime, Integer, String, func from sqlalchemy.orm import Mapped, mapped_column from app.database import Base class TerminalRoomBinding(Base): """终端-会议室绑定模型。 存储小鱼易联终端SN与企微会议室ID的映射关系。 一个终端只能绑定一个会议室(terminal_sn 唯一索引), 一个会议室可被多个终端绑定(meetingroom_id 普通索引)。 Attributes: id: 自增主键 terminal_sn: 小鱼易联终端序列号(唯一) terminal_name: 终端名称(如"18F东区大屏") meetingroom_id: 企微会议室ID meetingroom_name: 会议室名称(冗余字段,便于终端页面展示) location: 位置描述(如"18F东区") is_active: 是否启用 created_at: 创建时间 updated_at: 更新时间 """ __tablename__ = "terminal_room_binding" # 自增主键 id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) # 小鱼易联终端序列号(唯一索引,一个终端只能绑定一个会议室) terminal_sn: Mapped[str] = mapped_column(String(64), unique=True, index=True, nullable=False) # 终端名称(便于管理后台展示) terminal_name: Mapped[str] = mapped_column(String(100), nullable=False, default="") # 企微会议室ID(普通索引,一个会议室可被多个终端绑定) meetingroom_id: Mapped[int] = mapped_column(Integer, index=True, nullable=False) # 会议室名称(冗余字段,便于终端页面直接展示,无需额外查询企微API) meetingroom_name: Mapped[str] = mapped_column(String(100), nullable=False, default="") # 位置描述 location: Mapped[str] = mapped_column(String(200), nullable=False, default="") # 是否启用(默认True,管理员可禁用绑定) is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True) # 创建时间(服务器默认当前时间) created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False) # 更新时间(每次更新时自动刷新) updated_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False) def __repr__(self) -> str: """返回模型的可读字符串表示。""" return ( f"" )