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.ShowroomMapper;
import com.ics.admin.domain.meeting.Showroom;
import com.ics.admin.service.meeting.IShowroomService;

/**
 * 展厅管理Service业务层处理
 * 
 * @author ics
 * @date 2024-03-12
 */
@Service
public class ShowroomServiceImpl extends ServiceImpl<ShowroomMapper, Showroom> implements IShowroomService {
    @Autowired
    private ShowroomMapper showroomMapper;

    /**
     * 查询展厅管理
     * 
     * @param id 展厅管理ID
     * @return 展厅管理
     */
    @Override
    public Showroom selectShowroomById(Long id) {
        return showroomMapper.selectById(id);
    }

    /**
     * 查询展厅管理列表
     * 
     * @param showroom 展厅管理
     * @return 展厅管理
     */
    @Override
    public List<Showroom> selectShowroomList(Showroom showroom) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(showroom.getParkId() !=null,"park_id", showroom.getParkId());
        queryWrapper.eq(showroom.getMeetingName() !=null,"meeting_name", showroom.getMeetingName());
        queryWrapper.eq(showroom.getTenantId() !=null,"tenant_id", showroom.getTenantId());
        queryWrapper.eq(showroom.getRoomId() !=null,"room_id", showroom.getRoomId());
        queryWrapper.in(showroom.getRoomIds() !=null,"room_id", showroom.getRoomIds());

        return showroomMapper.selectList(queryWrapper);
    }

    /**
     * 新增展厅管理
     * 
     * @param showroom 展厅管理
     * @return 结果
     */
    @Override
    public int insertShowroom(Showroom showroom) {
        return showroomMapper.insert(showroom);
    }

    /**
     * 修改展厅管理
     * 
     * @param showroom 展厅管理
     * @return 结果
     */
    @Override
    public int updateShowroom(Showroom showroom) {
        return showroomMapper.updateById(showroom);
    }

    /**
     * 删除展厅管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteShowroomByIds(String ids) {
        String[] idsArray = StrUtil.split(ids,",");
        return showroomMapper.deleteBatchIds(CollUtil.toList(idsArray));
    }

    /**
     * 删除展厅管理信息
     * 
     * @param id 展厅管理ID
     * @return 结果
     */
    @Override
    public int deleteShowroomById(Long id) {
        return showroomMapper.deleteShowroomById(id);
    }
}
