Started working on the view upload page
This commit is contained in:
parent
0a9af9cde8
commit
48f39133d7
18 changed files with 327 additions and 45 deletions
|
|
@ -5,7 +5,7 @@
|
|||
package sqlgen
|
||||
|
||||
type PendingUpload struct {
|
||||
ID interface{}
|
||||
ID int64
|
||||
SiteID int64
|
||||
Guid string
|
||||
UserID int64
|
||||
|
|
@ -50,12 +50,13 @@ type Site struct {
|
|||
}
|
||||
|
||||
type Upload struct {
|
||||
ID interface{}
|
||||
ID int64
|
||||
SiteID int64
|
||||
Guid string
|
||||
MimeType string
|
||||
Filename string
|
||||
FileSize int64
|
||||
Slug string
|
||||
Alt string
|
||||
CreatedAt int64
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ type InsertPendingUploadParams struct {
|
|||
UploadStartedAt int64
|
||||
}
|
||||
|
||||
func (q *Queries) InsertPendingUpload(ctx context.Context, arg InsertPendingUploadParams) (interface{}, error) {
|
||||
func (q *Queries) InsertPendingUpload(ctx context.Context, arg InsertPendingUploadParams) (int64, error) {
|
||||
row := q.db.QueryRowContext(ctx, insertPendingUpload,
|
||||
arg.SiteID,
|
||||
arg.Guid,
|
||||
|
|
@ -51,7 +51,7 @@ func (q *Queries) InsertPendingUpload(ctx context.Context, arg InsertPendingUplo
|
|||
arg.MimeType,
|
||||
arg.UploadStartedAt,
|
||||
)
|
||||
var id interface{}
|
||||
var id int64
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const deleteUpload = `-- name: DeleteUpload :exec
|
|||
DELETE FROM uploads WHERE id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) DeleteUpload(ctx context.Context, id interface{}) error {
|
||||
func (q *Queries) DeleteUpload(ctx context.Context, id int64) error {
|
||||
_, err := q.db.ExecContext(ctx, deleteUpload, id)
|
||||
return err
|
||||
}
|
||||
|
|
@ -24,9 +24,11 @@ INSERT INTO uploads (
|
|||
guid,
|
||||
mime_type,
|
||||
filename,
|
||||
created_at,
|
||||
alt
|
||||
) VALUES (?, ?, ?, ?, ?, ?)
|
||||
file_size,
|
||||
slug,
|
||||
alt,
|
||||
created_at
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
RETURNING id
|
||||
`
|
||||
|
||||
|
|
@ -35,8 +37,10 @@ type InsertUploadParams struct {
|
|||
Guid string
|
||||
MimeType string
|
||||
Filename string
|
||||
CreatedAt int64
|
||||
FileSize int64
|
||||
Slug string
|
||||
Alt string
|
||||
CreatedAt int64
|
||||
}
|
||||
|
||||
func (q *Queries) InsertUpload(ctx context.Context, arg InsertUploadParams) error {
|
||||
|
|
@ -45,17 +49,19 @@ func (q *Queries) InsertUpload(ctx context.Context, arg InsertUploadParams) erro
|
|||
arg.Guid,
|
||||
arg.MimeType,
|
||||
arg.Filename,
|
||||
arg.CreatedAt,
|
||||
arg.FileSize,
|
||||
arg.Slug,
|
||||
arg.Alt,
|
||||
arg.CreatedAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const selectUploadByID = `-- name: SelectUploadByID :one
|
||||
SELECT id, site_id, guid, mime_type, filename, file_size, alt, created_at FROM uploads WHERE id = ?
|
||||
SELECT id, site_id, guid, mime_type, filename, file_size, slug, alt, created_at FROM uploads WHERE id = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) SelectUploadByID(ctx context.Context, id interface{}) (Upload, error) {
|
||||
func (q *Queries) SelectUploadByID(ctx context.Context, id int64) (Upload, error) {
|
||||
row := q.db.QueryRowContext(ctx, selectUploadByID, id)
|
||||
var i Upload
|
||||
err := row.Scan(
|
||||
|
|
@ -65,6 +71,33 @@ func (q *Queries) SelectUploadByID(ctx context.Context, id interface{}) (Upload,
|
|||
&i.MimeType,
|
||||
&i.Filename,
|
||||
&i.FileSize,
|
||||
&i.Slug,
|
||||
&i.Alt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const selectUploadBySiteIDAndSlug = `-- name: SelectUploadBySiteIDAndSlug :one
|
||||
SELECT id, site_id, guid, mime_type, filename, file_size, slug, alt, created_at FROM uploads WHERE site_id = ? AND slug = ? LIMIT 1
|
||||
`
|
||||
|
||||
type SelectUploadBySiteIDAndSlugParams struct {
|
||||
SiteID int64
|
||||
Slug string
|
||||
}
|
||||
|
||||
func (q *Queries) SelectUploadBySiteIDAndSlug(ctx context.Context, arg SelectUploadBySiteIDAndSlugParams) (Upload, error) {
|
||||
row := q.db.QueryRowContext(ctx, selectUploadBySiteIDAndSlug, arg.SiteID, arg.Slug)
|
||||
var i Upload
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.SiteID,
|
||||
&i.Guid,
|
||||
&i.MimeType,
|
||||
&i.Filename,
|
||||
&i.FileSize,
|
||||
&i.Slug,
|
||||
&i.Alt,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
|
|
@ -72,7 +105,7 @@ func (q *Queries) SelectUploadByID(ctx context.Context, id interface{}) (Upload,
|
|||
}
|
||||
|
||||
const selectUploadsOfSite = `-- name: SelectUploadsOfSite :many
|
||||
SELECT id, site_id, guid, mime_type, filename, file_size, alt, created_at FROM uploads WHERE site_id = ? ORDER BY created_at DESC
|
||||
SELECT id, site_id, guid, mime_type, filename, file_size, slug, alt, created_at FROM uploads WHERE site_id = ? ORDER BY created_at DESC
|
||||
`
|
||||
|
||||
func (q *Queries) SelectUploadsOfSite(ctx context.Context, siteID int64) ([]Upload, error) {
|
||||
|
|
@ -91,6 +124,7 @@ func (q *Queries) SelectUploadsOfSite(ctx context.Context, siteID int64) ([]Uplo
|
|||
&i.MimeType,
|
||||
&i.Filename,
|
||||
&i.FileSize,
|
||||
&i.Slug,
|
||||
&i.Alt,
|
||||
&i.CreatedAt,
|
||||
); err != nil {
|
||||
|
|
@ -113,7 +147,7 @@ UPDATE uploads SET alt = ? WHERE id = ?
|
|||
|
||||
type UpdateUploadParams struct {
|
||||
Alt string
|
||||
ID interface{}
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (q *Queries) UpdateUpload(ctx context.Context, arg UpdateUploadParams) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue