Merge branch 'dev' of ssh://meowgit.nekoea.red:22222/nihonium/nyanimedb into dev
This commit is contained in:
commit
e67c9a77ce
7 changed files with 293 additions and 134 deletions
|
|
@ -76,6 +76,19 @@ func (q *Queries) DeleteUserTitle(ctx context.Context, arg DeleteUserTitleParams
|
|||
return i, err
|
||||
}
|
||||
|
||||
const getExternalServiceByToken = `-- name: GetExternalServiceByToken :one
|
||||
SELECT id, name, auth_token
|
||||
FROM external_services
|
||||
WHERE auth_token = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetExternalServiceByToken(ctx context.Context, authToken *string) (ExternalService, error) {
|
||||
row := q.db.QueryRow(ctx, getExternalServiceByToken, authToken)
|
||||
var i ExternalService
|
||||
err := row.Scan(&i.ID, &i.Name, &i.AuthToken)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getImageByID = `-- name: GetImageByID :one
|
||||
SELECT id, storage_type, image_path
|
||||
FROM images
|
||||
|
|
@ -240,6 +253,35 @@ func (q *Queries) GetTitleTags(ctx context.Context, titleID int64) ([]json.RawMe
|
|||
return items, nil
|
||||
}
|
||||
|
||||
const getUserByExternalServiceId = `-- name: GetUserByExternalServiceId :one
|
||||
SELECT u.id, u.avatar_id, u.passhash, u.mail, u.nickname, u.disp_name, u.user_desc, u.creation_date, u.last_login
|
||||
FROM users u
|
||||
LEFT JOIN external_ids ei ON eu.user_id = u.id
|
||||
WHERE ei.external_id = $1 AND ei.service_id = $2
|
||||
`
|
||||
|
||||
type GetUserByExternalServiceIdParams struct {
|
||||
ExternalID string `json:"external_id"`
|
||||
ServiceID int64 `json:"service_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetUserByExternalServiceId(ctx context.Context, arg GetUserByExternalServiceIdParams) (User, error) {
|
||||
row := q.db.QueryRow(ctx, getUserByExternalServiceId, arg.ExternalID, arg.ServiceID)
|
||||
var i User
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.AvatarID,
|
||||
&i.Passhash,
|
||||
&i.Mail,
|
||||
&i.Nickname,
|
||||
&i.DispName,
|
||||
&i.UserDesc,
|
||||
&i.CreationDate,
|
||||
&i.LastLogin,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getUserByID = `-- name: GetUserByID :one
|
||||
SELECT
|
||||
t.id as id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue