修复商品库存与网络摘要并校验订购编号

This commit is contained in:
cieanyau committed 2026-11-06 04:48:38 +08:00
1 parent 28894e0813
commit d8224ec5b7
15 files changed
+529 -68

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
/** 商品接口使用有符号 32 位正整数;在拼接后端路径之前拒绝数组、精度丢失和超限编号。 */
export function productId(value) {
if (typeof value !== "string" && typeof value !== "number") return null;
const text = String(value);
if (!/^[1-9]\d{0,9}$/.test(text)) return null;
const id = Number(text);
return id <= 2147483647 ? id : null;
}