const Stock = require('../model/stock');
exports.getStockRowColumn = async (req, res, next)=>{
    const {
        leftShelveId,
        rightShelveId
    } = req.query;
    let left = await Stock.getStockRowColumn(leftShelveId);
    let right;
    if(leftShelveId === rightShelveId) {
        right = left;
    } else {
        right = await Stock.getStockRowColumn(rightShelveId);
    }
    res.send({
        code: 200,
        data: {
            left,
            right
        }
    });
    res.end();
}

// 如果是人工复合错误，那么就需要取stock_log里的关联的最新的信息。
exports.getStockRowColumnNesInfo = async (req, res, next) => {
    const { shelveId, row, column } = req.query;
    const data = await Stock.getStockRowColumnNesInfo(shelveId, row, column);
    if(!data) {
        res.send({
            code: 200,
            message: '暂无数据',
            data: {}
        });
    }else {
        res.send({
            code: 200,
            data: data
        });
    }
    res.end();
}


