-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First Attempt #201
base: main
Are you sure you want to change the base?
First Attempt #201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rework so you use your DTOs, especially in controller response
src/main/java/mate/academy/rickandmorty/controller/CharacterController.java
Outdated
Show resolved
Hide resolved
src/main/java/mate/academy/rickandmorty/controller/CharacterController.java
Outdated
Show resolved
Hide resolved
src/main/java/mate/academy/rickandmorty/controller/CharacterController.java
Outdated
Show resolved
Hide resolved
Empty line removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, please review my comments.
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping(value = "/character") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For API design consistency, it would be better to use a plural form '/characters' instead of '/character'.
public class CharacterController { | ||
private final CharacterService characterService; | ||
|
||
@GetMapping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method 'getRandomCharacter' does not have any explicit path. Consider adding an explicit path like '/random' to make it clear this endpoint is for getting a random character.
List<Character> characters = characterMapper.toModelList(characterDtoList); | ||
characterRepository.saveAll(characters); | ||
} catch (IOException | InterruptedException e) { | ||
throw new EntityNotFoundException("Can't access results from external API", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EntityNotFoundException is not the appropriate exception to throw when there is an error connecting to the external API. Consider creating a custom exception to handle this scenario.
@RequiredArgsConstructor | ||
public class CharacterInitializer { | ||
@Value("${api.url}") | ||
private String apiUrl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'apiUrl' field should be final. Since we are injecting value from the property file, it should not be changed during runtime.
@NoArgsConstructor | ||
@Table(name = "results") | ||
|
||
public class Character { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class 'Character' might conflict with 'java.lang.Character'. Consider renaming your class to something more specific like 'RickAndMortyCharacter'.
No description provided.