package com.bonus.canteen.menu.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.menu.mapper.MenuMaterialCategoryMapper;
import com.bonus.canteen.menu.domain.MenuMaterialCategory;
import com.bonus.canteen.menu.service.IMenuMaterialCategoryService;

/**
 * 原料类别Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-03
 */
@Service
public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategoryService {
    @Autowired
    private MenuMaterialCategoryMapper menuMaterialCategoryMapper;

    /**
     * 查询原料类别
     * 
     * @param id 原料类别主键
     * @return 原料类别
     */
    @Override
    public MenuMaterialCategory selectMenuMaterialCategoryById(Long id) {
        return menuMaterialCategoryMapper.selectMenuMaterialCategoryById(id);
    }

    /**
     * 查询原料类别列表
     * 
     * @param menuMaterialCategory 原料类别
     * @return 原料类别
     */
    @Override
    public List<MenuMaterialCategory> selectMenuMaterialCategoryList(MenuMaterialCategory menuMaterialCategory) {
        return menuMaterialCategoryMapper.selectMenuMaterialCategoryList(menuMaterialCategory);
    }

    /**
     * 新增原料类别
     * 
     * @param menuMaterialCategory 原料类别
     * @return 结果
     */
    @Override
    public int insertMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory) {
        menuMaterialCategory.setCreateTime(DateUtils.getNowDate());
        try {
            return menuMaterialCategoryMapper.insertMenuMaterialCategory(menuMaterialCategory);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改原料类别
     * 
     * @param menuMaterialCategory 原料类别
     * @return 结果
     */
    @Override
    public int updateMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory) {
        menuMaterialCategory.setUpdateTime(DateUtils.getNowDate());
        try {
            return menuMaterialCategoryMapper.updateMenuMaterialCategory(menuMaterialCategory);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除原料类别
     * 
     * @param ids 需要删除的原料类别主键
     * @return 结果
     */
    @Override
    public int deleteMenuMaterialCategoryByIds(Long[] ids) {
        return menuMaterialCategoryMapper.deleteMenuMaterialCategoryByIds(ids);
    }

    /**
     * 删除原料类别信息
     * 
     * @param id 原料类别主键
     * @return 结果
     */
    @Override
    public int deleteMenuMaterialCategoryById(Long id) {
        return menuMaterialCategoryMapper.deleteMenuMaterialCategoryById(id);
    }
}
