This commit is contained in:
2025-10-01 22:54:47 +02:00
parent fd0542f2a4
commit 64d65d270e
6 changed files with 109 additions and 19 deletions

View File

@@ -150,6 +150,7 @@ function mapPostRow(row) {
sections: row.sections || [],
footer: row.footer,
isEditorsPick: row.is_editors_pick,
isSold: row.is_sold || false,
category: row.category,
createdAt: row.created_at,
updatedAt: row.updated_at
@@ -273,9 +274,11 @@ app.post('/posts', upload.fields(getUploadFields()), async (req, res) => {
await ensureEditorsPickLimit(null, isEditorsPick)
const isSold = Boolean(payload.isSold)
const result = await query(
`INSERT INTO blog_posts (title, slug, preview_image, link_url, sections, footer, is_editors_pick, category)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
`INSERT INTO blog_posts (title, slug, preview_image, link_url, sections, footer, is_editors_pick, is_sold, category)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
RETURNING *`,
[
payload.title.trim(),
@@ -285,6 +288,7 @@ app.post('/posts', upload.fields(getUploadFields()), async (req, res) => {
JSON.stringify(sections),
payload.footer || null,
isEditorsPick,
isSold,
payload.category || null
]
)
@@ -333,6 +337,8 @@ app.put('/posts/:id', upload.fields(getUploadFields()), async (req, res) => {
await ensureEditorsPickLimit(Number(id), true)
}
const isSold = Boolean(payload.isSold)
const result = await query(
`UPDATE blog_posts
SET title = $1,
@@ -342,8 +348,9 @@ app.put('/posts/:id', upload.fields(getUploadFields()), async (req, res) => {
sections = $5,
footer = $6,
is_editors_pick = $7,
category = $8
WHERE id = $9
is_sold = $8,
category = $9
WHERE id = $10
RETURNING *`,
[
payload.title.trim(),
@@ -353,6 +360,7 @@ app.put('/posts/:id', upload.fields(getUploadFields()), async (req, res) => {
JSON.stringify(sections),
payload.footer || null,
isEditorsPick,
isSold,
payload.category || null,
id
]