"""反馈相关响应 schema。请求是 multipart 表单(content/contact/images),在路由里直接校验。"""
from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field


class FeedbackOut(BaseModel):
    model_config = ConfigDict(from_attributes=True)

    id: int
    status: str
    created_at: datetime


class FeedbackQrConfigOut(BaseModel):
    """反馈页二维码卡配置(运营后台可配)。App 反馈页据此渲染整张「加群二维码」卡。

    image_url 是相对 /media 路径(客户端按自己的 BASE_URL 拼绝对地址),为空 → 客户端走本地兜底。
    """

    enabled: bool
    image_url: str | None = None
    title: str
    group_name: str
    subtitle: str


class FeedbackRecordOut(BaseModel):
    id: int
    content: str
    # 比价反馈的问题场景(找错商品/优惠不对…);普通反馈为 None
    scene: str | None = None
    images: list[str] = Field(default_factory=list)
    status: str
    reject_reason: str | None = None
    reward_coins: int | None = None
    # 运营给用户的回复留言(用户端可见,采纳/未采纳都可能有)
    admin_reply: str | None = None
    created_at: datetime


class FeedbackRecordCountsOut(BaseModel):
    all: int = 0
    pending: int = 0
    adopted: int = 0
    rejected: int = 0


class FeedbackRecordsOut(BaseModel):
    records: list[FeedbackRecordOut]
    counts: FeedbackRecordCountsOut

