mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-05-13 17:11:49 +00:00
fix: devWeb - display all list of played game (profile)
This commit is contained in:
@@ -30,11 +30,11 @@ public class ProfileServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||||
User user = (User) request.getSession().getAttribute("user");
|
User usersession = (User) request.getSession().getAttribute("user");
|
||||||
DAO<User> userDAO = null;
|
DAO<User> userDAO = null;
|
||||||
try {
|
try {
|
||||||
userDAO = new Game_JPA_DAO_Factory().getDAOUser();
|
userDAO = new Game_JPA_DAO_Factory().getDAOUser();
|
||||||
user = userDAO.findById(user.getId().intValue());
|
User user = userDAO.findById(usersession.getId().intValue());
|
||||||
for(Player p : user.getPlayedGames()){
|
for(Player p : user.getPlayedGames()){
|
||||||
System.out.println("Partie jouée le " + p.getGame().getCreatedAt().toLocaleString());
|
System.out.println("Partie jouée le " + p.getGame().getCreatedAt().toLocaleString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,11 @@ public class GameWS {
|
|||||||
|
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
em.persist(game);
|
em.persist(game);
|
||||||
for (Player p : games.get(game)) em.persist(p);
|
for (Player p : games.get(game)){
|
||||||
|
game.addPlayer(p);
|
||||||
|
p.getUser().addPlayedGame(p);
|
||||||
|
}
|
||||||
|
em.persist(game);
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user