Departments
Summary
A department is a tenant-scoped Employee Service aggregate identified by a generated identifier and a code unique within the tenant. It may reference a parent department and a head employee.
Audience
- Tenant administrators and implementation partners
- Support engineers, developers, QA engineers, and architects
Purpose
Departments group employees and optionally organize designations. They are organization master data, not Identity security groups.
Architecture
Business concepts
- Identity and scope — Implemented: name and code are required; code is normalized and unique per tenant.
- Parent-child hierarchy — Implemented with limits: an optional parent reference exists and self-parenting is rejected on update. Recursive cycle detection and hierarchy-depth rules were not confirmed.
- Department head — Implemented reference: an optional head-employee reference exists. Compatibility models use a user-based head reference, so ownership is transitional.
- Employee assignment — Implemented: employees can reference a department; assignment requires an active department.
- Create and update — Implemented: tenant-scoped services create and update department metadata and active state with audit records.
- Deactivate/delete — Transitional: extracted Employee Service “delete” deactivates and rejects deactivation while active employees are assigned. The monolith physically deletes only when no users or labor records reference the department.
- Department master events — Not implemented: no dedicated DepartmentCreated/Updated integration contracts were confirmed. Employee department changes do emit an employee-scoped event.
Technical implementation
Employee Service repositories and query filters enforce tenant-scoped access. Listings may exclude inactive departments. Compatibility responses include assignment counts and preserve legacy UI field shapes. A parent reference is stored, but complete tree-integrity validation is Requires confirmation.
Source References
microservices/src/employee-service/Domain/Organization/Organization.csmicroservices/src/employee-service/Application/Organization/Organization.csmicroservices/src/employee-service/Application/Validators/EmployeeCommandValidators.csmicroservices/src/employee-service/Infrastructure/Persistence.csmicroservices/src/employee-service/Infrastructure/EmployeeDbContext.csmicroservices/src/employee-service/Api/EmployeeCompatibilityEndpoints.csControllers/DepartmentsController.csModels/Department.cs
Related Articles
See Also
Keywords
- Department hierarchy
- Department head
- Department assignment
Revision Information
- Status: Draft
- Last reviewed: 2026-07-15
- Review cycle: Quarterly