Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
730 B
0
Indexable
Never
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,
};
Leave a Comment