ЛР4 - БВТ2303 - Голиков- на 4 #13

Closed
Maximillan_Mercer wants to merge 64 commits from Maximillan_Mercer/mtusi2026lab4-fork:solution/BVT2303-Golikov into main
Showing only changes of commit d208a7bef3 - Show all commits
@@ -49,3 +49,23 @@ func (r *AttachmentRepo) Create(ctx context.Context, a *domain.Attachment) error
}
return nil
}
func (r *AttachmentRepo) GetByID(ctx context.Context, id string) (*domain.Attachment, error) {
const q = `
SELECT id, chat_id, owner_id, filename, content_type, size_bytes, sha256,
object_key, status, error_code, created_at, updated_at
FROM attachments
WHERE id = $1::uuid
`
a := &domain.Attachment{}
var status string
err := r.pool.QueryRow(ctx, q, id).
Scan(&a.ID, &a.ChatID, &a.OwnerID, &a.Filename, &a.ContentType,
&a.SizeBytes, &a.SHA256, &a.ObjectKey, &status, &a.ErrorCode,
&a.CreatedAt, &a.UpdatedAt)
if err != nil {
return nil, notFound(err, "attachment", id)
}
a.Status = domain.AttachmentStatus(status)
return a, nil
}