1
|
package cz.zcu.kiv.backendapi.external;
|
2
|
|
3
|
import io.swagger.v3.oas.annotations.Operation;
|
4
|
import lombok.RequiredArgsConstructor;
|
5
|
import org.springframework.http.HttpStatus;
|
6
|
import org.springframework.http.ResponseEntity;
|
7
|
import org.springframework.web.bind.annotation.*;
|
8
|
import org.springframework.web.multipart.MultipartFile;
|
9
|
|
10
|
import java.util.List;
|
11
|
|
12
|
/**
|
13
|
* Controller for external catalog
|
14
|
*/
|
15
|
@RestController
|
16
|
@RequiredArgsConstructor
|
17
|
@RequestMapping("/external-catalog-items")
|
18
|
public class ExternalCatalogController {
|
19
|
|
20
|
/**
|
21
|
* External catalog service
|
22
|
*/
|
23
|
private final IExternalCatalogItemService externalCatalogService;
|
24
|
|
25
|
/**
|
26
|
* Updates external catalog
|
27
|
*
|
28
|
* @param file file - should contain CIGS catalog
|
29
|
*/
|
30
|
@PostMapping("")
|
31
|
@Operation(summary = "updates external catalog")
|
32
|
public void updateCatalog(@RequestParam("file") MultipartFile file) {
|
33
|
externalCatalogService.updateCatalog(file);
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* Returns external catalog items satisfying given filter
|
38
|
*
|
39
|
* @param name name
|
40
|
* @param source source
|
41
|
* @return list of external catalog items satisfying given filter
|
42
|
*/
|
43
|
@GetMapping("")
|
44
|
@Operation(summary = "returns external catalog items based on filter")
|
45
|
public ResponseEntity<List<ExternalCatalogItem>> getCatalog(@RequestParam String name, @RequestParam ExternalSource source) {
|
46
|
return new ResponseEntity<>(externalCatalogService.getCatalog(name, source), HttpStatus.OK);
|
47
|
}
|
48
|
}
|