added produkt parent
This commit is contained in:
parent
b0dc1672fc
commit
80c6859a8b
1 changed files with 11 additions and 3 deletions
|
@ -245,7 +245,8 @@ export const addProduct: Act = {
|
|||
listCatID: "number",
|
||||
defUnit: "number",
|
||||
defValue: "string-256",
|
||||
ean: "string-64"
|
||||
ean: "string-64",
|
||||
parent: "number" //-1 = no parent
|
||||
},
|
||||
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
|
||||
if (!checkSelfTag(data.server)) {
|
||||
|
@ -260,6 +261,7 @@ export const addProduct: Act = {
|
|||
return;
|
||||
}
|
||||
if (!isCategoryInRoom(roomID, data.listCatID)) return void aws("error", "existence");
|
||||
if (data.parent > -1 && !isProductInRoom(roomID, data.parent)) return void aws("error", "existence");
|
||||
let req = await insert(
|
||||
listProducts.roomID,
|
||||
listProducts.title,
|
||||
|
@ -268,6 +270,7 @@ export const addProduct: Act = {
|
|||
listProducts.defUnit,
|
||||
listProducts.defValue,
|
||||
listProducts.ean,
|
||||
listProducts.parent,
|
||||
).add(
|
||||
roomID,
|
||||
data.title,
|
||||
|
@ -275,7 +278,8 @@ export const addProduct: Act = {
|
|||
data.listCatID,
|
||||
data.defUnit,
|
||||
data.defValue,
|
||||
data.ean
|
||||
data.ean,
|
||||
data.parent > -1 ? data.parent : null,
|
||||
).query(db);
|
||||
if (req.affectedRows > 0) aws("ok", {
|
||||
listProdID: req.insertId
|
||||
|
@ -296,7 +300,8 @@ export const changeProduct: Act = {
|
|||
listCatID: "number",
|
||||
defUnit: "number",
|
||||
defValue: "string-256",
|
||||
ean: "string-64"
|
||||
ean: "string-64",
|
||||
parent: "number" //-1 = no parent
|
||||
},
|
||||
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
|
||||
if (!checkSelfTag(data.server)) {
|
||||
|
@ -312,6 +317,8 @@ export const changeProduct: Act = {
|
|||
}
|
||||
if (!isCategoryInRoom(roomID, data.listCatID)) return void aws("error", "existence");
|
||||
if (!isProductInRoom(roomID, data.listProdID)) return void aws("error", "existence");
|
||||
if (data.parent > -1 && !isProductInRoom(roomID, data.parent)) return void aws("error", "existence");
|
||||
|
||||
let req = await update(listProducts)
|
||||
.set(listProducts.title, data.title)
|
||||
.set(listProducts.description, data.description)
|
||||
|
@ -319,6 +326,7 @@ export const changeProduct: Act = {
|
|||
.set(listProducts.defUnit, data.defUnit)
|
||||
.set(listProducts.defValue, data.defValue)
|
||||
.set(listProducts.ean, data.ean)
|
||||
.set(listProducts.parent, data.parent > -1 ? data.parent : null)
|
||||
.where(eq(listProducts.listProdID, data.listProdID))
|
||||
.query(db);
|
||||
if (req.affectedRows > 0) aws("ok", "");
|
||||
|
|
Loading…
Reference in a new issue