u
This commit is contained in:
1 parent
4dcac7b5a0
commit
59d3be2299
25 files changed
+380
-125
No files matched your search
@@ -18,19 +18,21 @@ SET role = $1
|
||||
WHERE user_id = $2
|
||||
AND space_id = $3;
|
||||
|
||||
-- 获取空间下的所有用户信息
|
||||
-- 获取空间下的所有用户信息(按 role, active_time, username 排序)
|
||||
-- name: ListSpaceUsers :many
|
||||
SELECT
|
||||
u.id as user_id,
|
||||
u.id AS user_id,
|
||||
u.username,
|
||||
u.active_time,
|
||||
su.role,
|
||||
su.join_time
|
||||
FROM space_user su
|
||||
JOIN space s ON su.space_id = s.id
|
||||
JOIN user_info u ON su.user_id = u.id
|
||||
WHERE s.id = $1
|
||||
ORDER BY su.join_time ASC;
|
||||
|
||||
ORDER BY su.role ASC,
|
||||
u.active_time DESC,
|
||||
u.username ASC;
|
||||
|
||||
-- name: GetSpaceUserByUserId :one
|
||||
SELECT * FROM space_user WHERE user_id = $1;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- 插入用户并返回刚创建的记录
|
||||
-- name: InsertUser :execrows
|
||||
INSERT INTO user_info (id, account, password)
|
||||
VALUES ($1, $2, $3);
|
||||
INSERT INTO user_info (id, account, password,username)
|
||||
VALUES ($1, $2, $3,$4);
|
||||
|
||||
-- 根据 ID 查询单条用户记录
|
||||
-- name: GetUserById :one
|
||||
@@ -23,8 +23,13 @@ WHERE account = $1
|
||||
AND password = $2;
|
||||
|
||||
-- 更新用户最后登录时间,并返回更新后的记录
|
||||
-- name: UpdateUserLoginLastTime :execrows
|
||||
-- name: UpdateUserLoginLastTime :exec
|
||||
UPDATE user_info
|
||||
SET last_login_time = now()
|
||||
WHERE id = $1;
|
||||
|
||||
-- 更新用户活跃时间
|
||||
-- name: UpdateUserActiveTime :exec
|
||||
UPDATE user_info
|
||||
SET active_time = now()
|
||||
WHERE id = $1;
|
||||
Reference in new issue
Block a user