-
Notifications
You must be signed in to change notification settings - Fork 250
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
solution #189
base: main
Are you sure you want to change the base?
solution #189
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.
good job overall!
return new Random().nextLong(characterRepository.count()); | ||
} | ||
} | ||
|
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.
} | ||
|
||
private long getRandomId() { | ||
return new Random().nextLong(characterRepository.count()); |
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.
make random a private final class field to avoid needless recreation
private final CharacterService characterService; | ||
|
||
@Operation(summary = "Get one random character") | ||
@GetMapping("/randomly") |
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.
@GetMapping("/randomly") | |
@GetMapping("/random") |
makes more sense for RESTful naming
@GetMapping("/search") | ||
public List<CharacterEntity> searchByName(String name) { |
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.
@GetMapping("/search") | |
public List<CharacterEntity> searchByName(String name) { | |
@GetMapping | |
public List<CharacterEntity> searchByName(String name) { |
make name a request parameter
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.
Great job! 🔥 A few recommendations, please correct them and take them into account in the next solutions 😉
<configuration> | ||
<configLocation>${maven.checkstyle.plugin.configLocation}</configLocation> | ||
<consoleOutput>true</consoleOutput> | ||
<sourceDirectories>src/main/java/mate/academy/rickandmorty/mapper/CharacterMapper.java</sourceDirectories> |
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.
Why do you apply checkstyle plugin only to one class? Let's apply it to the src
directory;)
|
||
@SpringBootApplication | ||
public class Application { | ||
|
||
private final CharacterService characterService; | ||
|
||
@Autowired |
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.
JFYI this annotation is optional ;)
@Getter | ||
@Setter | ||
@Entity | ||
public class CharacterEntity { |
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.
public class CharacterEntity { | |
public class Character { |
url = dataDto.getInfo().getNext(); | ||
} | ||
} catch (IOException | InterruptedException e) { | ||
throw new RuntimeException(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.
Let's add an informative message ;)
spring.jpa.hibernate.ddl-auto=create-drop | ||
spring.jpa.show-sql=true | ||
spring.jpa.open-in-view=false | ||
|
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.
Leave only one empty line at the end of the file ;)
No description provided.