feat: handler for get /users is implemented
This commit is contained in:
parent
fe18c0d865
commit
6a5994e33e
2 changed files with 67 additions and 0 deletions
|
|
@ -23,6 +23,37 @@ FROM users as t
|
|||
LEFT JOIN images as i ON (t.avatar_id = i.id)
|
||||
WHERE t.id = sqlc.arg('id')::bigint;
|
||||
|
||||
-- name: SearchUser :many
|
||||
SELECT
|
||||
u.id AS id,
|
||||
u.avatar_id AS avatar_id,
|
||||
u.mail AS mail,
|
||||
u.nickname AS nickname,
|
||||
u.disp_name AS disp_name,
|
||||
u.user_desc AS user_desc,
|
||||
u.creation_date AS creation_date,
|
||||
i.storage_type AS storage_type,
|
||||
i.image_path AS image_path
|
||||
FROM users AS u
|
||||
LEFT JOIN images AS i ON u.avatar_id = i.id
|
||||
WHERE
|
||||
(
|
||||
sqlc.narg('word')::text IS NULL
|
||||
OR (
|
||||
SELECT bool_and(
|
||||
u.nickname ILIKE ('%' || term || '%')
|
||||
OR u.disp_name ILIKE ('%' || term || '%')
|
||||
)
|
||||
FROM unnest(string_to_array(trim(sqlc.narg('word')::text), ' ')) AS term
|
||||
WHERE term <> ''
|
||||
)
|
||||
)
|
||||
AND (
|
||||
sqlc.narg('cursor')::int IS NULL
|
||||
OR u.id > sqlc.narg('cursor')::int
|
||||
)
|
||||
ORDER BY u.id ASC
|
||||
LIMIT COALESCE(sqlc.narg('limit')::int, 20);
|
||||
|
||||
-- name: GetStudioByID :one
|
||||
SELECT *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue