mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
06e8619a37
Align channel identity and bind flow across backend and app-facing layers, including generated swagger artifacts and package lock updates while excluding docs content changes.
250 lines
6.7 KiB
Go
250 lines
6.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: channel_identities.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const clearChannelIdentityLinkedUser = `-- name: ClearChannelIdentityLinkedUser :one
|
|
UPDATE channel_identities
|
|
SET user_id = NULL, updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, user_id, channel, channel_subject_id, display_name, metadata, created_at, updated_at
|
|
`
|
|
|
|
func (q *Queries) ClearChannelIdentityLinkedUser(ctx context.Context, id pgtype.UUID) (ChannelIdentity, error) {
|
|
row := q.db.QueryRow(ctx, clearChannelIdentityLinkedUser, id)
|
|
var i ChannelIdentity
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Channel,
|
|
&i.ChannelSubjectID,
|
|
&i.DisplayName,
|
|
&i.Metadata,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createChannelIdentity = `-- name: CreateChannelIdentity :one
|
|
INSERT INTO channel_identities (user_id, channel, channel_subject_id, display_name, metadata)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
RETURNING id, user_id, channel, channel_subject_id, display_name, metadata, created_at, updated_at
|
|
`
|
|
|
|
type CreateChannelIdentityParams struct {
|
|
UserID pgtype.UUID `json:"user_id"`
|
|
Channel string `json:"channel"`
|
|
ChannelSubjectID string `json:"channel_subject_id"`
|
|
DisplayName pgtype.Text `json:"display_name"`
|
|
Metadata []byte `json:"metadata"`
|
|
}
|
|
|
|
func (q *Queries) CreateChannelIdentity(ctx context.Context, arg CreateChannelIdentityParams) (ChannelIdentity, error) {
|
|
row := q.db.QueryRow(ctx, createChannelIdentity,
|
|
arg.UserID,
|
|
arg.Channel,
|
|
arg.ChannelSubjectID,
|
|
arg.DisplayName,
|
|
arg.Metadata,
|
|
)
|
|
var i ChannelIdentity
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Channel,
|
|
&i.ChannelSubjectID,
|
|
&i.DisplayName,
|
|
&i.Metadata,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getChannelIdentityByChannelSubject = `-- name: GetChannelIdentityByChannelSubject :one
|
|
SELECT id, user_id, channel, channel_subject_id, display_name, metadata, created_at, updated_at
|
|
FROM channel_identities
|
|
WHERE channel = $1 AND channel_subject_id = $2
|
|
`
|
|
|
|
type GetChannelIdentityByChannelSubjectParams struct {
|
|
Channel string `json:"channel"`
|
|
ChannelSubjectID string `json:"channel_subject_id"`
|
|
}
|
|
|
|
func (q *Queries) GetChannelIdentityByChannelSubject(ctx context.Context, arg GetChannelIdentityByChannelSubjectParams) (ChannelIdentity, error) {
|
|
row := q.db.QueryRow(ctx, getChannelIdentityByChannelSubject, arg.Channel, arg.ChannelSubjectID)
|
|
var i ChannelIdentity
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Channel,
|
|
&i.ChannelSubjectID,
|
|
&i.DisplayName,
|
|
&i.Metadata,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getChannelIdentityByID = `-- name: GetChannelIdentityByID :one
|
|
SELECT id, user_id, channel, channel_subject_id, display_name, metadata, created_at, updated_at
|
|
FROM channel_identities
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetChannelIdentityByID(ctx context.Context, id pgtype.UUID) (ChannelIdentity, error) {
|
|
row := q.db.QueryRow(ctx, getChannelIdentityByID, id)
|
|
var i ChannelIdentity
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Channel,
|
|
&i.ChannelSubjectID,
|
|
&i.DisplayName,
|
|
&i.Metadata,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getChannelIdentityByIDForUpdate = `-- name: GetChannelIdentityByIDForUpdate :one
|
|
SELECT id, user_id, channel, channel_subject_id, display_name, metadata, created_at, updated_at
|
|
FROM channel_identities
|
|
WHERE id = $1
|
|
FOR UPDATE
|
|
`
|
|
|
|
func (q *Queries) GetChannelIdentityByIDForUpdate(ctx context.Context, id pgtype.UUID) (ChannelIdentity, error) {
|
|
row := q.db.QueryRow(ctx, getChannelIdentityByIDForUpdate, id)
|
|
var i ChannelIdentity
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Channel,
|
|
&i.ChannelSubjectID,
|
|
&i.DisplayName,
|
|
&i.Metadata,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listChannelIdentitiesByUserID = `-- name: ListChannelIdentitiesByUserID :many
|
|
SELECT id, user_id, channel, channel_subject_id, display_name, metadata, created_at, updated_at
|
|
FROM channel_identities
|
|
WHERE user_id = $1
|
|
ORDER BY created_at DESC
|
|
`
|
|
|
|
func (q *Queries) ListChannelIdentitiesByUserID(ctx context.Context, userID pgtype.UUID) ([]ChannelIdentity, error) {
|
|
rows, err := q.db.Query(ctx, listChannelIdentitiesByUserID, userID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ChannelIdentity
|
|
for rows.Next() {
|
|
var i ChannelIdentity
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Channel,
|
|
&i.ChannelSubjectID,
|
|
&i.DisplayName,
|
|
&i.Metadata,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const setChannelIdentityLinkedUser = `-- name: SetChannelIdentityLinkedUser :one
|
|
UPDATE channel_identities
|
|
SET user_id = $2, updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, user_id, channel, channel_subject_id, display_name, metadata, created_at, updated_at
|
|
`
|
|
|
|
type SetChannelIdentityLinkedUserParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
UserID pgtype.UUID `json:"user_id"`
|
|
}
|
|
|
|
func (q *Queries) SetChannelIdentityLinkedUser(ctx context.Context, arg SetChannelIdentityLinkedUserParams) (ChannelIdentity, error) {
|
|
row := q.db.QueryRow(ctx, setChannelIdentityLinkedUser, arg.ID, arg.UserID)
|
|
var i ChannelIdentity
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Channel,
|
|
&i.ChannelSubjectID,
|
|
&i.DisplayName,
|
|
&i.Metadata,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const upsertChannelIdentityByChannelSubject = `-- name: UpsertChannelIdentityByChannelSubject :one
|
|
INSERT INTO channel_identities (user_id, channel, channel_subject_id, display_name, metadata)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
ON CONFLICT (channel, channel_subject_id)
|
|
DO UPDATE SET
|
|
display_name = EXCLUDED.display_name,
|
|
metadata = EXCLUDED.metadata,
|
|
user_id = COALESCE(channel_identities.user_id, EXCLUDED.user_id),
|
|
updated_at = now()
|
|
RETURNING id, user_id, channel, channel_subject_id, display_name, metadata, created_at, updated_at
|
|
`
|
|
|
|
type UpsertChannelIdentityByChannelSubjectParams struct {
|
|
UserID pgtype.UUID `json:"user_id"`
|
|
Channel string `json:"channel"`
|
|
ChannelSubjectID string `json:"channel_subject_id"`
|
|
DisplayName pgtype.Text `json:"display_name"`
|
|
Metadata []byte `json:"metadata"`
|
|
}
|
|
|
|
func (q *Queries) UpsertChannelIdentityByChannelSubject(ctx context.Context, arg UpsertChannelIdentityByChannelSubjectParams) (ChannelIdentity, error) {
|
|
row := q.db.QueryRow(ctx, upsertChannelIdentityByChannelSubject,
|
|
arg.UserID,
|
|
arg.Channel,
|
|
arg.ChannelSubjectID,
|
|
arg.DisplayName,
|
|
arg.Metadata,
|
|
)
|
|
var i ChannelIdentity
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.Channel,
|
|
&i.ChannelSubjectID,
|
|
&i.DisplayName,
|
|
&i.Metadata,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|