new version using better built-in api for create 6
This commit is contained in:
parent
ac492b1301
commit
634d060c75
1504
package-lock.json
generated
1504
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,8 +15,6 @@
|
||||
"axios": "^1.13.2",
|
||||
"express": "^5.2.1",
|
||||
"mariadb": "^3.4.5",
|
||||
"sqlight": "^1.0.0-alpha.8",
|
||||
"sqlite3": "^5.1.7",
|
||||
"ws": "^8.18.3"
|
||||
}
|
||||
}
|
||||
|
||||
14
users-api.js
14
users-api.js
@ -380,16 +380,14 @@ module.exports = function (app, wss, pool) {
|
||||
if (!userRow)
|
||||
return res.status(404).json({ ok: false, error: "User not found" });
|
||||
if (userRow.balance < price * item.quantity)
|
||||
return res
|
||||
.status(400)
|
||||
.json({
|
||||
return res.status(400).json({
|
||||
ok: false,
|
||||
error: `Insufficient balance for item ${item.id}`,
|
||||
});
|
||||
|
||||
const shopId = response.data.shopId;
|
||||
if (!shopList[shopId]) shopList[shopId] = [];
|
||||
shopList[shopId].push({ id: item.id, count: item.quantity });
|
||||
shopList[shopId].push({ name: item.id, _requestCount: item.quantity });
|
||||
total += price * item.quantity;
|
||||
}
|
||||
|
||||
@ -418,9 +416,7 @@ module.exports = function (app, wss, pool) {
|
||||
);
|
||||
|
||||
await conn.commit();
|
||||
res
|
||||
.status(200)
|
||||
.json({
|
||||
res.status(200).json({
|
||||
ok: true,
|
||||
message: `Successfully purchased items for user ${userId} at ${total}`,
|
||||
});
|
||||
@ -462,9 +458,7 @@ module.exports = function (app, wss, pool) {
|
||||
);
|
||||
|
||||
await conn.commit();
|
||||
res
|
||||
.status(200)
|
||||
.json({
|
||||
res.status(200).json({
|
||||
ok: true,
|
||||
message: `Successfully transferred ${amount} from ${from} to ${to}`,
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user