File tree Expand file tree Collapse file tree
src/main/java/com/gabriel_torelo/game_list/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import java .util .List ;
44import org .springframework .beans .factory .annotation .Autowired ;
55import org .springframework .stereotype .Service ;
6+ import org .springframework .transaction .annotation .Transactional ;
7+ import com .gabriel_torelo .game_list .dto .GameLongDTO ;
68import com .gabriel_torelo .game_list .dto .GameMinDTO ;
9+ import com .gabriel_torelo .game_list .dto .GameShortDTO ;
710import com .gabriel_torelo .game_list .entities .Game ;
811import com .gabriel_torelo .game_list .repositories .GameRepository ;
912
@@ -13,9 +16,24 @@ public class GameService {
1316 @ Autowired
1417 private GameRepository gameRepository ;
1518
19+ @ Transactional (readOnly = true )
1620 public List <GameMinDTO > readAll () {
1721 List <Game > rGames = gameRepository .findAll ();
1822
1923 return rGames .stream ().map (gameEntity -> new GameMinDTO (gameEntity )).toList ();
2024 }
25+
26+ @ Transactional (readOnly = true )
27+ public GameShortDTO readID (Long id ) {
28+ Game rGame = gameRepository .findById (id ).get ();
29+
30+ return new GameShortDTO (rGame );
31+ }
32+
33+ @ Transactional (readOnly = true )
34+ public GameLongDTO readMoreID (Long id ) {
35+ Game rGame = gameRepository .findById (id ).get ();
36+
37+ return new GameLongDTO (rGame );
38+ }
2139}
You can’t perform that action at this time.
0 commit comments