File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11
11
import java .util .UUID ;
12
12
import org .springframework .http .HttpStatus ;
13
13
import org .springframework .http .ResponseEntity ;
14
- import org .springframework .web .bind .annotation .DeleteMapping ;
15
14
import org .springframework .web .bind .annotation .CrossOrigin ;
15
+ import org .springframework .web .bind .annotation .DeleteMapping ;
16
16
import org .springframework .web .bind .annotation .GetMapping ;
17
17
import org .springframework .web .bind .annotation .PathVariable ;
18
18
import org .springframework .web .bind .annotation .PostMapping ;
@@ -34,15 +34,19 @@ public MediaItemsController(Library library) throws IOException {
34
34
this .library = library ;
35
35
this .librarian = library .getLibrarians ().stream ().findFirst ().orElseThrow ();
36
36
}
37
-
38
37
@ GetMapping ("/items" )
39
38
public GetMediaItemsResponse getItems () {
40
39
Set <MediaItem > items = library .search (SearchCriteria .builder ().build ());
41
40
List <MediaItemResponse > responseItems = items .stream ().map (MediaItemResponse ::from ).toList ();
42
41
var response = GetMediaItemsResponse .builder ().items (responseItems ).build ();
43
42
return response ;
44
43
}
45
-
44
+ /**
45
+ * Post an item to the specified endpoint.
46
+ *
47
+ * @param req the request object for creating a media item
48
+ * @return the response object for creating a media item
49
+ */
46
50
@ PostMapping ("/items" )
47
51
public CreateMediaItemResponse postItem (@ Valid @ RequestBody CreateMediaItemRequest req ) {
48
52
MediaItem media = MediaItemRequest .asMediaItem (req .getItem ());
You can’t perform that action at this time.
0 commit comments