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

import com.bonus.canteen.core.warehouse.domain.WareHouseCategory;
import com.bonus.canteen.core.warehouse.mapper.WareHouseCategoryMapper;
import com.bonus.canteen.core.warehouse.service.WareHouseCategoryService;
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 WareHouseCategoryServiceImpl implements WareHouseCategoryService {
    @Autowired
    private WareHouseCategoryMapper wareHouseCategoryMapper;

    /**
     * 查询仓库列表
     * 
     * @param WareHouseCategory 仓库
     * @return 仓库
     */
    @Override
    public List<WareHouseCategory> selectWareHouseCategoryList(WareHouseCategory WareHouseCategory) {
        return wareHouseCategoryMapper.selectWareHouseCategoryList(WareHouseCategory);
    }

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

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

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

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