A comprehensive Spring Boot REST API for managing workforce tasks, priorities, and team collaboration.
- ✅ Create, read, update, and delete tasks
- ✅ Assign tasks to staff members
- ✅ Track task status (ACTIVE, COMPLETED, CANCELLED)
- ✅ Set and modify task priorities (HIGH, MEDIUM, LOW)
- Task Re-assignment Fix: When reassigning tasks by customer reference, old tasks are properly cancelled
- Cancelled Task Filtering: Cancelled tasks are excluded from all task listing endpoints
-
Smart Daily Task View: Enhanced date-based filtering that shows:
- All active tasks that started within the date range
- All active tasks that started before the range but are still open
-
Task Priority Management:
- Set priority when creating tasks
- Update task priority after creation
- Filter tasks by priority level
-
Activity History & Comments:
- Automatic activity logging for all task changes
- User comments on tasks
- Complete chronological history for each task
POST /api/tasks- Create a new taskGET /api/tasks- Get all active tasksGET /api/tasks/{id}- Get task details with full historyPUT /api/tasks/{id}/status- Update task statusDELETE /api/tasks/{id}- Delete a task
GET /api/tasks/staff/{staffId}- Get tasks for a specific staff memberPOST /api/tasks/assign-by-ref/{customerRef}- Reassign task by customer reference
GET /api/tasks/date-range?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD- Smart date filteringGET /api/tasks/today- Get today's relevant tasksGET /api/tasks/priority/{priority}- Filter by priority (HIGH/MEDIUM/LOW)PUT /api/tasks/{id}/priority- Update task priority
POST /api/tasks/{id}/comments- Add comment to task- Task details endpoint includes full activity history and comments
- Java 17
- Spring Boot 3.0.4
- Gradle for build management
- Lombok for reducing boilerplate code
- MapStruct for object mapping
- In-memory storage using Java collections
src/main/java/com/company/workforcemgmt/
├── WorkforcemgmtApplication.java
├── controller/
│ └── TaskController.java
├── service/
│ └── TaskService.java
├── model/
│ ├── Task.java
│ ├── Staff.java
│ ├── Priority.java
│ ├── Status.java
│ ├── ActivityLog.java
│ └── Comment.java
├── dto/
│ ├── TaskDto.java
│ ├── CreateTaskRequest.java
│ ├── UpdatePriorityRequest.java
│ ├── AddCommentRequest.java
│ └── AssignTaskRequest.java
└── mapper/
└── TaskMapper.java
-
Prerequisites: Java 17 and Gradle installed
-
Clone the repository:
git clone https://github.com/1234-ad/workforce-management-api.git cd workforce-management-api -
Build and run:
./gradlew bootRun
-
Access the API: http://localhost:8080/api/tasks
curl -X POST http://localhost:8080/api/tasks \
-H "Content-Type: application/json" \
-H "X-User-ID: manager1" \
-d '{
"title": "Complete customer onboarding",
"description": "Onboard new customer ABC Corp",
"startDate": "2025-08-05",
"dueDate": "2025-08-08",
"assignedStaffId": "staff1",
"assignedStaffName": "John Doe",
"priority": "HIGH",
"customerRef": "ABC-001"
}'curl "http://localhost:8080/api/tasks/date-range?startDate=2025-08-05&endDate=2025-08-05"curl -X PUT http://localhost:8080/api/tasks/{taskId}/priority \
-H "Content-Type: application/json" \
-H "X-User-ID: manager1" \
-d '{"priority": "HIGH"}'curl -X POST http://localhost:8080/api/tasks/{taskId}/comments \
-H "Content-Type: application/json" \
-d '{
"content": "Task is progressing well",
"userId": "staff1",
"userName": "John Doe"
}'- Task Reassignment: The
assignTaskByRefmethod now properly cancels the old task before creating a new one - Cancelled Task Filtering: All task listing methods filter out cancelled tasks using
task.getStatus() != Status.CANCELLED
The enhanced date filtering logic includes:
- Tasks that started within the specified date range
- Active tasks that started before the range but are still open and incomplete
Every significant action is automatically logged:
- Task creation, status changes, priority updates
- Task assignments and reassignments
- Comment additions
Uses in-memory Java collections for simplicity:
Map<String, Task>for task storage- Automatic UUID generation for unique IDs
- Sample data initialization for testing
The application includes sample data for immediate testing. You can:
- View existing tasks:
GET /api/tasks - Test the smart date filtering with today's date
- Add comments and see activity history
- Test task reassignment functionality
- Filter tasks by priority levels
- Database integration (PostgreSQL/MySQL)
- User authentication and authorization
- Real-time notifications
- Task templates and recurring tasks
- Advanced reporting and analytics