新增优惠卷管理和图片上传

This commit is contained in:
dzl
2025-10-14 16:25:16 +08:00
parent 486d3179d3
commit 69a445cebd
3 changed files with 68 additions and 22 deletions

View File

@@ -7,25 +7,17 @@ router.get('/', async (req, res) => {
const db = await getDB();
const [firstCategory] = await db.query('SELECT * FROM category WHERE level = 1');
console.log(firstCategory);
for (const category of firstCategory) {
const [secondCategories] = await db.query('SELECT * FROM category WHERE parent_id = ?', [category.id]);
category.relative = secondCategories;
}
res.json({ success: true, data: firstCategory.map(category => ({
name: category.category_name,
relative: category.relative.map(secondCategory => ({
name: secondCategory.category_name,
img: secondCategory.image,
}))
}))});
} catch (error) {