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 com.ics.admin.domain.meeting.RoomItem;
import com.ics.admin.mapper.meeting.RoomItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ics.admin.service.meeting.IRoomItemService;

/**
 * 房间物品Service业务层处理
 * 
 * @author chen
 * @date 2024-02-23
 */
@Service
public class RoomItemServiceImpl extends ServiceImpl<RoomItemMapper, RoomItem> implements IRoomItemService {
    @Autowired
    private RoomItemMapper roomItemMapper;

    /**
     * 查询房间物品
     * 
     * @param id 房间物品ID
     * @return 房间物品
     */
    @Override
    public RoomItem selectRoomItemById(Long id) {
        return roomItemMapper.selectById(id);
    }

    /**
     * 查询房间物品列表
     * 
     * @param roomItem 房间物品
     * @return 房间物品
     */
    @Override
    public List<RoomItem> selectRoomItemList(RoomItem roomItem) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like(StrUtil.isNotBlank(roomItem.getName()), "name", roomItem.getName());
        queryWrapper.eq(roomItem.getParkId() !=null,"park_id", roomItem.getParkId());
        queryWrapper.eq(roomItem.getTenantId() !=null,"tenant_id", roomItem.getTenantId());
        return roomItemMapper.selectList(queryWrapper);
    }

    /**
     * 新增房间物品
     * 
     * @param roomItem 房间物品
     * @return 结果
     */
    @Override
    public int insertRoomItem(RoomItem roomItem) {
        return roomItemMapper.insert(roomItem);
    }

    /**
     * 修改房间物品
     * 
     * @param roomItem 房间物品
     * @return 结果
     */
    @Override
    public int updateRoomItem(RoomItem roomItem) {
        return roomItemMapper.updateById(roomItem);
    }

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

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