import {Goods, GoodsAttributes, Orders} from "../../models";


module.exports = async (req, res, next) => {

    console.log(req.body.decryptedData);

    // const orders = await Orders.findAndCountAll({
    //     include: {
    //         model: GoodsAttributes,
    //         attributes: {
    //             exclude: ['createdAt', 'updatedAt', 'goodsId']
    //         },
    //         include: {
    //             model: Goods,
    //             attributes: ['goodsName', 'goodsDescription']
    //         }
    //     },
    //     attributes: {
    //         exclude: ["updatedAt", 'createdAt']
    //     },
    //     order: [['orderStatus', 'asc']],
    //     offset: req.params.offset,
    //     limit: 10
    // });
    //
    // const packages = {};
    // const orders = await Orders.findAll({
    //     include: {
    //         model: GoodsAttributes,
    //         attributes: {
    //             exclude: ['createdAt', 'updatedAt', 'goodsId']
    //         },
    //         include: {
    //             model: Goods,
    //             attributes: ['goodsName', 'goodsDescription']
    //         }
    //     },
    //     attributes: {
    //         exclude: ["updatedAt", 'createdAt']
    //     },
    //     order: [['orderStatus', 'asc']]
    // });
    // console.log(req.params.offset);
    // orders.rows.map(elem => {
    //     if(Object.keys(packages).indexOf(elem.packageId) == -1) {
    //         packages[elem.packageId] = [];
    //     }
    // });
    // Object.keys(packages).map(pack => {
    //     orders.rows.map(order => {
    //         if(pack == order.packageId) {
    //             packages[pack].push(order);
    //         }
    //     });
    // });
    //
    // req.body.ordersPackages = {
    //     packages: packages,
    //     count: orders.count
    // };
    // next();
};