Skip to content

Commit b6d9cdc

Browse files
committed
cria função de listar todos os jogos do BD, retornando um DTO com apenas os dados necessários
1 parent 81d5284 commit b6d9cdc

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.gabriel_torelo.game_list.services;
2+
3+
import java.util.List;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.stereotype.Service;
6+
import com.gabriel_torelo.game_list.dto.GameMinDTO;
7+
import com.gabriel_torelo.game_list.entities.Game;
8+
import com.gabriel_torelo.game_list.repositories.GameRepository;
9+
10+
@Service
11+
public class GameService {
12+
13+
@Autowired
14+
private GameRepository gameRepository;
15+
16+
public List<GameMinDTO> readAll() {
17+
List<Game> rGames = gameRepository.findAll();
18+
19+
return rGames.stream().map(gameEntity -> new GameMinDTO(gameEntity)).toList();
20+
}
21+
}

0 commit comments

Comments
 (0)