Checkpoint Module
4.Checkpoint Module
CheckpointController
Purpose
The CheckpointController manages operations related to checkpoints.
A checkpoint represents an image captured for comparison, which can later be accepted as a baseline.
APIs
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/checkpoints | Create a new checkpoint |
| POST | /api/checkpoints/{checkId}/accept-baseline | Accept checkpoint as baseline |
| POST | /api/checkpoints/{checkId}/json | Insert JSON data |
| POST | /api/checkpoints/{checkId}/assign | Assign checkpoint to user |
| PATCH | /api/checkpoints/{checkId}/review | Update review status |
| PATCH | /api/checkpoints/user/{userId}/last-login | Update last login time |
1. Create Checkpoint
Request
POST /api/checkpoints
| Param | Description |
|---|---|
| nid | Node/Test ID |
| userId | Created user |
| image | Image (byte array) |
Response
101
Returns checkId
2. Accept Checkpoint as Baseline
Request
POST /api/checkpoints/{checkId}/accept-baseline
| Param | Description |
|---|---|
| checkId | Checkpoint ID |
| userId | User performing action |
| regionsJson | Optional region data |
Response
5001
Returns baselineImgId
3. Insert JSON Data
Request
POST /api/checkpoints/{checkId}/json
{
"regions": [
{ "x": 10, "y": 20, "width": 50, "height": 50 }
]
}
Response
2001
Returns jsonId
4. Assign Checkpoint
Request
POST /api/checkpoints/{checkId}/assign
| Param | Description |
|---|---|
| assignedTo | User assigned |
| assignedBy | Assigning user |
| remarks | Optional notes |
Response
{
"id": 2,
"name": "John",
"email": "john@example.com"
}
5. Update Review Status
Request
PATCH /api/checkpoints/{checkId}/review
| Param | Description |
|---|---|
| status | approved / rejected / pending |
| userId | Reviewer |
Response
"Checkpoint review updated successfully"
6. Update Last Login Time
Request
PATCH /api/checkpoints/user/{userId}/last-login
Response
"Last login time updated successfully"
Controller Flow
Client → CheckpointController → CheckpointService → Repository → Database
CheckpointService
Purpose
Handles business logic, validation, and processing of checkpoint operations.
Main Methods
1. InsertCheckpoint(...)
- Creates a checkpoint
- Validates image and user
2. AcceptCheckpointAsBaseline(...)
- Converts checkpoint → baseline
- Accepts optional region JSON
3. InsertJsonData(...)
- Stores JSON metadata for checkpoint
4. AssignCheckpoint(...)
- Assigns checkpoint to user
- Returns assigned user details
5. updateCheckpointReview(...)
- Updates review status
- Tracks reviewer and timestamp
6. UpdateLastLoginTime(...)
- Updates user's last login time
Validation Rules
| Field | Rule |
|---|---|
| checkId / nid | Must be > 0 |
| userId | Must be valid |
| image | Required, max 5MB |
| JSON | Must be valid & < 200KB |
| status | approved / rejected / pending |
| remarks | Max 500 characters |
Repository Layer (Database Operations)
1. Insert Checkpoint
- Stored Procedure:
sp_InsertCheckpoint
Output: checkId
2. Accept as Baseline
- Stored Procedure:
sp_AcceptCheckpointAsBaseline
Output: baselineImgId
3. Insert JSON
- Stored Procedure:
InsertJsonData
Output: jsonId
4. Assign Checkpoint
- Stored Procedure:
sp_AssignCheckpoint
Returns:
- ID
- Name
5. Update Review Status
- Direct SQL update on
checkpointstable
6. Update Last Login Time
- Updates
usertable - Sets
LastLoginTime = NOW()
Flow
Service → Repository → Stored Procedure / SQL → Database
4. Checkpoint Functionality (UI / Flow Behavior)
Purpose
Checkpoint acts as an intermediate stage before baseline creation