-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCombinedRawDataController.java
More file actions
40 lines (32 loc) · 1.48 KB
/
CombinedRawDataController.java
File metadata and controls
40 lines (32 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package fr.insee.genesis.controller.rest;
import fr.insee.genesis.controller.dto.rawdata.CombinedRawDataDto;
import fr.insee.genesis.domain.service.rawdata.CombinedRawDataService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Slf4j
@Controller
@RequestMapping(path = "/combined-raw-data" )
@RequiredArgsConstructor
public class CombinedRawDataController {
private static final String INTERROGATION_ID = "interrogationId";
private final CombinedRawDataService combinedRawDataService;
@Operation(summary = "Retrieve combined raw responses and Lunatic raw data for a given interrogationId")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN', 'USER_PLATINE')")
public ResponseEntity<CombinedRawDataDto> getCombinedRawData(
@RequestParam(INTERROGATION_ID) String interrogationId
){
CombinedRawDataDto data = combinedRawDataService.getCombinedRawDataByInterrogationId(interrogationId);
if (data.rawResponseModels().isEmpty()) {
return ResponseEntity.notFound().build();
}
return ResponseEntity.ok(data);
}
}