From 777cd8bb8e98caa0a8bbaf4912031ed4a7188be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Tue, 6 Jan 2026 14:01:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8B=E6=9E=B6=E6=97=B6=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E6=9B=B4=E6=96=B0status=E4=B8=BAsold=5Fout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-example/server-mysql.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server-example/server-mysql.js b/server-example/server-mysql.js index 0593da7..c266668 100644 --- a/server-example/server-mysql.js +++ b/server-example/server-mysql.js @@ -4181,19 +4181,20 @@ app.post('/api/products/unpublish', async (req, res) => { console.log('准备下架商品,productId:', productId, ',当前label:', product.label); - // 直接使用商品实例更新label字段 + // 直接使用商品实例更新label字段和status字段 product.label = 1; + product.status = 'sold_out'; product.updated_at = getBeijingTime(); try { await product.save(); - console.log('下架商品成功(使用save方法):', { productId: product.productId, newLabel: product.label }); + console.log('下架商品成功(使用save方法):', { productId: product.productId, newLabel: product.label, newStatus: product.status }); } catch (saveError) { console.error('使用save方法更新失败,尝试使用update方法:', saveError); try { const updateResult = await Product.update( - { label: 1, updated_at: getBeijingTime() }, + { label: 1, status: 'sold_out', updated_at: getBeijingTime() }, { where: { productId } } ); console.log('下架商品成功(使用update方法):', { productId, updateResult });