package org.dromara.zhishu.service.impl;

import lombok.RequiredArgsConstructor;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.zhishu.domain.Statistic;

import org.dromara.zhishu.mapper.CountMapper;
import org.dromara.zhishu.service.CountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
public class CountServiceImpl implements CountService {

    @Autowired
    private CountMapper countMapper;

    @Override
    public Statistic selectStatistic() {
        Long userId = LoginHelper.getUserId();
        //查询当前用户下的库房
        List<Long> depotId = countMapper.selectDepotId(userId);
       Long wNum = countMapper.selectW(userId);
       Long sNum = countMapper.selectS(depotId);
       Statistic statistic=new Statistic();
       statistic.setWarehousesNum(wNum);
       statistic.setShelvesNum(sNum);
        return statistic;
    }
}
