From 6d579316b76efbb1bbec42772dadd845f6184e5b Mon Sep 17 00:00:00 2001 From: dzl <786316265@qq.com> Date: Tue, 21 Oct 2025 17:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=99=E5=88=B0=E4=B8=80=E5=8D=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/products.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/routes/products.js b/routes/products.js index 7360a99..8b3abfc 100644 --- a/routes/products.js +++ b/routes/products.js @@ -432,7 +432,8 @@ router.post('/', async (req, res) => { shop_name, shop_avatar, payment_methods = ['points', 'rongdou', 'points_rongdou'], attributes = [] } = req.body; - if (!name || !price || (!points_price && !rongdou_price) || stock === undefined) { + if (!name || !price || stock === undefined) { + // if (!name || !price || (!points_price && !rongdou_price) || stock === undefined) { return res.status(400).json({ message: '商品名称、原价、积分价格或融豆价格、库存不能为空' }); } @@ -444,15 +445,25 @@ router.post('/', async (req, res) => { // image_url, JSON.stringify(images), JSON.stringify(videos), details, // shop_name, shop_avatar, JSON.stringify(payment_methods), status] // ); - const [result] = await getDB().execute( - `UPDATE products - SET name = ?, description = ?, price = ?, points_price = ?, rongdou_price = ?, stock = ?, - image_url = ?, images = ?, videos = ?, details = ?, shop_name = ?, shop_avatar = ?, payment_methods = ?, status = ?, updated_at = NOW() - WHERE name = ?`, - [name, description, price, points_price, rongdou_price, stock, - image_url, JSON.stringify(images), JSON.stringify(videos), details, - shop_name, shop_avatar, JSON.stringify(payment_methods), status, 'temp'] - ) + + const query = [` + UPDATE products + SET name = ?, price = ?, stock = ? + `,` + WHERE name = ? + `] + + + + // const [result] = await getDB().execute( + // `UPDATE products + // SET name = ?, description = ?, price = ?, points_price = ?, rongdou_price = ?, stock = ?, + // image_url = ?, images = ?, videos = ?, details = ?, shop_name = ?, shop_avatar = ?, payment_methods = ?, status = ?, updated_at = NOW() + // WHERE name = ?`, + // [name, description, price, points_price, rongdou_price, stock, + // image_url, JSON.stringify(images), JSON.stringify(videos), details, + // shop_name, shop_avatar, JSON.stringify(payment_methods), status, 'temp'] + // ) const [product] = await getDB().execute( 'SELECT * FROM products WHERE name = ?',