|
| 1 | +package com.igot.cb.controller; |
| 2 | + |
| 3 | +import com.igot.cb.util.Constants; |
| 4 | +import org.springframework.beans.factory.annotation.Autowired; |
| 5 | +import org.springframework.http.ResponseEntity; |
| 6 | +import org.springframework.web.bind.annotation.*; |
| 7 | + |
| 8 | +import com.igot.cb.model.ApiResponse; |
| 9 | +import com.igot.cb.service.NotificationService; |
| 10 | + |
| 11 | +import java.util.Map; |
| 12 | + |
| 13 | +@RestController |
| 14 | +@RequestMapping("/v1/notifyAssignment") |
| 15 | +public class NotificationController { |
| 16 | + |
| 17 | + @Autowired |
| 18 | + private NotificationService notificationService; |
| 19 | + |
| 20 | + /** |
| 21 | + * Notifies learners in a batch that an instructor uploaded an assignment. |
| 22 | + * |
| 23 | + * @param requestData the request body containing courseId, batchId and assignmentTitle |
| 24 | + * @param authToken the authentication token for the user |
| 25 | + * @return a ResponseEntity containing the ApiResponse with notification result |
| 26 | + */ |
| 27 | + @PostMapping("/upload") |
| 28 | + public ResponseEntity<Object> notifyAssignmentUploaded(@RequestBody Map<String, Object> requestData, @RequestHeader(Constants.X_AUTH_TOKEN) String authToken) { |
| 29 | + ApiResponse response = notificationService.notifyAssignmentUploaded(requestData, authToken); |
| 30 | + return new ResponseEntity<>(response, response.getResponseCode()); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Notifies learners in a batch that an instructor evaluated an assignment. |
| 35 | + * |
| 36 | + * @param requestData the request body containing courseId, batchId, assignmentTitle and learnerId |
| 37 | + * @param authToken the authentication token for the user |
| 38 | + * @return a ResponseEntity containing the ApiResponse with notification result |
| 39 | + */ |
| 40 | + @PostMapping("/evaluate") |
| 41 | + public ResponseEntity<Object> notifyAssignmentEvaluation(@RequestBody Map<String, Object> requestData, @RequestHeader(Constants.X_AUTH_TOKEN) String authToken) { |
| 42 | + ApiResponse response = notificationService.notifyAssignmentEvaluate(requestData, authToken); |
| 43 | + return new ResponseEntity<>(response, response.getResponseCode()); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Notifies learners in a batch that a learner submitted an assignment. |
| 48 | + * |
| 49 | + * @param requestData the request body containing courseId, batchId and assignmentTitle and instructorId |
| 50 | + * @param authToken the authentication token for the user |
| 51 | + * @return a ResponseEntity containing the ApiResponse with notification result |
| 52 | + */ |
| 53 | + @PostMapping("/submit") |
| 54 | + public ResponseEntity<Object> notifyAssignmentSubmit(@RequestBody Map<String, Object> requestData, @RequestHeader(Constants.X_AUTH_TOKEN) String authToken) { |
| 55 | + ApiResponse response = notificationService.notifyAssignmentSubmit(requestData, authToken); |
| 56 | + return new ResponseEntity<>(response, response.getResponseCode()); |
| 57 | + } |
| 58 | +} |
0 commit comments