package com.ics.admin.service.impl.meeting;

import java.util.List;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ics.admin.mapper.meeting.ReservationServeMapper;
import com.ics.admin.domain.meeting.ReservationServe;
import com.ics.admin.service.meeting.IReservationServeService;

/**
 * 预约服务关联Service业务层处理
 * 
 * @author chen
 * @date 2024-06-26
 */
@Service
public class ReservationServeServiceImpl extends ServiceImpl<ReservationServeMapper, ReservationServe> implements IReservationServeService {
    @Autowired
    private ReservationServeMapper reservationServeMapper;

    /**
     * 查询预约服务关联
     * 
     * @param id 预约服务关联ID
     * @return 预约服务关联
     */
    @Override
    public ReservationServe selectReservationServeById(Long id) {
        return reservationServeMapper.selectById(id);
    }

    /**
     * 查询预约服务关联列表
     * 
     * @param reservationServe 预约服务关联
     * @return 预约服务关联
     */
    @Override
    public List<ReservationServe> selectReservationServeList(ReservationServe reservationServe) {
        QueryWrapper queryWrapper = new QueryWrapper();
        return reservationServeMapper.selectList(queryWrapper);
    }

    /**
     * 新增预约服务关联
     * 
     * @param reservationServe 预约服务关联
     * @return 结果
     */
    @Override
    public int insertReservationServe(ReservationServe reservationServe) {
        return reservationServeMapper.insert(reservationServe);
    }

    /**
     * 修改预约服务关联
     * 
     * @param reservationServe 预约服务关联
     * @return 结果
     */
    @Override
    public int updateReservationServe(ReservationServe reservationServe) {
        return reservationServeMapper.updateById(reservationServe);
    }

    /**
     * 删除预约服务关联对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteReservationServeByIds(String ids) {
        String[] idsArray = StrUtil.split(ids,",");
        return reservationServeMapper.deleteBatchIds(CollUtil.toList(idsArray));
    }

    /**
     * 删除预约服务关联信息
     * 
     * @param id 预约服务关联ID
     * @return 结果
     */
    @Override
    public int deleteReservationServeById(Long id) {
        return reservationServeMapper.deleteReservationServeById(id);
    }

    @Override
    public List<ReservationServe> selectReservationServeByReservationId(Long id) {

        QueryWrapper<ReservationServe> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("reservation_id",id);
        return reservationServeMapper.selectList(queryWrapper);
    }

}
