1
1
package com .codedifferently .lesson26 .web ;
2
2
3
- import com .codedifferently .lesson26 .library .Librarian ; // Ensure this import is present
3
+ import com .codedifferently .lesson26 .library .Librarian ;
4
4
import com .codedifferently .lesson26 .library .Library ;
5
5
import com .codedifferently .lesson26 .library .MediaItem ;
6
6
import com .codedifferently .lesson26 .library .search .SearchCriteria ;
21
21
import org .springframework .web .bind .annotation .RequestMapping ;
22
22
import org .springframework .web .bind .annotation .RestController ;
23
23
24
- // DTO imports
24
+
25
25
26
26
@ RestController
27
27
@ CrossOrigin
@@ -63,7 +63,7 @@ public ResponseEntity<CreateMediaItemResponse> createItem(
63
63
@ Valid @ RequestBody CreateMediaItemRequest request ) {
64
64
try {
65
65
MediaItem item = MediaItemRequest .asMediaItem (request .getItem ());
66
- library .addMediaItem (item , librarian ); // Ensure you're passing a Librarian object
66
+ library .addMediaItem (item , librarian );
67
67
var response = CreateMediaItemResponse .builder ().item (MediaItemResponse .from (item )).build ();
68
68
return ResponseEntity .ok (response );
69
69
} catch (IllegalArgumentException e ) {
@@ -79,7 +79,7 @@ public ResponseEntity<Void> deleteItemById(@PathVariable String id) {
79
79
if (items .isEmpty ()) {
80
80
return ResponseEntity .notFound ().build ();
81
81
}
82
- library .removeMediaItem (uuid , librarian ); // Ensure you're passing a Librarian object
82
+ library .removeMediaItem (uuid , librarian );
83
83
return ResponseEntity .noContent ().build ();
84
84
} catch (IllegalArgumentException e ) {
85
85
return ResponseEntity .notFound ().build ();
@@ -98,7 +98,7 @@ public ResponseEntity<Map<String, List<Map<String, String>>>> handleValidationEr
98
98
"message" , fieldError .getDefaultMessage ()))
99
99
.toList ();
100
100
101
- // Optional: Log the validation errors
101
+
102
102
System .out .println ("Validation errors: " + errors );
103
103
104
104
return ResponseEntity .badRequest ().body (Map .of ("errors" , errors ));
0 commit comments