# -*- coding: utf-8 -*- """ 管理端 — 注册体系 Pydantic Schema。 覆盖:租户列表、店铺列表、简写ID 管理、店铺同步。 需求: A2.1, A2.2, A2.4, A2.5 """ from __future__ import annotations from datetime import datetime from app.schemas.base import CamelModel # ── 租户 ────────────────────────────────────────────────── class TenantItem(CamelModel): """租户列表项(含连接器名称)。""" id: int tenant_id: int tenant_name: str | None = None connector_name: str is_active: bool # ── 店铺 ────────────────────────────────────────────────── class SiteItem(CamelModel): """店铺列表项。""" id: int site_id: int site_name: str | None = None site_code: str | None = None site_label: str | None = None is_active: bool # ── 简写ID 管理 ────────────────────────────────────────── class UpdateSiteCodeRequest(CamelModel): """设置/修改店铺简写ID 请求。""" new_code: str # 6 位,3+3 格式,统一大写 class SiteCodeResult(CamelModel): """简写ID 修改结果。""" site_id: int old_code: str | None = None new_code: str history_cleaned: bool # 旧 code 是否被清理 class SiteCodeHistoryItem(CamelModel): """简写ID 变更历史条目。""" id: int site_code: str is_current: bool created_at: datetime retired_at: datetime | None = None # ── 店铺同步 ───────────────────────────────────────────── class SiteSyncResult(CamelModel): """店铺同步结果。""" inserted: int # 新增店铺数 updated: int # 更新店铺数 # ── 测试用:手动创建/删除店铺 ───────────────────────────── class CreateSiteRequest(CamelModel): """手动创建店铺请求(测试功能)。""" tenant_id: int # 所属租户(biz.tenants.tenant_id,上游 BIGINT) site_id: int # 上游系统店铺 ID(BIGINT) site_name: str # 店铺名称 site_code: str | None = None # 可选简写ID(6 位 3+3 格式)