package com.bonus.canteen.core.cook.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.cook.mapper.CookCollectionDishesMapper;
import com.bonus.canteen.core.cook.domain.CookCollectionDishes;
import com.bonus.canteen.core.cook.service.ICookCollectionDishesService;

/**
 * 菜品收藏Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class CookCollectionDishesServiceImpl implements ICookCollectionDishesService {
    @Autowired
    private CookCollectionDishesMapper cookCollectionDishesMapper;

    /**
     * 查询菜品收藏
     * 
     * @param id 菜品收藏主键
     * @return 菜品收藏
     */
    @Override
    public CookCollectionDishes selectCookCollectionDishesById(Long id) {
        return cookCollectionDishesMapper.selectCookCollectionDishesById(id);
    }

    /**
     * 查询菜品收藏列表
     * 
     * @param cookCollectionDishes 菜品收藏
     * @return 菜品收藏
     */
    @Override
    public List<CookCollectionDishes> selectCookCollectionDishesList(CookCollectionDishes cookCollectionDishes) {
        return cookCollectionDishesMapper.selectCookCollectionDishesList(cookCollectionDishes);
    }

    /**
     * 新增菜品收藏
     * 
     * @param cookCollectionDishes 菜品收藏
     * @return 结果
     */
    @Override
    public int insertCookCollectionDishes(CookCollectionDishes cookCollectionDishes) {
        cookCollectionDishes.setCreateTime(DateUtils.getNowDate());
        try {
            return cookCollectionDishesMapper.insertCookCollectionDishes(cookCollectionDishes);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改菜品收藏
     * 
     * @param cookCollectionDishes 菜品收藏
     * @return 结果
     */
    @Override
    public int updateCookCollectionDishes(CookCollectionDishes cookCollectionDishes) {
        cookCollectionDishes.setUpdateTime(DateUtils.getNowDate());
        try {
            return cookCollectionDishesMapper.updateCookCollectionDishes(cookCollectionDishes);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除菜品收藏
     * 
     * @param ids 需要删除的菜品收藏主键
     * @return 结果
     */
    @Override
    public int deleteCookCollectionDishesByIds(Long[] ids) {
        return cookCollectionDishesMapper.deleteCookCollectionDishesByIds(ids);
    }

    /**
     * 删除菜品收藏信息
     * 
     * @param id 菜品收藏主键
     * @return 结果
     */
    @Override
    public int deleteCookCollectionDishesById(Long id) {
        return cookCollectionDishesMapper.deleteCookCollectionDishesById(id);
    }
}
