|
|
|
@@ -329,20 +329,20 @@ func (q *Queries) CreateDevice(ctx context.Context, arg CreateDeviceParams) (Dev
|
|
|
|
|
|
|
|
|
|
const CreateDeviceCatalog = `-- name: CreateDeviceCatalog :one
|
|
|
|
|
|
|
|
|
|
INSERT INTO device_catalogs (device_id, media_item_id, bookmann_uuid, kobo_content_id, content_id_type, available, delivery_date, delivery_method)
|
|
|
|
|
INSERT INTO device_catalogs (device_id, media_item_id, bookhoard_uuid, kobo_content_id, content_id_type, available, delivery_date, delivery_method)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
|
|
|
ON CONFLICT (device_id, kobo_content_id)
|
|
|
|
|
DO UPDATE SET
|
|
|
|
|
available = EXCLUDED.available,
|
|
|
|
|
delivery_date = COALESCE(EXCLUDED.delivery_date, device_catalogs.delivery_date),
|
|
|
|
|
delivery_method = EXCLUDED.delivery_method
|
|
|
|
|
RETURNING id, device_id, media_item_id, bookmann_uuid, kobo_content_id, content_id_type, available, delivery_date, delivery_method
|
|
|
|
|
RETURNING id, device_id, media_item_id, bookhoard_uuid, kobo_content_id, content_id_type, available, delivery_date, delivery_method
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type CreateDeviceCatalogParams struct {
|
|
|
|
|
DeviceID pgtype.UUID `db:"device_id" json:"device_id"`
|
|
|
|
|
MediaItemID pgtype.UUID `db:"media_item_id" json:"media_item_id"`
|
|
|
|
|
BookmannUuid pgtype.UUID `db:"bookmann_uuid" json:"bookmann_uuid"`
|
|
|
|
|
BookmannUuid pgtype.UUID `db:"bookhoard_uuid" json:"bookhoard_uuid"`
|
|
|
|
|
KoboContentID string `db:"kobo_content_id" json:"kobo_content_id"`
|
|
|
|
|
ContentIDType pgtype.Text `db:"content_id_type" json:"content_id_type"`
|
|
|
|
|
Available pgtype.Bool `db:"available" json:"available"`
|
|
|
|
@@ -1819,18 +1819,18 @@ func (q *Queries) GetDeviceByIdentifier(ctx context.Context, deviceIdentifier st
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GetDeviceCatalogByBookmannUUID = `-- name: GetDeviceCatalogByBookmannUUID :one
|
|
|
|
|
SELECT id, device_id, media_item_id, bookmann_uuid, kobo_content_id, content_id_type, available, delivery_date, delivery_method FROM device_catalogs WHERE device_id = $1 AND bookmann_uuid = $2
|
|
|
|
|
const GetDeviceCatalogByBookhoardUUID = `-- name: GetDeviceCatalogByBookhoardUUID :one
|
|
|
|
|
SELECT id, device_id, media_item_id, bookhoard_uuid, kobo_content_id, content_id_type, available, delivery_date, delivery_method FROM device_catalogs WHERE device_id = $1 AND bookhoard_uuid = $2
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type GetDeviceCatalogByBookmannUUIDParams struct {
|
|
|
|
|
type GetDeviceCatalogByBookhoardUUIDParams struct {
|
|
|
|
|
DeviceID pgtype.UUID `db:"device_id" json:"device_id"`
|
|
|
|
|
BookmannUuid pgtype.UUID `db:"bookmann_uuid" json:"bookmann_uuid"`
|
|
|
|
|
BookmannUuid pgtype.UUID `db:"bookhoard_uuid" json:"bookhoard_uuid"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get device catalog by Bookmann UUID
|
|
|
|
|
func (q *Queries) GetDeviceCatalogByBookmannUUID(ctx context.Context, arg GetDeviceCatalogByBookmannUUIDParams) (DeviceCatalogs, error) {
|
|
|
|
|
row := q.db.QueryRow(ctx, GetDeviceCatalogByBookmannUUID, arg.DeviceID, arg.BookmannUuid)
|
|
|
|
|
func (q *Queries) GetDeviceCatalogByBookhoardUUID(ctx context.Context, arg GetDeviceCatalogByBookhoardUUIDParams) (DeviceCatalogs, error) {
|
|
|
|
|
row := q.db.QueryRow(ctx, GetDeviceCatalogByBookhoardUUID, arg.DeviceID, arg.BookmannUuid)
|
|
|
|
|
var i DeviceCatalogs
|
|
|
|
|
err := row.Scan(
|
|
|
|
|
&i.ID,
|
|
|
|
@@ -1847,7 +1847,7 @@ func (q *Queries) GetDeviceCatalogByBookmannUUID(ctx context.Context, arg GetDev
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GetDeviceCatalogByKoboContentId = `-- name: GetDeviceCatalogByKoboContentId :one
|
|
|
|
|
SELECT id, device_id, media_item_id, bookmann_uuid, kobo_content_id, content_id_type, available, delivery_date, delivery_method FROM device_catalogs WHERE kobo_content_id = $1
|
|
|
|
|
SELECT id, device_id, media_item_id, bookhoard_uuid, kobo_content_id, content_id_type, available, delivery_date, delivery_method FROM device_catalogs WHERE kobo_content_id = $1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
// Get device catalog by Kobo ContentId
|
|
|
|
@@ -1869,7 +1869,7 @@ func (q *Queries) GetDeviceCatalogByKoboContentId(ctx context.Context, koboConte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GetDeviceCatalogEntries = `-- name: GetDeviceCatalogEntries :many
|
|
|
|
|
SELECT dc.id, dc.device_id, dc.media_item_id, dc.bookmann_uuid, dc.kobo_content_id, dc.content_id_type, dc.available, dc.delivery_date, dc.delivery_method, mi.title, mi.author
|
|
|
|
|
SELECT dc.id, dc.device_id, dc.media_item_id, dc.bookhoard_uuid, dc.kobo_content_id, dc.content_id_type, dc.available, dc.delivery_date, dc.delivery_method, mi.title, mi.author
|
|
|
|
|
FROM device_catalogs dc
|
|
|
|
|
JOIN media_items mi ON dc.media_item_id = mi.id
|
|
|
|
|
WHERE dc.device_id = $1 AND dc.available = true
|
|
|
|
@@ -1880,7 +1880,7 @@ type GetDeviceCatalogEntriesRow struct {
|
|
|
|
|
ID pgtype.UUID `db:"id" json:"id"`
|
|
|
|
|
DeviceID pgtype.UUID `db:"device_id" json:"device_id"`
|
|
|
|
|
MediaItemID pgtype.UUID `db:"media_item_id" json:"media_item_id"`
|
|
|
|
|
BookmannUuid pgtype.UUID `db:"bookmann_uuid" json:"bookmann_uuid"`
|
|
|
|
|
BookmannUuid pgtype.UUID `db:"bookhoard_uuid" json:"bookhoard_uuid"`
|
|
|
|
|
KoboContentID string `db:"kobo_content_id" json:"kobo_content_id"`
|
|
|
|
|
ContentIDType pgtype.Text `db:"content_id_type" json:"content_id_type"`
|
|
|
|
|
Available pgtype.Bool `db:"available" json:"available"`
|
|
|
|
|