-
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
app ready #46
base: main
Are you sure you want to change the base?
app ready #46
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.
very good job, can be improved a little
implementationPackage = "<PACKAGE_NAME>.impl" | ||
) | ||
public class MapperConfig { | ||
|
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.
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.
I'm not entirely sure what you meant here and in the other similar reviews.
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.
redundant blank lines
@RequiredArgsConstructor | ||
public class AppStartupRunner implements ApplicationRunner { | ||
private final CharacterRepository repository; | ||
|
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.
|
||
@Override | ||
public void run(ApplicationArguments args) throws Exception { | ||
if (characterClient.getDataByPage(1).getInfo().getCount() != repository.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.
is it up-to-date data check? consider extracting it to self-explanatory named method
if (characterClient.getDataByPage(1).getInfo().getCount() != repository.count()) { | |
if (characterClient.getDataByPage(1).getInfo().getCount() != repository.count()) { |
if (characterClient.getDataByPage(1).getInfo().getCount() != repository.count()) { | ||
List<Character> allCharacters = characterClient.getAllCharacters(); | ||
for (Character character : allCharacters) { | ||
if (!repository.findByExternalId(character.getExternalId()).isPresent()) { | ||
repository.save(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.
all this logic can be separated to the DataLoader
service (too low abstraction on high-level ApplicationRunner)
} | ||
} | ||
} | ||
System.out.println(characterClient.getDataByPage(1)); |
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.
what's purpose of this log? better do debug, also we have @Slf4j
logger embed in Lombok
System.out.println(characterClient.getDataByPage(1)); | |
log.debug(characterClient.getDataByPage(1)); |
private static final String BASE_URL = "https://rickandmortyapi.com/api/character/?page=%s"; | ||
|
||
private final ObjectMapper objectMapper; | ||
|
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 CharacterResponseDataDto getDataByPage(int page) { | ||
HttpClient client = HttpClient.newHttpClient(); |
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.
as we are using Spring, consider creating @Bean public HttpClient httpClient()...
bean in your Spring Configuration, so we could autowire it to the private final
class-level field
|
||
@Override | ||
public CharacterDto getRandomCharacter() { | ||
Random random = new Random(); |
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.
should be class-level field, injected by Spring
@RequiredArgsConstructor | ||
public class CharacterServiceImpl implements CharacterService { | ||
private final CharacterRepository characterRepository; | ||
|
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.
@@ -19,8 +19,45 @@ | |||
<maven.checkstyle.plugin.configLocation> |
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.
miss-clicked approve (:
I didn't quite understand some problems you pointed out. The ones with the -. Would be great if you clarified. |
No description provided.