Merge branch 'dev' into auth
This commit is contained in:
commit
3afd4e2e86
78 changed files with 3524 additions and 1635 deletions
|
|
@ -142,7 +142,7 @@ func (q *Queries) GetStudioByID(ctx context.Context, studioID int64) (Studio, er
|
|||
|
||||
const getTitleByID = `-- name: GetTitleByID :one
|
||||
SELECT
|
||||
t.id, t.title_names, t.studio_id, t.poster_id, t.title_status, t.rating, t.rating_count, t.release_year, t.release_season, t.season, t.episodes_aired, t.episodes_all, t.episodes_len,
|
||||
t.id, t.title_names, t.title_desc, t.studio_id, t.poster_id, t.title_status, t.rating, t.rating_count, t.release_year, t.release_season, t.season, t.episodes_aired, t.episodes_all, t.episodes_len,
|
||||
i.storage_type as title_storage_type,
|
||||
i.image_path as title_image_path,
|
||||
COALESCE(
|
||||
|
|
@ -170,6 +170,7 @@ GROUP BY
|
|||
type GetTitleByIDRow struct {
|
||||
ID int64 `json:"id"`
|
||||
TitleNames json.RawMessage `json:"title_names"`
|
||||
TitleDesc []byte `json:"title_desc"`
|
||||
StudioID int64 `json:"studio_id"`
|
||||
PosterID *int64 `json:"poster_id"`
|
||||
TitleStatus TitleStatusT `json:"title_status"`
|
||||
|
|
@ -198,6 +199,7 @@ func (q *Queries) GetTitleByID(ctx context.Context, titleID int64) (GetTitleByID
|
|||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.TitleNames,
|
||||
&i.TitleDesc,
|
||||
&i.StudioID,
|
||||
&i.PosterID,
|
||||
&i.TitleStatus,
|
||||
|
|
@ -651,6 +653,87 @@ func (q *Queries) SearchTitles(ctx context.Context, arg SearchTitlesParams) ([]S
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const searchUser = `-- 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
|
||||
(
|
||||
$1::text IS NULL
|
||||
OR (
|
||||
SELECT bool_and(
|
||||
u.nickname ILIKE ('%' || term || '%')
|
||||
OR u.disp_name ILIKE ('%' || term || '%')
|
||||
)
|
||||
FROM unnest(string_to_array(trim($1::text), ' ')) AS term
|
||||
WHERE term <> ''
|
||||
)
|
||||
)
|
||||
AND (
|
||||
$2::int IS NULL
|
||||
OR u.id > $2::int
|
||||
)
|
||||
ORDER BY u.id ASC
|
||||
LIMIT COALESCE($3::int, 20)
|
||||
`
|
||||
|
||||
type SearchUserParams struct {
|
||||
Word *string `json:"word"`
|
||||
Cursor *int32 `json:"cursor"`
|
||||
Limit *int32 `json:"limit"`
|
||||
}
|
||||
|
||||
type SearchUserRow struct {
|
||||
ID int64 `json:"id"`
|
||||
AvatarID *int64 `json:"avatar_id"`
|
||||
Mail *string `json:"mail"`
|
||||
Nickname string `json:"nickname"`
|
||||
DispName *string `json:"disp_name"`
|
||||
UserDesc *string `json:"user_desc"`
|
||||
CreationDate time.Time `json:"creation_date"`
|
||||
StorageType *StorageTypeT `json:"storage_type"`
|
||||
ImagePath *string `json:"image_path"`
|
||||
}
|
||||
|
||||
func (q *Queries) SearchUser(ctx context.Context, arg SearchUserParams) ([]SearchUserRow, error) {
|
||||
rows, err := q.db.Query(ctx, searchUser, arg.Word, arg.Cursor, arg.Limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []SearchUserRow{}
|
||||
for rows.Next() {
|
||||
var i SearchUserRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.AvatarID,
|
||||
&i.Mail,
|
||||
&i.Nickname,
|
||||
&i.DispName,
|
||||
&i.UserDesc,
|
||||
&i.CreationDate,
|
||||
&i.StorageType,
|
||||
&i.ImagePath,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const searchUserTitles = `-- name: SearchUserTitles :many
|
||||
|
||||
SELECT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue