From 0419f5d27768752c2b7c74ab2b7acf35ccbda566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Sun, 29 Nov 2020 13:52:50 +0100 Subject: [PATCH] BETTERZON-38: Added all products field to API return objects --- Backend/src/models/products/products.service.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Backend/src/models/products/products.service.ts b/Backend/src/models/products/products.service.ts index 237fea7..8cca5b0 100644 --- a/Backend/src/models/products/products.service.ts +++ b/Backend/src/models/products/products.service.ts @@ -28,7 +28,7 @@ export const findAll = async (): Promise => { let prodRows = []; try { conn = await pool.getConnection(); - const rows = await conn.query('SELECT product_id, name, asin FROM products'); + const rows = await conn.query('SELECT product_id, name, asin, is_active, short_description, long_description, image_guid, date_added, last_modified, manufacturer_id, selling_rank, category_id FROM products'); for (let row in rows) { if (row !== 'meta') { let prod: Product = { @@ -50,6 +50,15 @@ export const findAll = async (): Promise => { prod.product_id = sqlProd.product_id; prod.name = sqlProd.name; prod.asin = sqlProd.asin; + prod.is_active = sqlProd.is_active; + prod.short_description = sqlProd.short_description; + prod.long_description = sqlProd.long_description; + prod.image_guid = sqlProd.image_guid; + prod.date_added = sqlProd.date_added; + prod.last_modified = sqlProd.last_modified; + prod.manufacturer_id = sqlProd.manufacturer_id; + prod.selling_rank = sqlProd.selling_rank; + prod.category_id = sqlProd.category_id; prodRows.push(prod); } } @@ -70,7 +79,7 @@ export const find = async (id: number): Promise => { let prod: any; try { conn = await pool.getConnection(); - const rows = await conn.query('SELECT product_id, name FROM products WHERE product_id = ?', id); + const rows = await conn.query('SELECT product_id, name, asin, is_active, short_description, long_description, image_guid, date_added, last_modified, manufacturer_id, selling_rank, category_id FROM products WHERE product_id = ?', id); for (let row in rows) { if (row !== 'meta') { prod = rows[row]; @@ -94,7 +103,7 @@ export const findBySearchTerm = async (term: string): Promise => { try { conn = await pool.getConnection(); term = '%' + term + '%'; - const rows = await conn.query('SELECT product_id, name FROM products WHERE name LIKE ?', term); + const rows = await conn.query('SELECT product_id, name, asin, is_active, short_description, long_description, image_guid, date_added, last_modified, manufacturer_id, selling_rank, category_id FROM products WHERE name LIKE ?', term); for (let row in rows) { if (row !== 'meta') { prodRows.push(rows[row]);