package com.bonus.material.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.material.warehouse.mapper.WhHouseInfoMapper;
import com.bonus.material.warehouse.domain.WhHouseInfo;
import com.bonus.material.warehouse.service.IWhHouseInfoService;

/**
 * 仓库管理Service业务层处理
 * 
 * @author xsheng
 * @date 2024-09-27
 */
@Service
public class WhHouseInfoServiceImpl implements IWhHouseInfoService 
{
    @Autowired
    private WhHouseInfoMapper whHouseInfoMapper;

    /**
     * 查询仓库管理
     * 
     * @param houseId 仓库管理主键
     * @return 仓库管理
     */
    @Override
    public WhHouseInfo selectWhHouseInfoByHouseId(Long houseId)
    {
        return whHouseInfoMapper.selectWhHouseInfoByHouseId(houseId);
    }

    /**
     * 查询仓库管理列表
     * 
     * @param whHouseInfo 仓库管理
     * @return 仓库管理
     */
    @Override
    public List<WhHouseInfo> selectWhHouseInfoList(WhHouseInfo whHouseInfo) {
        return whHouseInfoMapper.selectWhHouseInfoList(whHouseInfo);
    }

    /**
     * 新增仓库管理
     * 
     * @param whHouseInfo 仓库管理
     * @return 结果
     */
    @Override
    public int insertWhHouseInfo(WhHouseInfo whHouseInfo)
    {
        whHouseInfo.setCreateTime(DateUtils.getNowDate());
        try {
            return whHouseInfoMapper.insertWhHouseInfo(whHouseInfo);
        } catch (Exception e) {
            throw new ServiceException("数据库错误或仓库重名");
        }
    }

    /**
     * 修改仓库管理
     * 
     * @param whHouseInfo 仓库管理
     * @return 结果
     */
    @Override
    public int updateWhHouseInfo(WhHouseInfo whHouseInfo)
    {
        whHouseInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return whHouseInfoMapper.updateWhHouseInfo(whHouseInfo);
        } catch (Exception e) {
            throw new ServiceException("数据库错误或仓库重名");
        }
    }

    /**
     * 批量删除仓库管理
     * 
     * @param houseIds 需要删除的仓库管理主键
     * @return 结果
     */
    @Override
    public int deleteWhHouseInfoByHouseIds(Long[] houseIds)
    {
        return whHouseInfoMapper.deleteWhHouseInfoByHouseIds(houseIds);
    }

    /**
     * 删除仓库管理信息
     * 
     * @param houseId 仓库管理主键
     * @return 结果
     */
    @Override
    public int deleteWhHouseInfoByHouseId(Long houseId)
    {
        return whHouseInfoMapper.deleteWhHouseInfoByHouseId(houseId);
    }
}
