package com.xinelu.manage.service.basedietinfo.impl;

import com.xinelu.manage.domain.basedietinfo.BaseDietInfo;
import com.xinelu.manage.mapper.basedietinfo.BaseDietInfoMapper;
import com.xinelu.manage.service.basedietinfo.IBaseDietInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 饮食知识库Service业务层处理
 *
 * @author xinelu
 * @date 2024-05-17
 */
@Service
public class BaseDietInfoServiceImpl implements IBaseDietInfoService {
    @Resource
    private BaseDietInfoMapper baseDietInfoMapper;

    /**
     * 查询饮食知识库
     *
     * @param id 饮食知识库主键
     * @return 饮食知识库
     */
    @Override
    public BaseDietInfo selectBaseDietInfoById(Long id) {
        return baseDietInfoMapper.selectBaseDietInfoById(id);
    }

    /**
     * 查询饮食知识库列表
     *
     * @param baseDietInfo 饮食知识库
     * @return 饮食知识库
     */
    @Override
    public List<BaseDietInfo> selectBaseDietInfoList(BaseDietInfo baseDietInfo) {
        return baseDietInfoMapper.selectBaseDietInfoList(baseDietInfo);
    }

    /**
     * 新增饮食知识库
     *
     * @param baseDietInfo 饮食知识库
     * @return 结果
     */
    @Override
    public int insertBaseDietInfo(BaseDietInfo baseDietInfo) {
        baseDietInfo.setCreateTime(LocalDateTime.now());
        return baseDietInfoMapper.insertBaseDietInfo(baseDietInfo);
    }

    /**
     * 修改饮食知识库
     *
     * @param baseDietInfo 饮食知识库
     * @return 结果
     */
    @Override
    public int updateBaseDietInfo(BaseDietInfo baseDietInfo) {
        baseDietInfo.setUpdateTime(LocalDateTime.now());
        return baseDietInfoMapper.updateBaseDietInfo(baseDietInfo);
    }

    /**
     * 批量删除饮食知识库
     *
     * @param ids 需要删除的饮食知识库主键
     * @return 结果
     */
    @Override
    public int deleteBaseDietInfoByIds(Long[] ids) {
        return baseDietInfoMapper.deleteBaseDietInfoByIds(ids);
    }

    /**
     * 删除饮食知识库信息
     *
     * @param id 饮食知识库主键
     * @return 结果
     */
    @Override
    public int deleteBaseDietInfoById(Long id) {
        return baseDietInfoMapper.deleteBaseDietInfoById(id);
    }
}
