Skip to content

Commit

Permalink
Merge pull request #16 from kiblykat/SIS-33
Browse files Browse the repository at this point in the history
Sis 33
  • Loading branch information
kiblykat authored Mar 24, 2024
2 parents fd2c0b1 + 7db523c commit 3b8c020
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
15 changes: 15 additions & 0 deletions src/main/java/sg/com/smartinventory/exceptions/ErrorResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package sg.com.smartinventory.exceptions;

import java.time.LocalDateTime;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
public class ErrorResponse {
private String message;
private LocalDateTime timeStamp;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.time.LocalDateTime;
import java.util.List;

import sg.com.smartinventory.entities.ErrorResponse;

import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -24,15 +22,6 @@ public ResponseEntity<ErrorResponse> handleResourceNotFoundException(CustomerNot
return new ResponseEntity<>(errorResponse, HttpStatus.NOT_FOUND);
}

// @ExceptionHandler(ProductNotFoundException.class)
// public ResponseEntity<ErrorResponse>
// handleProductNotFoundException(CustomerNotFoundException ex){
// ErrorResponse errorResponse = new ErrorResponse(ex.getMessage(),
// LocalDateTime.now());
//
// return new ResponseEntity<>(errorResponse, HttpStatus.NOT_FOUND);
// }

@ExceptionHandler(EmptyResultDataAccessException.class)
public ResponseEntity<ErrorResponse> handleEmptyResultDataAccessException(EmptyResultDataAccessException ex) {
ErrorResponse errorResponse = new ErrorResponse("Entry does not exist. ", LocalDateTime.now());
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/sg/com/smartinventory/utility/DataLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,25 @@ public void loadData() {
productRepository.save(new Product("Books", "Science Fiction Novel",
"Bestselling sci-fi novel set in a dystopian future. ", 14.99, 300));

reviewRepository.save(new Review("Electronics", "Great smartphone with excellent features. ",
5, 1, 1));
reviewRepository.save(new Review("Books", "Expected more from the ending, felt rushed. ",
3, 1, 1));
reviewRepository.save(new Review("Electronics", "Fast delivery, product works as expected. ",
4, 1, 2));
reviewRepository.save(new Review("Clothing", "Very comfortable t-shirt, fits perfectly. ",
4, 2, 2));
reviewRepository.save(new Review("Home & Kitchen", "Makes delicious coffee, easy to use. ",
4, 3, 3));
reviewRepository.save(new Review("Home & Kitchen", "Difficult to assemble, but sturdy once done. ",
3, 2, 4));
reviewRepository.save(new Review("Electronics", "Great smartphone with excellent features. ",
5, 3, 1));
reviewRepository.save(new Review("Clothing", "The color faded after a few washes. ",
2, 3, 3));
reviewRepository.save(new Review("Beauty", "Lovely fragrance, long-lasting. ",
5, 4, 4));
reviewRepository.save(new Review("Home & Kitchen", "Makes delicious coffee, easy to use. ",
4, 4, 3));
reviewRepository.save(new Review("Books", "Intriguing plot, couldn't put it down. ",
5, 5, 5));
reviewRepository.save(new Review("Beauty", "Disappointed with the scent, doesn't last long. ",
2, 5, 5));
}
}

0 comments on commit 3b8c020

Please sign in to comment.