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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Charlie Darques
S4a021 Web Backend
Commits
4dd153c5
Commit
4dd153c5
authored
4 months ago
by
Charlie Darques
Browse files
Options
Downloads
Patches
Plain Diff
correction pour l'affichage des messages suivis
parent
e33578ec
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
WEB-INF/src/controleurs/Feed.java
+6
-2
6 additions, 2 deletions
WEB-INF/src/controleurs/Feed.java
WEB-INF/src/controleurs/LogIn.java
+1
-0
1 addition, 0 deletions
WEB-INF/src/controleurs/LogIn.java
WEB-INF/src/dao/UserDAO.java
+14
-5
14 additions, 5 deletions
WEB-INF/src/dao/UserDAO.java
with
21 additions
and
7 deletions
WEB-INF/src/controleurs/Feed.java
+
6
−
2
View file @
4dd153c5
...
...
@@ -27,7 +27,8 @@ public class Feed extends HttpServlet {
String
login
=
(
String
)
req
.
getSession
().
getAttribute
(
"login"
);
System
.
out
.
println
(
login
);
User
user
=
userDao
.
getUserByLogs
(
login
,
req
.
getParameter
(
"password"
));
User
user
=
userDao
.
getUserByLogs
(
login
,
req
.
getSession
().
getAttribute
(
"password"
).
toString
());
if
(
user
!=
null
)
{
List
<
Message
>
messages
=
null
;
try
{
...
...
@@ -41,14 +42,17 @@ public class Feed extends HttpServlet {
out
.
println
(
"<h1>Welcome "
+
login
+
"</h1>"
);
out
.
println
(
""
);
System
.
out
.
println
(
messages
.
size
());
for
(
Message
message
:
messages
)
{
System
.
out
.
println
(
"dans le for"
);
MyThread
msgThread
=
null
;
try
{
msgThread
=
threadDao
.
getThreadById
(
message
.
getThreadId
());
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
out
.
println
(
"div class=\"message\">"
);
out
.
println
(
"
<
div class=\"message\">"
);
out
.
println
(
"<h3 class=\"msgThread\">"
+
msgThread
.
getThreadName
()
+
"</h3>"
);
out
.
println
(
"<p class=\"msgContent\">"
+
message
.
getContent
()
+
"</p>"
);
out
.
println
(
"</div>"
);
...
...
This diff is collapsed.
Click to expand it.
WEB-INF/src/controleurs/LogIn.java
+
1
−
0
View file @
4dd153c5
...
...
@@ -27,6 +27,7 @@ public class LogIn extends HttpServlet {
req
.
getSession
().
setAttribute
(
"user"
,
user
);
}
else
System
.
out
.
println
(
"session nulle"
);
req
.
getSession
().
setAttribute
(
"password"
,
user
.
getPwd
());
res
.
sendRedirect
(
"http://localhost:8080/s4a021-web-backend/Welcome"
);
}
else
{
out
.
println
(
"<h1>Partez de chez moi ?!</h1>"
);
...
...
This diff is collapsed.
Click to expand it.
WEB-INF/src/dao/UserDAO.java
+
14
−
5
View file @
4dd153c5
...
...
@@ -206,16 +206,23 @@ public class UserDAO {
List
<
Message
>
messages
=
new
ArrayList
<>();
PreparedStatement
ps
=
this
.
con
.
prepareStatement
(
"""
SELECT m.msgID, m.userID_msg, m.threadID, m.msg, m.posted_at FROM msg AS m
INNER JOIN follow AS f
ON m.userID_msg = f.userID_follow
WHERE f.threadID_follow = m.threadID
AND m.userID_msg = ?
ORDER BY m.posted_at DESC
INNER JOIN thread AS t ON m.threadid = t.threadid
WHERE m.threadID IN (
SELECT f.threadid_follow FROM follow AS f
INNER JOIN thread AS t
ON t.threadid = f.threadid_follow
INNER JOIN userAccount AS u
ON u.userid = f.userid_follow
WHERE u.userID = ?)
ORDER BY m.posted_at DESC;
"""
);
try
{
System
.
out
.
println
(
"user id : "
+
user
.
getId
());
ps
.
setInt
(
1
,
user
.
getId
());
System
.
out
.
println
(
"dans le try"
);
ResultSet
rs
=
ps
.
executeQuery
();
while
(
rs
.
next
()){
System
.
out
.
println
(
"dans le while"
);
int
msgID
=
rs
.
getInt
(
1
);
int
sender
=
rs
.
getInt
(
2
);
int
threadID
=
rs
.
getInt
(
3
);
...
...
@@ -225,8 +232,10 @@ public class UserDAO {
}
}
catch
(
SQLException
sqle
)
{
System
.
out
.
println
(
"erreur"
);
sqle
.
getStackTrace
();
}
System
.
out
.
println
(
"test"
);
return
messages
;
}
}
\ No newline at end of file
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