package com.ruoyi.reservation.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.reservation.domain.Reservation;
import com.ruoyi.reservation.mapper.ReservationMasterMapper;
import com.ruoyi.reservation.mapper.ReservationSlaveMapper;
import com.ruoyi.reservation.service.IReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReservationServiceImpl implements IReservationService
{
    @Autowired
    private ReservationMasterMapper masterMapper;
    @Autowired
    private ReservationSlaveMapper slaveMapper;

    @Override
    public int saveSlaveReservation(Reservation reservation) {
        int save = slaveMapper.saveSlaveReservation(reservation);
        return save;
    }
    @Override
    public List<Reservation> selectSlaveReservationList(Reservation reservation)
    {
        return slaveMapper.selectSlaveReservationList(reservation);
    }

    /**
     * 查询预约信息
     *
     * @param id 预约信息主键
     * @return 预约信息
     */
    @Override
    public Reservation selectMasterReservationById(Long id)
    {
        return masterMapper.selectMasterReservationById(id);
    }

    /**
     * 查询预约信息列表
     *
     * @param reservation 预约信息
     * @return 预约信息
     */
    @Override
    public List<Reservation> selectMasterReservationList(Reservation reservation)
    {
        return masterMapper.selectMasterReservationList(reservation);
    }

    /**
     * 新增预约信息
     *
     * @param reservation 预约信息
     * @return 结果
     */
    @Override
    public int insertMasterReservation(Reservation reservation)
    {
        reservation.setCreateTime(DateUtils.getNowDate());
        return masterMapper.insertMasterReservation(reservation);
    }

    /**
     * 修改预约信息
     *
     * @param reservation 预约信息
     * @return 结果
     */
    @Override
    public int updateMasterReservation(Reservation reservation)
    {
        reservation.setUpdateTime(DateUtils.getNowDate());
        return masterMapper.updateMasterReservation(reservation);
    }

    /**
     * 批量删除预约信息
     *
     * @param ids 需要删除的预约信息主键
     * @return 结果
     */
    @Override
    public int deleteMasterReservationByIds(Long[] ids)
    {
        return masterMapper.deleteMasterReservationByIds(ids);
    }

    /**
     * 删除预约信息信息
     *
     * @param id 预约信息主键
     * @return 结果
     */
    @Override
    public int deleteMasterReservationById(Long id)
    {
        return masterMapper.deleteMasterReservationById(id);
    }
}
