"""日报查询 API 的 OpenAPI 文档 serializer（只读，不用于反序列化）。"""

from rest_framework import serializers


class EventSerializer(serializers.Serializer):
    """日报事件明细（news_event 一行）"""
    id = serializers.IntegerField()
    section = serializers.CharField()
    rank = serializers.IntegerField()
    importance = serializers.IntegerField(allow_null=True)
    event_type = serializers.CharField(allow_null=True)
    title = serializers.CharField()
    summary = serializers.CharField(allow_null=True)
    sentiment = serializers.CharField(allow_null=True)
    source = serializers.CharField(allow_null=True)
    url = serializers.CharField(allow_null=True)


class ReportListSerializer(serializers.Serializer):
    """日报列表项（news_report 主表字段）"""
    id = serializers.IntegerField()
    report_date = serializers.CharField()
    report_type = serializers.CharField()
    file_name = serializers.CharField()
    generated_at = serializers.CharField()
    ai_summary = serializers.CharField(allow_null=True)
    stats = serializers.JSONField(allow_null=True)
    created_at = serializers.CharField()


class ReportDetailSerializer(ReportListSerializer):
    """日报详情（主表字段 + 事件列表）"""
    events = EventSerializer(many=True)


class ImportantEventSerializer(serializers.Serializer):
    """跨日报重要事件聚合（news_event JOIN news_report）"""
    report_date = serializers.CharField()
    report_type = serializers.CharField()
    id = serializers.IntegerField()
    section = serializers.CharField()
    rank = serializers.IntegerField()
    importance = serializers.IntegerField(allow_null=True)
    event_type = serializers.CharField(allow_null=True)
    title = serializers.CharField()
    summary = serializers.CharField(allow_null=True)
    sentiment = serializers.CharField(allow_null=True)
    source = serializers.CharField(allow_null=True)
    url = serializers.CharField(allow_null=True)
