feat: add employee management, backend health check, and UI improvements
This commit is contained in:
@@ -1,24 +1,102 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import date, datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, EmailStr
|
||||
from pydantic import BaseModel, ConfigDict, EmailStr, Field
|
||||
|
||||
|
||||
class EmployeeCreate(BaseModel):
|
||||
employee_no: str
|
||||
class EmployeeHistoryRead(BaseModel):
|
||||
action: str
|
||||
owner: str
|
||||
time: str
|
||||
occurredAt: str
|
||||
|
||||
|
||||
class EmployeeOrganizationRead(BaseModel):
|
||||
id: str
|
||||
code: str
|
||||
name: str
|
||||
department: str
|
||||
email: EmailStr
|
||||
unitType: str
|
||||
costCenter: str | None = None
|
||||
location: str | None = None
|
||||
managerName: str | None = None
|
||||
|
||||
|
||||
class EmployeeRoleOptionRead(BaseModel):
|
||||
id: str
|
||||
code: str
|
||||
label: str
|
||||
desc: str
|
||||
permissions: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
class EmployeeStatusSummaryRead(BaseModel):
|
||||
id: str
|
||||
label: str
|
||||
count: int
|
||||
|
||||
|
||||
class EmployeeMetaRead(BaseModel):
|
||||
totalEmployees: int
|
||||
statusSummary: list[EmployeeStatusSummaryRead]
|
||||
roleOptions: list[EmployeeRoleOptionRead]
|
||||
|
||||
|
||||
class EmployeeRead(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
model_config = ConfigDict(from_attributes=False)
|
||||
|
||||
id: str
|
||||
employee_no: str
|
||||
avatar: str
|
||||
name: str
|
||||
employeeNo: str
|
||||
department: str
|
||||
position: str
|
||||
grade: str
|
||||
manager: str
|
||||
financeOwner: str
|
||||
roles: list[str] = Field(default_factory=list)
|
||||
roleCodes: list[str] = Field(default_factory=list)
|
||||
status: str
|
||||
statusTone: str
|
||||
gender: str | None = None
|
||||
age: int | None = None
|
||||
birthDate: str | None = None
|
||||
email: EmailStr
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
phone: str | None = None
|
||||
joinDate: str | None = None
|
||||
location: str | None = None
|
||||
costCenter: str | None = None
|
||||
updatedAt: str | None = None
|
||||
lastSync: str | None = None
|
||||
syncState: str
|
||||
spotlight: bool = False
|
||||
permissions: list[str] = Field(default_factory=list)
|
||||
history: list[EmployeeHistoryRead] = Field(default_factory=list)
|
||||
organization: EmployeeOrganizationRead | None = None
|
||||
|
||||
|
||||
class EmployeeCreate(BaseModel):
|
||||
employee_no: str = Field(min_length=1, max_length=50)
|
||||
name: str = Field(min_length=1, max_length=100)
|
||||
email: EmailStr
|
||||
gender: str | None = Field(default=None, max_length=20)
|
||||
birth_date: str | None = None
|
||||
phone: str | None = Field(default=None, max_length=30)
|
||||
join_date: str | None = None
|
||||
location: str | None = Field(default=None, max_length=100)
|
||||
position: str = Field(default="员工", max_length=100)
|
||||
grade: str = Field(default="P3", max_length=20)
|
||||
cost_center: str | None = Field(default=None, max_length=50)
|
||||
finance_owner_name: str | None = Field(default=None, max_length=100)
|
||||
employment_status: str = Field(default="在职", max_length=30)
|
||||
sync_state: str = Field(default="已同步", max_length=30)
|
||||
spotlight: bool = False
|
||||
organization_unit_code: str | None = Field(default=None, max_length=50)
|
||||
manager_employee_no: str | None = Field(default=None, max_length=50)
|
||||
role_codes: list[str] = Field(default_factory=lambda: ["user"])
|
||||
|
||||
def parsed_birth_date(self) -> date | None:
|
||||
return datetime.strptime(self.birth_date, "%Y-%m-%d").date() if self.birth_date else None
|
||||
|
||||
def parsed_join_date(self) -> date | None:
|
||||
return datetime.strptime(self.join_date, "%Y-%m-%d").date() if self.join_date else None
|
||||
|
||||
Reference in New Issue
Block a user