Skip to content

Commit

Permalink
-task solution/mark.2
Browse files Browse the repository at this point in the history
  • Loading branch information
andriimikhaylovskiy committed May 17, 2024
1 parent 796e611 commit a187f56
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public CharacterDto getRandomCharacter() {

@Operation(summary = "Get list characters", description = "Get list characters by name from db")
@GetMapping()
public List<CharacterDto> getAllByName(@RequestParam String name) {
return service.getAllByName(name);
public List<CharacterDto> findAllByName(@RequestParam String name) {
return service.findAllByName(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Data
@Getter
@Setter
@Entity
@Table(name = "characters")
public class CharacterModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public interface CharacterService {
CharacterDto getRandomCharacter();

List<CharacterDto> getAllByName(String name);
List<CharacterDto> findAllByName(String name);

CharacterDto save(CreateCharacterRequestDto requestDto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public CharacterDto getRandomCharacter() {
}

@Override
public List<CharacterDto> getAllByName(String name) {
public List<CharacterDto> findAllByName(String name) {
return repository.findAllByNameContainingIgnoreCase(name)
.stream()
.map(mapper::toDto)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ private void getListWithExternalApi() {
response.body(),
CharacterResponseDataDto.class);
characterResponseDataDto.results()
.stream().map(createCharacterRequestDto ->
characterService.save(createCharacterRequestDto))
.stream().map(characterService::save)
.toList();
url = characterResponseDataDto.info().next();
} catch (IOException | InterruptedException e) {
Expand Down

0 comments on commit a187f56

Please sign in to comment.