Skip to content
Snippets Groups Projects
Commit 3001d3fb authored by Maxime Gosselin's avatar Maxime Gosselin
Browse files

Fonction ne plus suivre un fil operationelle

parent 5060d1ad
No related branches found
No related tags found
No related merge requests found
......@@ -16,25 +16,30 @@ import java.io.IOException;
public class ThreadController extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String action = (String) req.getParameter("action");
String vue;
String username;
DaoFollower daoFollower = new DaoFollower();
// vérification de l'authentification
if((username = (String) req.getSession().getAttribute("username")) == null){
resp.sendRedirect("index.html");
} else {
switch (action){
case "follow":
int idThread = Integer.parseInt(req.getParameter("id"));
Follower follow = new Follower(username, idThread);
daoFollower.create(follow);
vue = "WEB-INF/vue/filsSuivis.jsp";
break;
default:
vue = "WEB-INF/vue/accueil.jsp";
}
req.getRequestDispatcher(vue).forward(req, resp);
return ;
}
String action = (String) req.getParameter("action");
String vue;
DaoFollower daoFollower = new DaoFollower();
int idThread = Integer.parseInt(req.getParameter("id"));
Follower follow = new Follower(username, idThread);
switch (action){
case "follow":
daoFollower.create(follow);
vue = "WEB-INF/vue/filsSuivis.jsp";
break;
case "unfollow":
daoFollower.delete(follow);
vue = "WEB-INF/vue/filsSuivis.jsp";
break;
default:
vue = "WEB-INF/vue/fils.jsp";
}
req.getRequestDispatcher(vue).forward(req, resp);
}
}
......@@ -44,7 +44,7 @@ public class DaoFollower {
public void delete(Follower follower) {
DS bdd = DS.getInstance();
try(Connection con = bdd.getConnection()) {
PreparedStatement ps = con.prepareStatement("DELETE followers WHERE username=? AND id_thread=?");
PreparedStatement ps = con.prepareStatement("DELETE FROM followers WHERE username=? AND id_thread=?");
ps.setString(1, follower.getUsername());
ps.setInt(2, follower.getId_thread());
ps.executeUpdate();
......
......@@ -73,7 +73,7 @@
</div>
<div class="d-flex">
<a class="me-3 align-self-center btn btn-primary" href="?chat=1">Ouvrir <i class="bi-chat-fill"></i></a>
<a class="me-3 align-self-center btn btn-danger" href="?delete=1">Ne plus suivre <i class="bi-x-circle-fill"></i></a>
<a class="me-3 align-self-center btn btn-danger" href="thread?action=unfollow&id=<%=fil.getId_thread() %>">Ne plus suivre <i class="bi-x-circle-fill"></i></a>
</div>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment