Update code in endpoints/api/v1/endpoint.post.py

This commit is contained in:
Backend IM Bot 2025-03-19 09:40:56 +00:00
parent aecc5dbaee
commit 5891d59a13

View File

@ -1,49 +1,49 @@
from fastapi import APIRouter, Depends, HTTPException
from core.database import fake_users_db
import uuid
from pydantic import BaseModel, EmailStr
from pydantic import BaseModel
router = APIRouter()
class CookingCommunityRegistration(BaseModel):
username: str
email: EmailStr
class CompanyRegistration(BaseModel):
company_name: str
user_name: str
email: str
password: str
cooking_experience: str
favorite_cuisine: str
role: str = "employee"
@router.post("/api/v1/endpoint")
async def register_cooking_community(
registration: CookingCommunityRegistration
):
"""Register new user for cooking community"""
if registration.username in fake_users_db:
@router.post("/register/company")
async def register_company_user(registration: CompanyRegistration):
"""Register a new user in a company"""
if registration.user_name in fake_users_db:
raise HTTPException(status_code=400, detail="Username already exists")
user_id = str(uuid.uuid4())
fake_users_db[registration.username] = {
company_id = str(uuid.uuid4())
fake_users_db[registration.user_name] = {
"id": user_id,
"company_id": company_id,
"company_name": registration.company_name,
"email": registration.email,
"password": registration.password,
"cooking_experience": registration.cooking_experience,
"favorite_cuisine": registration.favorite_cuisine,
"disabled": False,
"role": "community_member"
"role": registration.role,
"disabled": False
}
return {
"message": "Successfully registered in cooking community",
"message": "Company user registered successfully",
"user_id": user_id,
"username": registration.username,
"company_id": company_id,
"username": registration.user_name,
"next_steps": [
"Verify your email",
"Complete your cooking profile",
"Join cooking discussion groups",
"Share your favorite recipe"
"Verify company email",
"Complete company profile",
"Invite team members"
],
"features": {
"recipe_sharing": True,
"community_chat": True,
"cooking_tips_access": True
"max_team_members": 10,
"storage_limit": "5GB",
"trial_period_days": 30
}
}