Initial commit: Базовая структура сайта
This commit is contained in:
26
backend/app/schemas/__init__.py
Executable file
26
backend/app/schemas/__init__.py
Executable file
@@ -0,0 +1,26 @@
|
||||
from app.schemas.auth import Token, TokenData, LoginRequest
|
||||
from app.schemas.user import UserCreate, UserResponse
|
||||
from app.schemas.summary import SummaryHistogramResponse, SummaryDataset
|
||||
from app.schemas.timeline import TimelineActivityResponse, ActivitySegment
|
||||
from app.schemas.metrics import MetricsAggregateResponse, MetricsRow
|
||||
from app.schemas.leave import LeaveEventCreate, LeaveEventResponse
|
||||
from app.schemas.config import ConfigResponse, ConfigUpdate
|
||||
|
||||
__all__ = [
|
||||
"Token",
|
||||
"TokenData",
|
||||
"LoginRequest",
|
||||
"UserCreate",
|
||||
"UserResponse",
|
||||
"SummaryHistogramResponse",
|
||||
"SummaryDataset",
|
||||
"TimelineActivityResponse",
|
||||
"ActivitySegment",
|
||||
"MetricsAggregateResponse",
|
||||
"MetricsRow",
|
||||
"LeaveEventCreate",
|
||||
"LeaveEventResponse",
|
||||
"ConfigResponse",
|
||||
"ConfigUpdate"
|
||||
]
|
||||
|
||||
21
backend/app/schemas/auth.py
Executable file
21
backend/app/schemas/auth.py
Executable file
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
Схемы для аутентификации
|
||||
"""
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
login: str
|
||||
password: str
|
||||
|
||||
|
||||
class Token(BaseModel):
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
|
||||
|
||||
class TokenData(BaseModel):
|
||||
user_id: Optional[int] = None
|
||||
role: Optional[str] = None
|
||||
|
||||
16
backend/app/schemas/config.py
Executable file
16
backend/app/schemas/config.py
Executable file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
Схемы для конфигурации
|
||||
"""
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class ConfigResponse(BaseModel):
|
||||
key: str
|
||||
value: Optional[str] = None
|
||||
|
||||
|
||||
class ConfigUpdate(BaseModel):
|
||||
key: str
|
||||
value: Optional[str] = None
|
||||
|
||||
27
backend/app/schemas/leave.py
Executable file
27
backend/app/schemas/leave.py
Executable file
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Схемы для модуля Отпуска/Больничные
|
||||
"""
|
||||
from pydantic import BaseModel
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class LeaveEventCreate(BaseModel):
|
||||
user_id: int
|
||||
start_date: date
|
||||
end_date: date
|
||||
leave_type: str # "Отпуск", "Больничный"
|
||||
|
||||
|
||||
class LeaveEventResponse(BaseModel):
|
||||
id: int
|
||||
user_id: int
|
||||
user_login: Optional[str] = None
|
||||
start_date: date
|
||||
end_date: date
|
||||
leave_type: str
|
||||
created_at: Optional[str] = None
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
17
backend/app/schemas/metrics.py
Executable file
17
backend/app/schemas/metrics.py
Executable file
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
Схемы для модуля Метрика
|
||||
"""
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Dict, Any
|
||||
|
||||
|
||||
class MetricsRow(BaseModel):
|
||||
user: str
|
||||
data: Dict[str, Any] # Динамические ключи типа "Q1", "Q2", "W1", "M1" и т.д.
|
||||
|
||||
|
||||
class MetricsAggregateResponse(BaseModel):
|
||||
period_type: str # 'week', 'month', 'quarter', 'year'
|
||||
year: int
|
||||
data: List[MetricsRow]
|
||||
|
||||
17
backend/app/schemas/summary.py
Executable file
17
backend/app/schemas/summary.py
Executable file
@@ -0,0 +1,17 @@
|
||||
"""
|
||||
Схемы для модуля Сводка
|
||||
"""
|
||||
from pydantic import BaseModel
|
||||
from typing import List
|
||||
|
||||
|
||||
class SummaryDataset(BaseModel):
|
||||
label: str
|
||||
color: str
|
||||
data: List[float] # секунды
|
||||
|
||||
|
||||
class SummaryHistogramResponse(BaseModel):
|
||||
labels: List[str] # даты
|
||||
datasets: List[SummaryDataset]
|
||||
|
||||
23
backend/app/schemas/timeline.py
Executable file
23
backend/app/schemas/timeline.py
Executable file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
Схемы для модуля Хронология
|
||||
"""
|
||||
from pydantic import BaseModel
|
||||
from typing import List
|
||||
|
||||
|
||||
class ActivitySegment(BaseModel):
|
||||
type: str # "Active", "Away", "Productive", "Session Locked", "Power Off"
|
||||
start: str # ISO datetime
|
||||
end: str # ISO datetime
|
||||
|
||||
|
||||
class UserActivity(BaseModel):
|
||||
user_id: int
|
||||
display_name: str
|
||||
segments: List[ActivitySegment]
|
||||
|
||||
|
||||
class TimelineActivityResponse(BaseModel):
|
||||
date: str
|
||||
activities: List[UserActivity]
|
||||
|
||||
25
backend/app/schemas/user.py
Executable file
25
backend/app/schemas/user.py
Executable file
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
Схемы для пользователей
|
||||
"""
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class UserCreate(BaseModel):
|
||||
login: str
|
||||
password: str
|
||||
role_id: int
|
||||
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
id: int
|
||||
login: str
|
||||
role_id: int
|
||||
role_name: Optional[str] = None
|
||||
is_active: bool
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
Reference in New Issue
Block a user