alphah il y a 2 semaines
Parent
commit
2173cc5b39

+ 4 - 4
backend/app/api/v1/module_system/menu/schema.py

@@ -60,10 +60,10 @@ class MenuCreateSchema(BaseModel):
                 except Exception:
                     pass
             # 路由名/路径规范
-            if "route_path" in values and isinstance(values["route_path"], str):
-                rp = values["route_path"]
-                if rp and not rp.startswith("/"):
-                    raise ValueError("路由路径需以 / 开头")
+            # if "route_path" in values and isinstance(values["route_path"], str):
+            #     rp = values["route_path"]
+            #     if rp and not rp.startswith("/"):
+            #         raise ValueError("路由路径需以 / 开头")
             if "component_path" in values and isinstance(values["component_path"], str):
                 cp = values["component_path"]
                 if cp and cp.startswith("/"):

+ 17 - 1
backend/app/plugin/module_payment/employee/controller.py

@@ -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,