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

import java.util.List;
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 com.bonus.canteen.core.supply.mapper.SupplyWarehouseInfoMapper;
import com.bonus.canteen.core.supply.domain.SupplyWarehouseInfo;
import com.bonus.canteen.core.supply.service.ISupplyWarehouseInfoService;

/**
 * 仓库信息Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class SupplyWarehouseInfoServiceImpl implements ISupplyWarehouseInfoService {
    @Autowired
    private SupplyWarehouseInfoMapper supplyWarehouseInfoMapper;

    /**
     * 查询仓库信息
     * 
     * @param warehouseId 仓库信息主键
     * @return 仓库信息
     */
    @Override
    public SupplyWarehouseInfo selectSupplyWarehouseInfoByWarehouseId(Long warehouseId) {
        return supplyWarehouseInfoMapper.selectSupplyWarehouseInfoByWarehouseId(warehouseId);
    }

    /**
     * 查询仓库信息列表
     * 
     * @param supplyWarehouseInfo 仓库信息
     * @return 仓库信息
     */
    @Override
    public List<SupplyWarehouseInfo> selectSupplyWarehouseInfoList(SupplyWarehouseInfo supplyWarehouseInfo) {
        return supplyWarehouseInfoMapper.selectSupplyWarehouseInfoList(supplyWarehouseInfo);
    }

    /**
     * 新增仓库信息
     * 
     * @param supplyWarehouseInfo 仓库信息
     * @return 结果
     */
    @Override
    public int insertSupplyWarehouseInfo(SupplyWarehouseInfo supplyWarehouseInfo) {
        supplyWarehouseInfo.setCreateTime(DateUtils.getNowDate());
        try {
            return supplyWarehouseInfoMapper.insertSupplyWarehouseInfo(supplyWarehouseInfo);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改仓库信息
     * 
     * @param supplyWarehouseInfo 仓库信息
     * @return 结果
     */
    @Override
    public int updateSupplyWarehouseInfo(SupplyWarehouseInfo supplyWarehouseInfo) {
        supplyWarehouseInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return supplyWarehouseInfoMapper.updateSupplyWarehouseInfo(supplyWarehouseInfo);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除仓库信息
     * 
     * @param warehouseIds 需要删除的仓库信息主键
     * @return 结果
     */
    @Override
    public int deleteSupplyWarehouseInfoByWarehouseIds(Long[] warehouseIds) {
        return supplyWarehouseInfoMapper.deleteSupplyWarehouseInfoByWarehouseIds(warehouseIds);
    }

    /**
     * 删除仓库信息信息
     * 
     * @param warehouseId 仓库信息主键
     * @return 结果
     */
    @Override
    public int deleteSupplyWarehouseInfoByWarehouseId(Long warehouseId) {
        return supplyWarehouseInfoMapper.deleteSupplyWarehouseInfoByWarehouseId(warehouseId);
    }
}
