-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
64 lines (51 loc) · 1.74 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import uuid
from enum import Enum
from pydantic import BaseModel, EmailStr, Field
class RoleName(str, Enum):
ADMIN = "admin"
HR = "hr"
EMPLOYEE = "employee"
class Role(BaseModel):
id: int | None = Field(
default_factory=lambda: str(uuid.uuid4()),
description="Unique identifier for the role",
examples=["1", "2", "3"],
)
name: RoleName = Field(
..., description="Name of the role", examples=["admin", "hr", "employee"]
)
class Department(BaseModel):
id: int | None = Field(
default_factory=lambda: str(uuid.uuid4()),
description="Unique identifier for the department",
)
name: str = Field(
..., max_length=50, description="Name of the department", examples=["HR"]
)
class Employee(BaseModel):
id: int | None = Field(
default_factory=lambda: str(uuid.uuid4()),
description="Unique identifier for the employee",
)
first_name: str = Field(
..., max_length=30, description="First name of the employee", examples=["John"]
)
last_name: str = Field(
..., max_length=30, description="Last name of the employee", examples=["Doe"]
)
email: EmailStr = Field(
..., description="Email address of the employee", examples=["johndoe@email.com"]
)
department_id: int = Field(
..., description="ID of the department the employee belongs to", examples=["1"]
)
role_id: int = Field(..., description="ID of the employee's role", examples=["1"])
class ErrorResponse(BaseModel):
detail: str = Field(
...,
description="Detailed error message explaining the issue.",
examples=["Invalid input"],
)
class UserCredentials(BaseModel):
username: str
password: str