Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0b682e4
feat:adds custom folder and file
Boyce007 Sep 27, 2025
f9f5016
feat:adds divs
Boyce007 Sep 27, 2025
37263e7
feat:adds html and css for tab component
Boyce007 Sep 28, 2025
a6a3a5e
feat:adds logic to get working tabs
Boyce007 Sep 28, 2025
2f7102e
feat:adds accordian component
Boyce007 Sep 29, 2025
8709500
feat:adds images to new image folder
Boyce007 Sep 29, 2025
4195800
feat:adds images image list
Boyce007 Sep 29, 2025
e01a89b
feat:adds tic tac to board
Boyce007 Sep 29, 2025
807a3e4
feat:adds indices for tic tac toe blocks
Boyce007 Sep 29, 2025
f66003c
feat:adds restart button along with player turn text
Boyce007 Sep 29, 2025
b3f12a1
feat:adds code to handle selections
Boyce007 Sep 29, 2025
6bbf2ce
fix:adds comma to fix bug
Boyce007 Sep 29, 2025
178a38c
fix:updates query selector to acces text content
Boyce007 Sep 29, 2025
25d0967
refactor:moves strech assignment to sub folder of base assignment
Boyce007 Oct 2, 2025
6514aaa
feat:adds images to photo gallery
Boyce007 Oct 2, 2025
167f9a0
feat:adds scrolling functionality to photo gallery
Boyce007 Oct 2, 2025
e178194
feat:adds scrolling backwards functionality
Boyce007 Oct 2, 2025
2ed70c0
fix:re adds tic tac toe html
Boyce007 Oct 2, 2025
3113f17
fix:readds tic tac toe css and javascript
Boyce007 Oct 2, 2025
affa060
feat:adds draw functionality to game
Boyce007 Oct 2, 2025
e53f7c8
refactor:changed imports of images to match ifle restructure
Boyce007 Oct 2, 2025
79a525a
Merge branch 'main' of https://github.com/Boyce007/code-society-25-2 …
Boyce007 Oct 5, 2025
19f1797
feat:adds method to get media items by id using pathvaraibles and add…
Boyce007 Oct 5, 2025
cc07b57
feat:adds converts media item object to response item
Boyce007 Oct 5, 2025
3102a66
feat:tests pass with simple response entity returned
Boyce007 Oct 5, 2025
ba22981
chore:uncomments code to get media items by id
Boyce007 Oct 5, 2025
3581d25
feat:adds proper respone entites when get item is not found
Boyce007 Oct 5, 2025
86a7547
feat:adds method to add a new media item to the library
Boyce007 Oct 6, 2025
d605426
fix:changes endpoint form items to /items to match with tests and add…
Boyce007 Oct 6, 2025
65d5f1b
feat:changes response entity from not found to bad request to match t…
Boyce007 Oct 6, 2025
7b2160f
fix:chages response body to media items requests and and uses the sta…
Boyce007 Oct 6, 2025
889df7d
feat:adds method to get media items by id using pathvaraibles and add…
Boyce007 Oct 5, 2025
ab383c4
feat:adds converts media item object to response item
Boyce007 Oct 5, 2025
ed40e1b
feat:tests pass with simple response entity returned
Boyce007 Oct 5, 2025
eb6f35e
chore:uncomments code to get media items by id
Boyce007 Oct 5, 2025
5ababd7
fix:fixes issue where extra files are added
Boyce007 Oct 6, 2025
16f1484
feat:adds proper respone entites when get item is not found
Boyce007 Oct 5, 2025
e58946e
feat:adds method to add a new media item to the library
Boyce007 Oct 6, 2025
87e8222
fix:changes endpoint form items to /items to match with tests and add…
Boyce007 Oct 6, 2025
46fb984
fix:removes uncessary files
Boyce007 Oct 6, 2025
486d8db
feat:adds create media item request to parameters with check if the i…
Boyce007 Oct 6, 2025
2cc98b4
feat:adds method body to delete item
Boyce007 Oct 6, 2025
e1848cc
feat:adds logic to delete item from
Boyce007 Oct 6, 2025
910b9ac
chore: spotless apply
Boyce007 Oct 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class MediaItemRequest {
private int runtime;

public static MediaItem asMediaItem(MediaItemRequest request) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra line break

var id = request.id != null ? request.id : UUID.randomUUID();
switch (request.type.toLowerCase()) {
case "book" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
import com.codedifferently.lesson23.library.search.SearchCriteria;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand All @@ -31,4 +37,52 @@ public ResponseEntity<GetMediaItemsResponse> getItems() {
var response = GetMediaItemsResponse.builder().items(responseItems).build();
return ResponseEntity.ok(response);
}

@GetMapping(value = "items/{id}")
public ResponseEntity<GetMediaItemsResponse> getItem(@PathVariable String id) {
// gets the media items that matches the id
Set<MediaItem> items = library.search(SearchCriteria.builder().id(id).build());
Optional<MediaItem> mediaItemById = items.stream().findFirst();
MediaItemResponse responseItem = null;
// if the media exists by the idea return an ok response entity otherwise return not found
if (mediaItemById.isPresent()) {
responseItem = MediaItemResponse.from(mediaItemById.get());
var response = GetMediaItemsResponse.builder().item(responseItem).build();
return ResponseEntity.ok(response);
}
return ResponseEntity.notFound().build();
}

@PostMapping("/items")
public ResponseEntity<?> addItem(@RequestBody CreateMediaItemRequest requestItem) {
if (requestItem == null || requestItem.getItem() == null) {
return ResponseEntity.badRequest().body(Map.of("errors", List.of("item is required")));
}
try {
MediaItem mediaItem = MediaItemRequest.asMediaItem(requestItem.getItem());
library.addMediaItem(mediaItem, librarian);

MediaItemResponse itemResponse = MediaItemResponse.from(mediaItem);
CreateMediaItemResponse response =
CreateMediaItemResponse.builder().item(itemResponse).build();
return ResponseEntity.ok(response);

} catch (IllegalArgumentException e) {
return ResponseEntity.badRequest().body(Map.of("errors", List.of(e.getMessage())));
} catch (Exception e) {
return ResponseEntity.badRequest()
.body(Map.of("errors", List.of("An unexpected error occurred")));
}
}

@DeleteMapping("/items/{id}")
public ResponseEntity deleteItem(@PathVariable String id) {
Set<MediaItem> items = library.search(SearchCriteria.builder().id(id).build());
Optional<MediaItem> mediaItemById = items.stream().findFirst();
if (mediaItemById.isPresent()) {
library.removeMediaItem(mediaItemById.get(), librarian);
return ResponseEntity.noContent().build();
}
return ResponseEntity.notFound().build();
}
}