diff --git a/api/controller/Product/product.controller.js b/api/controller/Product/product.controller.js index 65ae76d..675ec25 100644 --- a/api/controller/Product/product.controller.js +++ b/api/controller/Product/product.controller.js @@ -97,11 +97,11 @@ class ProductController { async findById(req, res) { const { dateExpired, postalCode } = req.query const id = Number(req.params.id) - const _products = await db.getProducts(dateExpired, postalCode); - const filterProduct = _products[0].filter(item => item.itemFk === id) + const product = await db.getProductById(req.params.id); + //const filterProduct = _products[0].filter(item => item.itemFk === id) return res.status(200).send({ - data: filterProduct + data: product }) } } diff --git a/api/db/db.js b/api/db/db.js index 46e65e1..62c77c9 100644 --- a/api/db/db.js +++ b/api/db/db.js @@ -23,6 +23,12 @@ async function getProducts(dateExpired, postalCode) { return rows; } +async function getProductById(id) { + const conn = await connect(); + const rows = await conn.query(`CALL catalogue_findById(${id})`); + return rows; +} + //Procedure for create transactions, do not carry out any manipulation at the bank async function orderData_put(jsonOrderData) { const conn = await connect(); @@ -81,6 +87,7 @@ async function findAll_banner() { module.exports = { getProducts, + getProductById, orderData_get, orderData_put, getProvinces, diff --git a/src/components/ui/Card.vue b/src/components/ui/Card.vue index 7b8d66e..84f72a2 100644 --- a/src/components/ui/Card.vue +++ b/src/components/ui/Card.vue @@ -34,6 +34,7 @@ export default defineComponent({ default: "", }, isNew: String, + hasPostalCode: Boolean, size: { type: String, default: "md-card", @@ -77,7 +78,7 @@ export default defineComponent({