package com.waimai.web.admin.service.impl;

import java.util.List;
import com.waimai.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.waimai.web.admin.mapper.FoodMapper;
import com.waimai.web.admin.domain.Food;
import com.waimai.web.admin.service.IFoodService;

/**
 * 食品Service业务层处理
 * 
 * @author callmeyan
 * @date 2023-03-24
 */
@Service
public class FoodServiceImpl implements IFoodService 
{
    @Autowired
    private FoodMapper foodMapper;

    /**
     * 查询食品
     * 
     * @param id 食品主键
     * @return 食品
     */
    @Override
    public Food selectFoodById(Long id)
    {
        return foodMapper.selectFoodById(id);
    }

    /**
     * 查询食品列表
     * 
     * @param food 食品
     * @return 食品
     */
    @Override
    public List<Food> selectFoodList(Food food)
    {
        return foodMapper.selectFoodList(food);
    }

    /**
     * 新增食品
     * 
     * @param food 食品
     * @return 结果
     */
    @Override
    public int insertFood(Food food)
    {
        food.setCreateTime(DateUtils.getNowDate());
        return foodMapper.insertFood(food);
    }

    /**
     * 修改食品
     * 
     * @param food 食品
     * @return 结果
     */
    @Override
    public int updateFood(Food food)
    {
        food.setUpdateTime(DateUtils.getNowDate());
        return foodMapper.updateFood(food);
    }

    /**
     * 批量删除食品
     * 
     * @param ids 需要删除的食品主键
     * @return 结果
     */
    @Override
    public int deleteFoodByIds(Long[] ids)
    {
        return foodMapper.deleteFoodByIds(ids);
    }

    /**
     * 删除食品信息
     * 
     * @param id 食品主键
     * @return 结果
     */
    @Override
    public int deleteFoodById(Long id)
    {
        return foodMapper.deleteFoodById(id);
    }
}
