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 1111import java .util .UUID ;
1212import org .springframework .http .HttpStatus ;
1313import org .springframework .http .ResponseEntity ;
14- import org .springframework .web .bind .annotation .DeleteMapping ;
1514import org .springframework .web .bind .annotation .CrossOrigin ;
15+ import org .springframework .web .bind .annotation .DeleteMapping ;
1616import org .springframework .web .bind .annotation .GetMapping ;
1717import org .springframework .web .bind .annotation .PathVariable ;
1818import org .springframework .web .bind .annotation .PostMapping ;
@@ -34,15 +34,19 @@ public MediaItemsController(Library library) throws IOException {
3434 this .library = library ;
3535 this .librarian = library .getLibrarians ().stream ().findFirst ().orElseThrow ();
3636 }
37-
3837 @ GetMapping ("/items" )
3938 public GetMediaItemsResponse getItems () {
4039 Set <MediaItem > items = library .search (SearchCriteria .builder ().build ());
4140 List <MediaItemResponse > responseItems = items .stream ().map (MediaItemResponse ::from ).toList ();
4241 var response = GetMediaItemsResponse .builder ().items (responseItems ).build ();
4342 return response ;
4443 }
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+ */
4650 @ PostMapping ("/items" )
4751 public CreateMediaItemResponse postItem (@ Valid @ RequestBody CreateMediaItemRequest req ) {
4852 MediaItem media = MediaItemRequest .asMediaItem (req .getItem ());
You can’t perform that action at this time.
0 commit comments