# ============================================================================= # 企微IT智能服务台 — 设备清单模型 # ============================================================================= # 说明:存储从联软/火绒导出的设备清单,用于员工IT健康信息匹配 # ============================================================================= import uuid from datetime import datetime from typing import Optional from sqlalchemy import DateTime, String, Text from sqlalchemy.orm import Mapped, mapped_column from app.database import Base class DeviceInventory(Base): """设备清单模型 — 对应 device_inventory 表。 存储从联软/火绒导出的设备清单,包含: - 计算机名 - IP 地址 - MAC 地址 - 员工账号(用于匹配) - 数据来源(联软/火绒) Attributes: id: 记录唯一标识 computer_name: 计算机名 ip_address: IP 地址 mac_address: MAC 地址 employee_account: 员工账号(用于匹配) employee_name: 员工姓名 department: 部门 source: 数据来源(lianruan/huorong) asset_tag: 资产编号 created_at: 导入时间 updated_at: 更新时间 """ __tablename__ = "device_inventory" # 主键 id: Mapped[str] = mapped_column( String(36), primary_key=True, default=lambda: str(uuid.uuid4()), ) # 设备信息 computer_name: Mapped[str] = mapped_column(String(255), default="") ip_address: Mapped[str] = mapped_column(String(64), default="") mac_address: Mapped[str] = mapped_column(String(64), default="") # 员工信息 employee_account: Mapped[str] = mapped_column(String(128), default="") employee_name: Mapped[str] = mapped_column(String(128), default="") department: Mapped[str] = mapped_column(String(255), default="") # 元数据 source: Mapped[str] = mapped_column(String(32), default="") # lianruan / huorong asset_tag: Mapped[str] = mapped_column(String(64), default="") # 资产编号 # 时间戳 created_at: Mapped[datetime] = mapped_column( DateTime, default=datetime.now, ) updated_at: Mapped[datetime] = mapped_column( DateTime, default=datetime.now, onupdate=datetime.now, )