Skip to content

[BE-14] Create DepartmentsModule with CRUD endpoints in opsce module #824

@yusuftomilola

Description

@yusuftomilola

Problem

Departments cannot be managed via the API. Assets cannot be properly assigned to departments, breaking the organizational hierarchy feature.

Proposed Solution

Create backend/src/opsce/departments/departments.controller.ts and backend/src/opsce/departments/departments.service.ts.

Acceptance Criteria

  • POST /api/departments creates a department, optionally with a parentId (ADMIN only)
  • GET /api/departments returns all departments as a flat list with a childCount field
  • GET /api/departments/:id returns a department with its children and asset count
  • PATCH /api/departments/:id updates name, description, or parent (ADMIN only)
  • DELETE /api/departments/:id fails with 409 if the department has active assets
  • CreateDepartmentDto validates name as required string, parentId as optional UUID

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions