From d2d3bf8c21669e178581bcd55ae2f13e713ab9be Mon Sep 17 00:00:00 2001 From: Andrei Duvakin Date: Thu, 6 Feb 2025 21:08:19 +0500 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BA=D1=83=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=20=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/controllers/auth_routes.py | 1 - api/app/controllers/register_routes.py | 22 ++++++++++++++++++++++ api/app/domain/entities/auth.py | 4 ++-- api/app/domain/entities/register.py | 12 ++++++++++++ api/app/main.py | 2 ++ 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 api/app/controllers/register_routes.py create mode 100644 api/app/domain/entities/register.py diff --git a/api/app/controllers/auth_routes.py b/api/app/controllers/auth_routes.py index 49e9a77..44ede53 100644 --- a/api/app/controllers/auth_routes.py +++ b/api/app/controllers/auth_routes.py @@ -42,4 +42,3 @@ async def auth_user( ) return {"access_token": access_token, "refresh_token": None} - diff --git a/api/app/controllers/register_routes.py b/api/app/controllers/register_routes.py new file mode 100644 index 0000000..ef686a8 --- /dev/null +++ b/api/app/controllers/register_routes.py @@ -0,0 +1,22 @@ +from fastapi import APIRouter, Depends, HTTPException, Response, status +from sqlalchemy.ext.asyncio import AsyncSession + +from app.database.session import get_db +from app.domain.entities.register import RegisterEntity +from app.infrastructure.auth_service import AuthService + +router = APIRouter() + + +@router.post( + "/register/", + response_model=dict, + summary="Регистрация пользователя", + description="Производит регистрацию пользователя в системе.", +) +async def register_user( + response: Response, + user_data: RegisterEntity, + db: AsyncSession = Depends(get_db) +): + return {} diff --git a/api/app/domain/entities/auth.py b/api/app/domain/entities/auth.py index fc3dd35..a36b80a 100644 --- a/api/app/domain/entities/auth.py +++ b/api/app/domain/entities/auth.py @@ -2,6 +2,6 @@ from pydantic import BaseModel, Field class AuthEntity(BaseModel): - login: str = Field(..., example="user@example.com") - password: str = Field(..., min_length=5, example="strongpassword") + login: str = Field(..., example='user@example.com') + password: str = Field(..., min_length=5, example='strongpassword') diff --git a/api/app/domain/entities/register.py b/api/app/domain/entities/register.py new file mode 100644 index 0000000..f6a479d --- /dev/null +++ b/api/app/domain/entities/register.py @@ -0,0 +1,12 @@ +from typing import Optional + +from pydantic import BaseModel, Field + + +class RegisterEntity(BaseModel): + first_name: str = Field(..., example='Ivan') + last_name: str = Field(..., example='Ivanov') + patronymic: Optional[str] = Field(None, example='Ivanov') + role_id: int = Field(..., example=1) + login: str = Field(..., example='user@example.com') + password: str = Field(..., min_length=5, example='strongpassword') diff --git a/api/app/main.py b/api/app/main.py index b95ef02..3d8bd08 100644 --- a/api/app/main.py +++ b/api/app/main.py @@ -2,6 +2,7 @@ from fastapi import FastAPI from starlette.middleware.cors import CORSMiddleware from app.controllers.auth_routes import router as auth_router +from app.controllers.register_routes import router as register_router from app.settings import settings @@ -17,6 +18,7 @@ def start_app(): ) api_app.include_router(auth_router, prefix=settings.APP_PREFIX) + api_app.include_router(register_router, prefix=settings.APP_PREFIX) return api_app