- OpenAPI: add missing endpoints (add-from-url, subscriptions, public availability) - OpenAPI: CalendarSubscription schema, Subscriptions tag - Frontend app - Migrations: count_for_availability, subscriptions_sync, user_preferences, calendar_settings - Config, rate limit, auth, calendar, booking, ICS, availability, user service updates Made-with: Cursor
256 lines
9.3 KiB
Go
256 lines
9.3 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: users.sql
|
|
|
|
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createUser = `-- name: CreateUser :one
|
|
INSERT INTO users (id, email, password_hash, timezone)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING id, email, password_hash, timezone, is_active, created_at, updated_at
|
|
`
|
|
|
|
type CreateUserParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Email string `json:"email"`
|
|
PasswordHash string `json:"password_hash"`
|
|
Timezone string `json:"timezone"`
|
|
}
|
|
|
|
type CreateUserRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Email string `json:"email"`
|
|
PasswordHash string `json:"password_hash"`
|
|
Timezone string `json:"timezone"`
|
|
IsActive bool `json:"is_active"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (CreateUserRow, error) {
|
|
row := q.db.QueryRow(ctx, createUser,
|
|
arg.ID,
|
|
arg.Email,
|
|
arg.PasswordHash,
|
|
arg.Timezone,
|
|
)
|
|
var i CreateUserRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.Timezone,
|
|
&i.IsActive,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByEmail = `-- name: GetUserByEmail :one
|
|
SELECT id, email, password_hash, timezone, is_active, week_start_day, date_format, time_format,
|
|
default_event_duration_minutes, default_reminder_minutes, show_weekends,
|
|
working_hours_start, working_hours_end, notifications_email, created_at, updated_at
|
|
FROM users
|
|
WHERE email = $1 AND deleted_at IS NULL
|
|
`
|
|
|
|
type GetUserByEmailRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Email string `json:"email"`
|
|
PasswordHash string `json:"password_hash"`
|
|
Timezone string `json:"timezone"`
|
|
IsActive bool `json:"is_active"`
|
|
WeekStartDay int16 `json:"week_start_day"`
|
|
DateFormat string `json:"date_format"`
|
|
TimeFormat string `json:"time_format"`
|
|
DefaultEventDurationMinutes int32 `json:"default_event_duration_minutes"`
|
|
DefaultReminderMinutes int32 `json:"default_reminder_minutes"`
|
|
ShowWeekends bool `json:"show_weekends"`
|
|
WorkingHoursStart string `json:"working_hours_start"`
|
|
WorkingHoursEnd string `json:"working_hours_end"`
|
|
NotificationsEmail bool `json:"notifications_email"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) GetUserByEmail(ctx context.Context, email string) (GetUserByEmailRow, error) {
|
|
row := q.db.QueryRow(ctx, getUserByEmail, email)
|
|
var i GetUserByEmailRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.Timezone,
|
|
&i.IsActive,
|
|
&i.WeekStartDay,
|
|
&i.DateFormat,
|
|
&i.TimeFormat,
|
|
&i.DefaultEventDurationMinutes,
|
|
&i.DefaultReminderMinutes,
|
|
&i.ShowWeekends,
|
|
&i.WorkingHoursStart,
|
|
&i.WorkingHoursEnd,
|
|
&i.NotificationsEmail,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getUserByID = `-- name: GetUserByID :one
|
|
SELECT id, email, password_hash, timezone, is_active, week_start_day, date_format, time_format,
|
|
default_event_duration_minutes, default_reminder_minutes, show_weekends,
|
|
working_hours_start, working_hours_end, notifications_email, created_at, updated_at
|
|
FROM users
|
|
WHERE id = $1 AND deleted_at IS NULL
|
|
`
|
|
|
|
type GetUserByIDRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Email string `json:"email"`
|
|
PasswordHash string `json:"password_hash"`
|
|
Timezone string `json:"timezone"`
|
|
IsActive bool `json:"is_active"`
|
|
WeekStartDay int16 `json:"week_start_day"`
|
|
DateFormat string `json:"date_format"`
|
|
TimeFormat string `json:"time_format"`
|
|
DefaultEventDurationMinutes int32 `json:"default_event_duration_minutes"`
|
|
DefaultReminderMinutes int32 `json:"default_reminder_minutes"`
|
|
ShowWeekends bool `json:"show_weekends"`
|
|
WorkingHoursStart string `json:"working_hours_start"`
|
|
WorkingHoursEnd string `json:"working_hours_end"`
|
|
NotificationsEmail bool `json:"notifications_email"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (GetUserByIDRow, error) {
|
|
row := q.db.QueryRow(ctx, getUserByID, id)
|
|
var i GetUserByIDRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.Timezone,
|
|
&i.IsActive,
|
|
&i.WeekStartDay,
|
|
&i.DateFormat,
|
|
&i.TimeFormat,
|
|
&i.DefaultEventDurationMinutes,
|
|
&i.DefaultReminderMinutes,
|
|
&i.ShowWeekends,
|
|
&i.WorkingHoursStart,
|
|
&i.WorkingHoursEnd,
|
|
&i.NotificationsEmail,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const softDeleteUser = `-- name: SoftDeleteUser :exec
|
|
UPDATE users SET deleted_at = now(), is_active = false, updated_at = now()
|
|
WHERE id = $1 AND deleted_at IS NULL
|
|
`
|
|
|
|
func (q *Queries) SoftDeleteUser(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, softDeleteUser, id)
|
|
return err
|
|
}
|
|
|
|
const updateUser = `-- name: UpdateUser :one
|
|
UPDATE users
|
|
SET timezone = COALESCE($1::TEXT, timezone),
|
|
week_start_day = COALESCE($2::SMALLINT, week_start_day),
|
|
date_format = COALESCE($3::TEXT, date_format),
|
|
time_format = COALESCE($4::TEXT, time_format),
|
|
default_event_duration_minutes = COALESCE($5::INTEGER, default_event_duration_minutes),
|
|
default_reminder_minutes = COALESCE($6::INTEGER, default_reminder_minutes),
|
|
show_weekends = COALESCE($7::BOOLEAN, show_weekends),
|
|
working_hours_start = COALESCE($8::TEXT, working_hours_start),
|
|
working_hours_end = COALESCE($9::TEXT, working_hours_end),
|
|
notifications_email = COALESCE($10::BOOLEAN, notifications_email),
|
|
updated_at = now()
|
|
WHERE id = $11 AND deleted_at IS NULL
|
|
RETURNING id, email, password_hash, timezone, is_active, week_start_day, date_format, time_format,
|
|
default_event_duration_minutes, default_reminder_minutes, show_weekends,
|
|
working_hours_start, working_hours_end, notifications_email, created_at, updated_at
|
|
`
|
|
|
|
type UpdateUserParams struct {
|
|
Timezone pgtype.Text `json:"timezone"`
|
|
WeekStartDay pgtype.Int2 `json:"week_start_day"`
|
|
DateFormat pgtype.Text `json:"date_format"`
|
|
TimeFormat pgtype.Text `json:"time_format"`
|
|
DefaultEventDurationMinutes pgtype.Int4 `json:"default_event_duration_minutes"`
|
|
DefaultReminderMinutes pgtype.Int4 `json:"default_reminder_minutes"`
|
|
ShowWeekends pgtype.Bool `json:"show_weekends"`
|
|
WorkingHoursStart pgtype.Text `json:"working_hours_start"`
|
|
WorkingHoursEnd pgtype.Text `json:"working_hours_end"`
|
|
NotificationsEmail pgtype.Bool `json:"notifications_email"`
|
|
ID pgtype.UUID `json:"id"`
|
|
}
|
|
|
|
type UpdateUserRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Email string `json:"email"`
|
|
PasswordHash string `json:"password_hash"`
|
|
Timezone string `json:"timezone"`
|
|
IsActive bool `json:"is_active"`
|
|
WeekStartDay int16 `json:"week_start_day"`
|
|
DateFormat string `json:"date_format"`
|
|
TimeFormat string `json:"time_format"`
|
|
DefaultEventDurationMinutes int32 `json:"default_event_duration_minutes"`
|
|
DefaultReminderMinutes int32 `json:"default_reminder_minutes"`
|
|
ShowWeekends bool `json:"show_weekends"`
|
|
WorkingHoursStart string `json:"working_hours_start"`
|
|
WorkingHoursEnd string `json:"working_hours_end"`
|
|
NotificationsEmail bool `json:"notifications_email"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (UpdateUserRow, error) {
|
|
row := q.db.QueryRow(ctx, updateUser,
|
|
arg.Timezone,
|
|
arg.WeekStartDay,
|
|
arg.DateFormat,
|
|
arg.TimeFormat,
|
|
arg.DefaultEventDurationMinutes,
|
|
arg.DefaultReminderMinutes,
|
|
arg.ShowWeekends,
|
|
arg.WorkingHoursStart,
|
|
arg.WorkingHoursEnd,
|
|
arg.NotificationsEmail,
|
|
arg.ID,
|
|
)
|
|
var i UpdateUserRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Email,
|
|
&i.PasswordHash,
|
|
&i.Timezone,
|
|
&i.IsActive,
|
|
&i.WeekStartDay,
|
|
&i.DateFormat,
|
|
&i.TimeFormat,
|
|
&i.DefaultEventDurationMinutes,
|
|
&i.DefaultReminderMinutes,
|
|
&i.ShowWeekends,
|
|
&i.WorkingHoursStart,
|
|
&i.WorkingHoursEnd,
|
|
&i.NotificationsEmail,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|