Untitled

 avatar
unknown
plain_text
a year ago
730 B
3
Indexable
const serviceSales = require('../services/service.sales');

const getSalesController = async (req, resp) => {
  try {
    const sales = await serviceSales.getSales();
    resp.status(200).json(sales);
  } catch (error) {
    resp.status(500).json({ message: error.message });
  }
};

const getSalesControllerId = async (req, resp) => {
  const { id } = req.params;
  try {
    const salesId = await serviceSales.getSaleId(id);
    if (!salesId || salesId.length === 0) {
      return resp.status(404).json({ message: 'Sale not found' });
    }
    resp.status(200).json(salesId);
  } catch (error) {
    resp.status(404).json({ message: error.message });
  }
};

module.exports = {
  getSalesController,
  getSalesControllerId,
};
Editor is loading...
Leave a Comment