alabuga/backend/app/schemas/user.py
danilgryaznev e050bd46ef 1 vers
2025-09-21 19:30:55 +02:00

87 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Pydantic-схемы для пользователей и компетенций."""
from __future__ import annotations
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, EmailStr
from app.models.user import CompetencyCategory, UserRole
class CompetencyBase(BaseModel):
"""Базовое описание компетенции."""
id: int
name: str
description: str
category: CompetencyCategory
class Config:
from_attributes = True
class UserCompetencyRead(BaseModel):
"""Информация о компетенции пользователя."""
competency: CompetencyBase
level: int
class Config:
from_attributes = True
class UserArtifactRead(BaseModel):
"""Полученный артефакт."""
id: int
name: str
description: str
rarity: str
image_url: Optional[str]
class Config:
from_attributes = True
class UserRead(BaseModel):
"""Схема чтения пользователя."""
id: int
email: EmailStr
full_name: str
role: UserRole
xp: int
mana: int
current_rank_id: Optional[int]
is_active: bool
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
class UserProfile(UserRead):
"""Профиль с расширенной информацией."""
competencies: list[UserCompetencyRead]
artifacts: list[UserArtifactRead]
class UserCreate(BaseModel):
"""Создание пользователя (используется для сидов)."""
email: EmailStr
full_name: str
password: str
role: UserRole = UserRole.PILOT
class UserLogin(BaseModel):
"""Данные для входа."""
email: EmailStr
password: str