from sqlalchemy.orm import Session

from app.models.employee import Employee
from app.repositories.employee import EmployeeRepository
from app.schemas.employee import EmployeeCreate


class EmployeeService:
    def __init__(self, db: Session) -> None:
        self.repository = EmployeeRepository(db)

    def list_employees(self) -> list[Employee]:
        return self.repository.list()

    def get_employee(self, employee_id: str) -> Employee | None:
        return self.repository.get(employee_id)

    def create_employee(self, payload: EmployeeCreate) -> Employee:
        employee = Employee(**payload.model_dump())
        return self.repository.create(employee)
