Entities and departments API
Implementation: front/src/services/api/entityService.ts. Entity and department interfaces in that module document fields expected by the frontend, not the complete backend schema.
Entities
GET /entities
- Called from: Department Management and Create/Edit User workflows.
- Response expected:
ApiResponse<Entity[]>. - Example:
GET {VITE_API_BASE_URL}/entities
GET /entities/:id
- Called from:
getEntityById; Edit Lease resolves the selected entity. - Path:
idstring. - Response expected:
ApiResponse<Entity>. - Example:
GET {VITE_API_BASE_URL}/entities/{id}
POST /entities
- Called from: Department Management entity create.
- Body:
EntityCreateData(name, optionaldescription). - Response expected:
ApiResponse<Entity>. - Example:
POST {VITE_API_BASE_URL}/entitieswithEntityCreateData.
PUT /entities/:id
- Called from: Department Management entity edit.
- Path:
idstring. - Body:
EntityUpdateData(optionalname,description). - Response expected:
ApiResponse<Entity>. - Example:
PUT {VITE_API_BASE_URL}/entities/{id}with partial entity data.
DELETE /entities/:id
- Called from: Department Management delete entity.
- Path:
idstring. - Response expected:
ApiResponse<{ success: boolean }>. - Example:
DELETE {VITE_API_BASE_URL}/entities/{id}
Departments
GET /departments
- Called from: Department Management; service supports optional entity filter.
- Query: optional
entityId. - Response expected:
ApiResponse<Department[]>. - Example:
GET {VITE_API_BASE_URL}/departments?entityId={entityId}
GET /departments/entity/:entityId
- Called from: Create/Edit User entity selection.
- Path:
entityIdstring. - Response expected:
ApiResponse<Department[]>. - Example:
GET {VITE_API_BASE_URL}/departments/entity/{entityId}
GET /departments/:id
- Called from: Edit Lease related-data resolution.
- Path:
idstring. - Response expected:
ApiResponse<Department>. - Example:
GET {VITE_API_BASE_URL}/departments/{id}
POST /departments
- Called from: Department Management department create.
- Body:
DepartmentCreateData(name,entityId, optionaldescription). - Response expected:
ApiResponse<Department>. - Example:
POST {VITE_API_BASE_URL}/departmentswithDepartmentCreateData.
PUT /departments/:id
- Called from: Department Management department edit.
- Path:
idstring. - Body:
DepartmentUpdateData(optionalname,description). - Response expected:
ApiResponse<Department>. - Example:
PUT {VITE_API_BASE_URL}/departments/{id}with partial department data.
DELETE /departments/:id
- Called from: Department Management delete department.
- Path:
idstring. - Response expected:
ApiResponse<{ success: boolean }>. - Example:
DELETE {VITE_API_BASE_URL}/departments/{id}
For every endpoint, service methods log and rethrow failures. The shared client handles 401 centrally; exact other status codes and server authorization are not available from frontend source.