接口更改

This commit is contained in:
dzl
2025-10-10 17:30:49 +08:00
parent 83af2cefd6
commit 2aa0e9d884
10 changed files with 284 additions and 81 deletions

View File

@@ -1,9 +1,8 @@
const express = require('express');
const router = express.Router();
const { auth } = require('../middleware/auth');
const { getDB } = require('../database');
router.get('/', auth, async (req, res) => {
router.get('/', async (req, res) => {
try {
res.json({
success: true,
@@ -17,7 +16,7 @@ router.get('/', auth, async (req, res) => {
}
});
router.get('/product-details/:id', auth, async (req, res) => {
router.get('/product-details/:id', async (req, res) => {
try {
const { id } = req.params;
const query = `
@@ -38,7 +37,7 @@ router.get('/product-details/:id', auth, async (req, res) => {
}
})
router.get('/flash-products', auth, async (req, res) => {
router.get('/flash-products', async (req, res) => {
try {
const { page = 1, limit = 10, search = '', category = '' } = req.query;
@@ -111,7 +110,7 @@ router.get('/flash-products', auth, async (req, res) => {
}
})
router.get('/flash-product/:id', auth, async (req, res) => {
router.get('/flash-product/:id', async (req, res) => {
try {
const { id } = req.params;
const query = `
@@ -132,7 +131,7 @@ router.get('/flash-product/:id', auth, async (req, res) => {
}
})
router.delete('/flash-product/:id', auth, async (req, res) => {
router.delete('/flash-product/:id', async (req, res) => {
try {
const { id } = req.params;
const query = `
@@ -152,7 +151,7 @@ router.delete('/flash-product/:id', auth, async (req, res) => {
}
})
router.post('/flash-product', auth, async (req, res) => {
router.post('/flash-product', async (req, res) => {
try {
const { start_time, end_time, flash_stock, flash_price, products_id } = req.body;
const query = `
@@ -170,7 +169,7 @@ router.post('/flash-product', auth, async (req, res) => {
}
})
router.put('/flash-product/:id', auth, async (req, res) => {
router.put('/flash-product/:id', async (req, res) => {
try {
const { id } = req.params;
const { start_time, end_time, flash_stock, flash_price, products_id } = req.body;
@@ -198,7 +197,7 @@ router.put('/flash-product/:id', auth, async (req, res) => {
router.get('/recommend-products', auth, async (req, res) => {
router.get('/recommend-products', async (req, res) => {
try {
const { page = 1, limit = 10, search = '', category = '' } = req.query;
@@ -269,7 +268,7 @@ router.get('/recommend-products', auth, async (req, res) => {
}
})
router.post('/recommend-product', auth, async (req, res) => {
router.post('/recommend-product', async (req, res) => {
try {
const { products_id } = req.body;
const query = `
@@ -287,7 +286,7 @@ router.post('/recommend-product', auth, async (req, res) => {
}
})
router.delete('/recommend-product/:id', auth, async (req, res) => {
router.delete('/recommend-product/:id', async (req, res) => {
try {
const { id } = req.params;
const query = `
@@ -308,7 +307,7 @@ router.delete('/recommend-product/:id', auth, async (req, res) => {
})
// 供应商
router.get('/producer-list', auth, async (req, res) => {
router.get('/producer-list', async (req, res) => {
try {
const { page = 1, limit = 10, search = '', category = '' } = req.query;
@@ -367,7 +366,7 @@ router.get('/producer-list', auth, async (req, res) => {
}
})
router.post('/producer', auth, async (req, res) => {
router.post('/producer', async (req, res) => {
try {
const { producer_name } = req.body;
const query = `
@@ -385,7 +384,7 @@ router.post('/producer', auth, async (req, res) => {
}
})
router.delete('/producer/:id', auth, async (req, res) => {
router.delete('/producer/:id', async (req, res) => {
try {
const { id } = req.params;
const query = `