feat: Implementar funcionalidades de Tarefas e Saúde
- Criadas APIs para Health (métricas de saúde) * Registrar peso, altura, % gordura, medidas * Histórico completo de medições * Estatísticas e resumo - Criadas APIs para Tasks (tarefas) * Criar, editar e deletar tarefas * Filtros por status e data * Estatísticas detalhadas * Prioridades (baixa, média, alta) - Frontend implementado: * Página Health.tsx - registro de métricas * Página Tasks.tsx - gerenciamento de tarefas * Página Progress.tsx - visualização de progresso * Dashboard integrado com estatísticas reais - Schemas e modelos atualizados - Todas as funcionalidades testadas e operacionais
This commit is contained in:
0
backend/app/schemas/__init__.py
Normal file
0
backend/app/schemas/__init__.py
Normal file
28
backend/app/schemas/admin.py
Normal file
28
backend/app/schemas/admin.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from pydantic import BaseModel, EmailStr
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
|
||||
class UserListResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
email: EmailStr
|
||||
username: str
|
||||
full_name: Optional[str]
|
||||
is_active: bool
|
||||
is_verified: bool
|
||||
is_superadmin: bool
|
||||
created_at: datetime
|
||||
last_login_at: Optional[datetime]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class UserUpdateRequest(BaseModel):
|
||||
email: Optional[EmailStr] = None
|
||||
username: Optional[str] = None
|
||||
full_name: Optional[str] = None
|
||||
is_active: Optional[bool] = None
|
||||
is_verified: Optional[bool] = None
|
||||
|
||||
class PasswordChangeRequest(BaseModel):
|
||||
new_password: str
|
||||
28
backend/app/schemas/habit.py
Normal file
28
backend/app/schemas/habit.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
from datetime import date, time
|
||||
import uuid
|
||||
|
||||
class HabitCreate(BaseModel):
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
frequency_type: str = "daily"
|
||||
target_count: int = 1
|
||||
reminder_time: Optional[time] = None
|
||||
start_date: Optional[date] = None
|
||||
|
||||
class HabitResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
name: str
|
||||
description: Optional[str]
|
||||
frequency_type: str
|
||||
target_count: int
|
||||
is_active: bool
|
||||
start_date: date
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class HabitCompletionCreate(BaseModel):
|
||||
notes: Optional[str] = None
|
||||
quality_rating: Optional[int] = None
|
||||
47
backend/app/schemas/health.py
Normal file
47
backend/app/schemas/health.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
from datetime import date, time
|
||||
from decimal import Decimal
|
||||
import uuid
|
||||
|
||||
class HealthMetricCreate(BaseModel):
|
||||
measurement_date: date
|
||||
measurement_time: Optional[time] = None
|
||||
weight: Optional[Decimal] = None
|
||||
height: Optional[Decimal] = None
|
||||
body_fat_percentage: Optional[Decimal] = None
|
||||
muscle_mass: Optional[Decimal] = None
|
||||
waist: Optional[Decimal] = None
|
||||
chest: Optional[Decimal] = None
|
||||
hips: Optional[Decimal] = None
|
||||
notes: Optional[str] = None
|
||||
|
||||
class HealthMetricResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
measurement_date: date
|
||||
measurement_time: Optional[time]
|
||||
weight: Optional[Decimal]
|
||||
height: Optional[Decimal]
|
||||
body_fat_percentage: Optional[Decimal]
|
||||
muscle_mass: Optional[Decimal]
|
||||
waist: Optional[Decimal]
|
||||
chest: Optional[Decimal]
|
||||
hips: Optional[Decimal]
|
||||
notes: Optional[str]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class HealthMetricUpdate(BaseModel):
|
||||
measurement_date: Optional[date] = None
|
||||
measurement_time: Optional[time] = None
|
||||
weight: Optional[Decimal] = None
|
||||
height: Optional[Decimal] = None
|
||||
body_fat_percentage: Optional[Decimal] = None
|
||||
muscle_mass: Optional[Decimal] = None
|
||||
waist: Optional[Decimal] = None
|
||||
chest: Optional[Decimal] = None
|
||||
hips: Optional[Decimal] = None
|
||||
notes: Optional[str] = None
|
||||
|
||||
39
backend/app/schemas/task.py
Normal file
39
backend/app/schemas/task.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
from datetime import date, time
|
||||
import uuid
|
||||
|
||||
class TaskCreate(BaseModel):
|
||||
title: str
|
||||
description: Optional[str] = None
|
||||
priority: str = "medium" # low, medium, high
|
||||
status: str = "pending" # pending, in_progress, completed
|
||||
due_date: Optional[date] = None
|
||||
due_time: Optional[time] = None
|
||||
category_id: Optional[uuid.UUID] = None
|
||||
|
||||
class TaskResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
user_id: uuid.UUID
|
||||
title: str
|
||||
description: Optional[str]
|
||||
priority: str
|
||||
status: str
|
||||
due_date: Optional[date]
|
||||
due_time: Optional[time]
|
||||
is_archived: bool
|
||||
category_id: Optional[uuid.UUID]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class TaskUpdate(BaseModel):
|
||||
title: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
priority: Optional[str] = None
|
||||
status: Optional[str] = None
|
||||
due_date: Optional[date] = None
|
||||
due_time: Optional[time] = None
|
||||
is_archived: Optional[bool] = None
|
||||
category_id: Optional[uuid.UUID] = None
|
||||
|
||||
53
backend/app/schemas/user.py
Normal file
53
backend/app/schemas/user.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from pydantic import BaseModel, EmailStr, field_validator
|
||||
from typing import Optional
|
||||
import uuid
|
||||
import re
|
||||
|
||||
class UserBase(BaseModel):
|
||||
email: EmailStr
|
||||
username: str
|
||||
full_name: str
|
||||
phone: str
|
||||
|
||||
class UserCreate(UserBase):
|
||||
password: str
|
||||
|
||||
@field_validator('phone')
|
||||
@classmethod
|
||||
def validate_phone(cls, v):
|
||||
# Remove tudo que não é número
|
||||
phone = re.sub(r'\D', '', v)
|
||||
if len(phone) < 10 or len(phone) > 11:
|
||||
raise ValueError('Telefone deve ter 10 ou 11 dígitos')
|
||||
return phone
|
||||
|
||||
@field_validator('full_name')
|
||||
@classmethod
|
||||
def validate_full_name(cls, v):
|
||||
if not v or len(v.strip()) < 3:
|
||||
raise ValueError('Nome completo deve ter no mínimo 3 caracteres')
|
||||
return v.strip()
|
||||
|
||||
class UserLogin(BaseModel):
|
||||
email: EmailStr
|
||||
password: str
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
id: uuid.UUID
|
||||
email: EmailStr
|
||||
username: str
|
||||
full_name: Optional[str]
|
||||
phone: Optional[str]
|
||||
is_superadmin: bool = False
|
||||
is_verified: bool = False
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class Token(BaseModel):
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
user: UserResponse
|
||||
|
||||
class TokenData(BaseModel):
|
||||
sub: str
|
||||
Reference in New Issue
Block a user