Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
健杭 徐
intern_project_frontend_backend
Commits
710c0f82
Commit
710c0f82
authored
Jun 24, 2025
by
健杭 徐
Browse files
debugger
parent
98194491
Changes
2
Hide whitespace changes
Inline
Side-by-side
myproject/chatroom/main.go
View file @
710c0f82
...
...
@@ -225,8 +225,8 @@ func AddMessage(c *gin.Context) {
}
query
:=
`
INSERT INTO messages (room_id, profile_id, sender, content)
VALUES ($1, $2, $3, $4)
INSERT INTO messages (room_id, profile_id, sender, content
, "time"
)
VALUES ($1, $2, $3, $4
, NOW()
)
RETURNING message_id
`
var
messageId
int
...
...
@@ -237,7 +237,7 @@ func AddMessage(c *gin.Context) {
}
_
,
err
=
db
.
Exec
(
"UPDATE rooms SET last
_s
ender = $1, last
_c
ontent = $2, last
_t
ime = NOW() WHERE room_id = $3"
,
"UPDATE rooms SET
last
S
ender = $1, last
C
ontent = $2, last
T
ime = NOW() WHERE room_id = $3"
,
message
.
Sender
,
message
.
Content
,
message
.
RoomId
,
)
if
err
!=
nil
{
...
...
myproject/my-app/src/app/pages/ChatRoom/ChatRoom.tsx
View file @
710c0f82
...
...
@@ -82,6 +82,7 @@ function InputRoomNameArea({ onAddNewRoom }: { onAddNewRoom: (roomName: string)
className
=
"RoomNameInput"
placeholder
=
"Start new chat"
value
=
{
roomNameInput
}
onChange
=
{
(
e
)
=>
setRoomNameInput
(
e
.
target
.
value
)
}
onKeyUpCapture
=
{
(
e
:
React
.
KeyboardEvent
<
HTMLInputElement
>
)
=>
{
if
(
e
.
key
===
'
Enter
'
)
{
handleAddNewRoom
();
...
...
@@ -223,6 +224,7 @@ export function ChatRoom({ userName }: { userName: string }) {
try
{
const
response
=
await
fetch
(
backEnd
+
`/room/message/list?roomId=
${
roomId
}
`
)
const
result
=
await
response
.
json
();
debugger
;
if
(
result
.
code
===
0
)
{
setCurrentRoom
({
...
...
@@ -301,7 +303,7 @@ export function ChatRoom({ userName }: { userName: string }) {
})
const
result
=
await
response
.
json
();
if
(
result
.
C
ode
!=
0
)
{
if
(
result
.
c
ode
!=
0
)
{
alert
(
`Error:
${
result
.
Msg
}
`
);
return
;
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment