Projekt

Obecné

Profil

Stáhnout (1.36 KB) Statistiky
| Větev: | Tag: | Revize:
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
    @PostMapping("")
26
    @Operation(summary = "updates external catalog")
27
    public void updateCatalog(@RequestParam("file") MultipartFile file) {
28
        externalCatalogService.updateCatalog(file);
29
    }
30

    
31
    /**
32
     * Returns external catalog items satisfying given filter
33
     *
34
     * @param name   name
35
     * @param source source
36
     * @return list of external catalog items satisfying given filter
37
     */
38
    @GetMapping("")
39
    @Operation(summary = "returns external catalog items based on filter")
40
    public ResponseEntity<List<ExternalCatalogItem>> getCatalog(@RequestParam String name, @RequestParam ExternalSource source) {
41
        return new ResponseEntity<>(externalCatalogService.getCatalog(name, source), HttpStatus.OK);
42
    }
43
}
(1-1/7)