Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
S4a021 Web Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Charlie Darques
S4a021 Web Backend
Commits
dbbfbe3b
Commit
dbbfbe3b
authored
1 month ago
by
Charlie Darques
Browse files
Options
Downloads
Patches
Plain Diff
correction de bug pour unfollow
parent
bda83feb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
WEB-INF/src/controleurs/FollowThread.java
+8
-9
8 additions, 9 deletions
WEB-INF/src/controleurs/FollowThread.java
WEB-INF/src/dao/UserDAO.java
+5
-1
5 additions, 1 deletion
WEB-INF/src/dao/UserDAO.java
with
13 additions
and
10 deletions
WEB-INF/src/controleurs/FollowThread.java
+
8
−
9
View file @
dbbfbe3b
...
@@ -33,17 +33,15 @@ public class FollowThread extends HttpServlet {
...
@@ -33,17 +33,15 @@ public class FollowThread extends HttpServlet {
}
}
boolean
followed
=
false
;
boolean
followed
=
false
;
try
{
if
(
threadsFollowed
.
contains
(
threadDao
.
getThreadById
((
Integer
.
parseInt
(
req
.
getParameter
(
"threadid"
))))))
{
if
(
threadsFollowed
.
contains
(
Integer
.
parseInt
(
req
.
getParameter
(
"threadid"
))))
{
followed
=
true
;
followed
=
true
;
}
else
{
followed
=
false
;
}
}
}
catch
(
SQLException
sqle
)
{
else
{
sqle
.
getStackTrace
()
;
followed
=
false
;
}
}
System
.
out
.
println
(
followed
);
if
(!
followed
)
{
if
(!
followed
)
{
try
{
try
{
...
@@ -55,6 +53,7 @@ public class FollowThread extends HttpServlet {
...
@@ -55,6 +53,7 @@ public class FollowThread extends HttpServlet {
}
}
}
}
else
if
(
followed
)
{
else
if
(
followed
)
{
System
.
out
.
println
(
"déjà suivi"
);
try
{
try
{
userDao
.
unfollowThread
(
user
,
threadDao
.
getThreadById
((
Integer
.
parseInt
(
req
.
getParameter
(
"threadid"
)))));
userDao
.
unfollowThread
(
user
,
threadDao
.
getThreadById
((
Integer
.
parseInt
(
req
.
getParameter
(
"threadid"
)))));
res
.
sendRedirect
(
"http://localhost:8080/s4a021-web-backend/Discover"
);
res
.
sendRedirect
(
"http://localhost:8080/s4a021-web-backend/Discover"
);
...
...
This diff is collapsed.
Click to expand it.
WEB-INF/src/dao/UserDAO.java
+
5
−
1
View file @
dbbfbe3b
...
@@ -192,6 +192,7 @@ public class UserDAO {
...
@@ -192,6 +192,7 @@ public class UserDAO {
ps
.
setInt
(
2
,
thread
.
getId
());
ps
.
setInt
(
2
,
thread
.
getId
());
Date
date
=
Date
.
valueOf
(
LocalDate
.
now
());
Date
date
=
Date
.
valueOf
(
LocalDate
.
now
());
ps
.
setDate
(
3
,
date
);
ps
.
setDate
(
3
,
date
);
ps
.
executeUpdate
();
ps
.
executeUpdate
();
}
}
catch
(
SQLException
sqle
)
{
catch
(
SQLException
sqle
)
{
...
@@ -200,10 +201,13 @@ public class UserDAO {
...
@@ -200,10 +201,13 @@ public class UserDAO {
}
}
public
void
unfollowThread
(
User
user
,
MyThread
thread
)
throws
SQLException
{
public
void
unfollowThread
(
User
user
,
MyThread
thread
)
throws
SQLException
{
PreparedStatement
ps
=
this
.
con
.
prepareStatement
(
"DELETE FROM follow WHERE userID_follow = ? AND threadID_follow = ?)"
);
System
.
out
.
println
(
"dans méthode"
);
PreparedStatement
ps
=
this
.
con
.
prepareStatement
(
"DELETE FROM follow WHERE userID_follow=? AND threadID_follow=?"
);
try
{
try
{
ps
.
setInt
(
1
,
user
.
getId
());
ps
.
setInt
(
1
,
user
.
getId
());
ps
.
setInt
(
2
,
thread
.
getId
());
ps
.
setInt
(
2
,
thread
.
getId
());
System
.
out
.
println
(
ps
);
ps
.
executeUpdate
();
ps
.
executeUpdate
();
}
}
catch
(
SQLException
sqle
)
{
catch
(
SQLException
sqle
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment