新增优惠卷管理和图片上传
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user