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
01b4afb5
Commit
01b4afb5
authored
Jun 21, 2025
by
健杭 徐
Browse files
main.go func createTable
parent
ba358013
Changes
2
Show whitespace changes
Inline
Side-by-side
myproject/chatroom/main.go
View file @
01b4afb5
...
...
@@ -143,3 +143,28 @@ func GetMessageList(c *gin.Context) {
func
RoomMessageUpdate
(
c
*
gin
.
Context
)
{
// 处理更新房间消息的逻辑
}
func
createTable
()
{
query
:=
`
CREATE TABLE IF NOT EXISTS messages (
message_id SERIAL PRIMARY KEY,
room_id INT NOT NULL,
profile_id INT NOT NULL,
sender VARCHAR(100) NOT NULL,
content TEXT NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS rooms (
room_id SERIAL PRIMARY KEY,
room_name VARCHAR(100) NOT NULL
LAST_MESSAGE TEXT,
LAST_MESSAGE_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
`
_
,
err
:=
db
.
Exec
(
query
)
if
err
!=
nil
{
log
.
Fatal
(
"Failed to create tables: "
,
err
)
}
log
.
Println
(
"Tables created successfully"
)
}
myproject/my-app/src/app/pages/ChatRoom/ChatRoom.tsx
View file @
01b4afb5
'
use client
'
;
import
{
METHODS
}
from
"
http
"
;
import
"
./ChatRoom.css
"
;
import
React
,
{
useState
}
from
"
react
"
;
...
...
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