Skip to main content

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​

MethodEndpointDescription
POST/api/checkpointsCreate a new checkpoint
POST/api/checkpoints/{checkId}/accept-baselineAccept checkpoint as baseline
POST/api/checkpoints/{checkId}/jsonInsert JSON data
POST/api/checkpoints/{checkId}/assignAssign checkpoint to user
PATCH/api/checkpoints/{checkId}/reviewUpdate review status
PATCH/api/checkpoints/user/{userId}/last-loginUpdate last login time

1. Create Checkpoint​

Request​

POST /api/checkpoints
ParamDescription
nidNode/Test ID
userIdCreated user
imageImage (byte array)

Response​

101

Returns checkId


2. Accept Checkpoint as Baseline​

Request​

POST /api/checkpoints/{checkId}/accept-baseline
ParamDescription
checkIdCheckpoint ID
userIdUser performing action
regionsJsonOptional 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
ParamDescription
assignedToUser assigned
assignedByAssigning user
remarksOptional notes

Response​

{
"id": 2,
"name": "John",
"email": "john@example.com"
}

5. Update Review Status​

Request​

PATCH /api/checkpoints/{checkId}/review
ParamDescription
statusapproved / rejected / pending
userIdReviewer

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​

FieldRule
checkId / nidMust be > 0
userIdMust be valid
imageRequired, max 5MB
JSONMust be valid & < 200KB
statusapproved / rejected / pending
remarksMax 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
  • Email

5. Update Review Status​

  • Direct SQL update on checkpoints table

6. Update Last Login Time​

  • Updates user table
  • 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