"""系统使用统计 VO。"""

from __future__ import annotations

from pydantic import BaseModel, Field


class UsageStatsOverviewVO(BaseModel):
    loginUserCount: int = Field(0)
    loginCount: int = Field(0)
    activeUserCount: int = Field(0)
    uploadDocumentCount: int = Field(0)
    uploadAttachmentCount: int = Field(0)
    auditRunCount: int = Field(0)
    auditCompletedCount: int = Field(0)
    auditFailedCount: int = Field(0)
    lastUpdatedAt: str = Field("")


class UsageStatsTrendItemVO(BaseModel):
    label: str = Field("")
    value: int = Field(0)


class UsageStatsTrendVO(BaseModel):
    granularity: str = Field("day")
    metric: str = Field("audit")
    items: list[UsageStatsTrendItemVO] = Field(default_factory=list)


class UsageStatsUserItemVO(BaseModel):
    userId: int = Field(...)
    username: str = Field("")
    nickName: str = Field("")
    departmentName: str | None = Field(None)
    area: str | None = Field(None)
    loginCount: int = Field(0)
    uploadDocumentCount: int = Field(0)
    uploadAttachmentCount: int = Field(0)
    auditRunCount: int = Field(0)
    auditCompletedCount: int = Field(0)
    auditFailedCount: int = Field(0)
    lastLoginTime: str | None = Field(None)


class UsageStatsUserPageVO(BaseModel):
    total: int = Field(0)
    page: int = Field(1)
    pageSize: int = Field(20)
    items: list[UsageStatsUserItemVO] = Field(default_factory=list)


class UsageStatsDepartmentItemVO(BaseModel):
    departmentName: str = Field("")
    userCount: int = Field(0)
    loginUserCount: int = Field(0)
    loginCount: int = Field(0)
    uploadDocumentCount: int = Field(0)
    uploadAttachmentCount: int = Field(0)
    auditRunCount: int = Field(0)
    auditCompletedCount: int = Field(0)
    auditFailedCount: int = Field(0)


class UsageStatsDepartmentPageVO(BaseModel):
    total: int = Field(0)
    page: int = Field(1)
    pageSize: int = Field(20)
    items: list[UsageStatsDepartmentItemVO] = Field(default_factory=list)


class UsageStatsAreaItemVO(BaseModel):
    area: str = Field("")
    loginUserCount: int = Field(0)
    loginCount: int = Field(0)
    uploadDocumentCount: int = Field(0)
    uploadAttachmentCount: int = Field(0)
    auditRunCount: int = Field(0)
    auditCompletedCount: int = Field(0)
    auditFailedCount: int = Field(0)


class UsageStatsAreaPageVO(BaseModel):
    total: int = Field(0)
    page: int = Field(1)
    pageSize: int = Field(20)
    areaScope: str = Field("user")
    items: list[UsageStatsAreaItemVO] = Field(default_factory=list)


class UsageStatsDetailItemVO(BaseModel):
    time: str = Field("")
    dataType: str = Field("")
    userId: int | None = Field(None)
    username: str = Field("")
    nickName: str = Field("")
    departmentName: str | None = Field(None)
    area: str | None = Field(None)
    documentId: int | None = Field(None)
    documentName: str | None = Field(None)
    documentTypeId: int | None = Field(None)
    documentTypeName: str | None = Field(None)
    entryModuleId: int | None = Field(None)
    entryModuleName: str | None = Field(None)
    status: str | None = Field(None)
    extra: dict = Field(default_factory=dict)


class UsageStatsDetailPageVO(BaseModel):
    total: int = Field(0)
    page: int = Field(1)
    pageSize: int = Field(20)
    items: list[UsageStatsDetailItemVO] = Field(default_factory=list)
