package com.bonus.canteen.core.warehouse.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.warehouse.mapper.WarehouseInfoMapper;
import com.bonus.canteen.core.warehouse.domain.WarehouseInfo;
import com.bonus.canteen.core.warehouse.service.IWarehouseInfoService;

/**
 * 仓库信息Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-15
 */
@Service
public class WarehouseInfoServiceImpl implements IWarehouseInfoService {
    @Autowired
    private WarehouseInfoMapper warehouseInfoMapper;

    /**
     * 查询仓库信息
     * 
     * @param warehouseId 仓库信息主键
     * @return 仓库信息
     */
    @Override
    public WarehouseInfo selectWarehouseInfoByWarehouseId(Long warehouseId) {
        return warehouseInfoMapper.selectWarehouseInfoByWarehouseId(warehouseId);
    }

    /**
     * 查询仓库信息列表
     * 
     * @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("错误信息描述, " + e.getMessage());
        }
    }

    /**
     * 修改仓库信息
     * 
     * @param warehouseInfo 仓库信息
     * @return 结果
     */
    @Override
    public int updateWarehouseInfo(WarehouseInfo warehouseInfo) {
        warehouseInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return warehouseInfoMapper.updateWarehouseInfo(warehouseInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述, " + e.getMessage());
        }
    }

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

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