写到一半

This commit is contained in:
dzl
2025-10-21 17:31:00 +08:00
parent fad0d070b6
commit 6d579316b7

View File

@@ -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 = ?',