|
|
@@ -6,9 +6,11 @@ from fastapi.responses import JSONResponse
|
|
|
from app.api.v1.module_system.auth.schema import AuthSchema
|
|
|
from app.common.response import ResponseSchema, SuccessResponse
|
|
|
from app.core.dependencies import AuthPermission, get_current_user
|
|
|
+from app.core.exceptions import CustomException
|
|
|
from app.core.logger import log
|
|
|
from app.core.router_class import OperationLogRoute
|
|
|
|
|
|
+from .crud import EmployeeCRUD
|
|
|
from .schema import (
|
|
|
EmployeeCreateOrUpdateSchema,
|
|
|
EmployeeListOutSchema,
|
|
|
@@ -31,13 +33,27 @@ EmployeeRouter = APIRouter(
|
|
|
description="查询员工详情",
|
|
|
)
|
|
|
async def info_employee_controller(
|
|
|
- enterprise_id: Annotated[str, Query(description="企业ID")],
|
|
|
+ enterprise_id: Annotated[Optional[str], Query(description="企业ID")] = None,
|
|
|
auth: Annotated[AuthSchema, Depends(get_current_user)],
|
|
|
employee_id: Annotated[Optional[str], Query(description="员工ID")] = None,
|
|
|
employee_email: Annotated[Optional[str], Query(description="员工邮箱")] = None,
|
|
|
employee_mobile: Annotated[Optional[str], Query(description="员工手机号")] = None,
|
|
|
) -> JSONResponse:
|
|
|
"""查询员工详情"""
|
|
|
+ # 如果没传 enterprise_id,从当前用户推断
|
|
|
+ if not enterprise_id:
|
|
|
+ if not employee_mobile and auth.user and auth.user.mobile:
|
|
|
+ employee_mobile = auth.user.mobile
|
|
|
+
|
|
|
+ if employee_mobile:
|
|
|
+ crud_cache = EmployeeCRUD(auth)
|
|
|
+ employee = await crud_cache.get(employee_mobile=employee_mobile)
|
|
|
+ if employee:
|
|
|
+ enterprise_id = employee.enterprise_id
|
|
|
+
|
|
|
+ if not enterprise_id:
|
|
|
+ raise CustomException(msg="缺少企业ID参数")
|
|
|
+
|
|
|
result = await EmployeeService.info_service(
|
|
|
auth=auth,
|
|
|
employee_id=employee_id,
|