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.RoomItemByRoomMapper;
import com.ics.admin.domain.meeting.RoomItemByRoom;
import com.ics.admin.service.meeting.IRoomItemByRoomService;

/**
 * 房间物品关联Service业务层处理
 * 
 * @author chen
 * @date 2024-02-25
 */
@Service
public class RoomItemByRoomServiceImpl extends ServiceImpl<RoomItemByRoomMapper, RoomItemByRoom> implements IRoomItemByRoomService {
    @Autowired
    private RoomItemByRoomMapper roomItemByRoomMapper;

    /**
     * 查询房间物品关联
     * 
     * @param id 房间物品关联ID
     * @return 房间物品关联
     */
    @Override
    public RoomItemByRoom selectRoomItemByRoomById(Long id) {
        return roomItemByRoomMapper.selectById(id);
    }

    /**
     * 查询房间物品关联列表
     * 
     * @param roomItemByRoom 房间物品关联
     * @return 房间物品关联
     */
    @Override
    public List<RoomItemByRoom> selectRoomItemByRoomList(RoomItemByRoom roomItemByRoom) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(roomItemByRoom.getRoomContentId() !=null,"room_content_id",roomItemByRoom.getRoomContentId());
        queryWrapper.eq(roomItemByRoom.getParkId() !=null,"park_id",roomItemByRoom.getParkId());
        return roomItemByRoomMapper.selectList(queryWrapper);
    }

    /**
     * 新增房间物品关联
     * 
     * @param roomItemByRoom 房间物品关联
     * @return 结果
     */
    @Override
    public int insertRoomItemByRoom(RoomItemByRoom roomItemByRoom) {
        return roomItemByRoomMapper.insert(roomItemByRoom);
    }

    /**
     * 修改房间物品关联
     * 
     * @param roomItemByRoom 房间物品关联
     * @return 结果
     */
    @Override
    public int updateRoomItemByRoom(RoomItemByRoom roomItemByRoom) {
        return roomItemByRoomMapper.updateById(roomItemByRoom);
    }

    /**
     * 删除房间物品关联对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteRoomItemByRoomByIds(String ids) {
        String[] idsArray = StrUtil.split(ids,",");
        return roomItemByRoomMapper.deleteBatchIds(CollUtil.toList(idsArray));
    }

    /**
     * 删除房间物品关联信息
     * 
     * @param id 房间物品关联ID
     * @return 结果
     */
    @Override
    public int deleteRoomItemByRoomById(Long id) {
        return roomItemByRoomMapper.deleteRoomItemByRoomById(id);
    }

    @Override
    public List<RoomItemByRoom> selectRoomContent(List<Long> collect, int size) {

        return roomItemByRoomMapper.selectRoomContent(collect,size);
    }
}
