feat: autogen run_hour/run_minute, publish_slots, scheduled_posts tables and routes
This commit is contained in:
@@ -26,13 +26,15 @@ router.post('/run', async (req, res) => {
|
||||
// PATCH /api/autogen/settings/:category — обновить настройки
|
||||
router.patch('/settings/:category', async (req, res) => {
|
||||
try {
|
||||
const { enabled, per_day } = req.body;
|
||||
const { enabled, per_day, run_hour, run_minute } = req.body;
|
||||
const fields = []; const vals = []; let i = 1;
|
||||
if (enabled !== undefined) { fields.push(`enabled=$${i++}`); vals.push(enabled); }
|
||||
if (per_day !== undefined) { fields.push(`per_day=$${i++}`); vals.push(per_day); }
|
||||
if (enabled !== undefined) { fields.push(`enabled=${i++}`); vals.push(enabled); }
|
||||
if (per_day !== undefined) { fields.push(`per_day=${i++}`); vals.push(per_day); }
|
||||
if (run_hour !== undefined) { fields.push(`run_hour=${i++}`); vals.push(run_hour); }
|
||||
if (run_minute !== undefined) { fields.push(`run_minute=${i++}`); vals.push(run_minute); }
|
||||
if (!fields.length) return res.status(400).json({ error: 'Nothing to update' });
|
||||
vals.push(req.params.category);
|
||||
await query(`UPDATE autogen_settings SET ${fields.join(',')} WHERE category=$${i}`, vals);
|
||||
await query(`UPDATE autogen_settings SET ${fields.join(',')} WHERE category=${i}`, vals);
|
||||
res.json({ ok: true });
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user