44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from core.database import fake_users_db
|
|
import uuid
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/api/employees")
|
|
async def create_employee(
|
|
name: str,
|
|
position: str,
|
|
email: str,
|
|
department: str = "General"
|
|
):
|
|
"""Create new employee record"""
|
|
employee_id = str(uuid.uuid4())
|
|
|
|
if email in [emp.get("email") for emp in fake_users_db.values()]:
|
|
raise HTTPException(status_code=400, detail="Employee with this email already exists")
|
|
|
|
employee_data = {
|
|
"id": employee_id,
|
|
"name": name,
|
|
"position": position,
|
|
"email": email,
|
|
"department": department,
|
|
"active": True,
|
|
"created_at": "2024-01-01T00:00:00Z" # Demo date
|
|
}
|
|
|
|
fake_users_db[employee_id] = employee_data
|
|
|
|
return {
|
|
"message": "Employee created successfully",
|
|
"data": employee_data,
|
|
"metadata": {
|
|
"created_id": employee_id,
|
|
"department": department,
|
|
"next_steps": [
|
|
"Complete employee onboarding",
|
|
"Assign workspace",
|
|
"Schedule orientation"
|
|
]
|
|
}
|
|
} |