package com.bonus.canteen.core.warehouse.service.impl;

import com.bonus.canteen.core.warehouse.domain.WareHouseInfo;
import com.bonus.canteen.core.warehouse.mapper.WareHouseInfoMapper;
import com.bonus.canteen.core.warehouse.service.WareHouseInfoService;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 仓库Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-05
 */
@Service
public class WareHouseInfoServiceImpl implements WareHouseInfoService {
    @Autowired
    private WareHouseInfoMapper wareHouseInfoMapper;

    /**
     * 查询仓库列表
     * 
     * @param WareHouseInfo 仓库
     * @return 仓库
     */
    @Override
    public List<WareHouseInfo> selectWareHouseInfoList(WareHouseInfo WareHouseInfo) {
        return wareHouseInfoMapper.selectWareHouseInfoList(WareHouseInfo);
    }

    /**
     * 新增仓库
     * 
     * @param WareHouseInfo 仓库
     * @return 结果
     */
    @Override
    public int insertWareHouseInfo(WareHouseInfo WareHouseInfo) {
        WareHouseInfo.setCreateTime(DateUtils.getNowDate());
        try {
            return wareHouseInfoMapper.insertWareHouseInfo(WareHouseInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改仓库
     * 
     * @param WareHouseInfo 仓库
     * @return 结果
     */
    @Override
    public int updateWareHouseInfo(WareHouseInfo WareHouseInfo) {
        WareHouseInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return wareHouseInfoMapper.updateWareHouseInfo(WareHouseInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除仓库
     * 
     * @param WareHouseIds 需要删除的仓库主键
     * @return 结果
     */
    @Override
    public int deleteWareHouseInfoByWareHouseIds(Long[] WareHouseIds) {
        return wareHouseInfoMapper.deleteWareHouseInfoByWareHouseIds(WareHouseIds);
    }

    /**
     * 删除仓库信息
     * 
     * @param WareHouseId 仓库主键
     * @return 结果
     */
    @Override
    public int deleteWareHouseInfoByWareHouseId(WareHouseInfo WareHouseInfo) {
        return wareHouseInfoMapper.deleteWareHouseInfoByWareHouseId(WareHouseInfo);
    }
}
